apify 4.0.0-rc.0 → 4.0.0-rc.1
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/dist/actor.d.ts +250 -29
- package/dist/actor.js +377 -126
- package/dist/apify_request_queue_backend.d.ts +1 -1
- package/dist/apify_request_queue_backend.js +1 -1
- package/dist/apify_request_queue_shared_backend.d.ts +2 -2
- package/dist/apify_request_queue_shared_backend.js +4 -4
- package/dist/apify_storage_backend.js +6 -13
- package/dist/charging.d.ts +27 -5
- package/dist/charging.js +155 -29
- package/dist/charging_storage_backend.js +6 -2
- package/dist/child_run_tracker.d.ts +88 -0
- package/dist/child_run_tracker.js +239 -0
- package/dist/configuration.d.ts +2 -1
- package/dist/configuration.js +2 -1
- package/dist/errors.d.ts +2 -2
- package/dist/google_sheets.d.ts +12 -0
- package/dist/google_sheets.js +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/platform_event_manager.d.ts +13 -2
- package/dist/platform_event_manager.js +178 -32
- package/dist/proxy_configuration.js +5 -2
- package/dist/utils.d.ts +5 -3
- package/dist/utils.js +14 -13
- package/package.json +31 -33
package/dist/actor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EventManager, EventTypeName, RecordOptions, UseStateOptions } from '@crawlee/core';
|
|
2
2
|
import { Dataset, KeyValueStore, RequestQueue } from '@crawlee/core';
|
|
3
3
|
import type { Awaitable, Dictionary, StorageBackend } from '@crawlee/types';
|
|
4
|
-
import type { ActorCallOptions, ActorInput, ActorStartOptions, ApifyClientOptions, RunAbortOptions, TaskCallOptions, WebhookResource, WebhookEventType } from 'apify-client';
|
|
4
|
+
import type { ActorCallOptions, ActorInput, ActorStartOptions, ApifyClientOptions, RunAbortOptions, RunClient, RunResurrectOptions, TaskCallOptions, TaskStartOptions, WebhookResource, WebhookEventType } from 'apify-client';
|
|
5
5
|
import { ApifyClient, Run as ClientActorRun } from 'apify-client';
|
|
6
6
|
import { type ACTOR_PERMISSION_LEVEL } from '@apify/consts';
|
|
7
7
|
import type { RequestQueueAccessMode } from './apify_request_queue_backend.js';
|
|
@@ -115,9 +115,9 @@ export interface ApifyEnv {
|
|
|
115
115
|
*/
|
|
116
116
|
userId: string | null;
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Whether the user who started the Actor is a paying user. `false` when not set. (APIFY_USER_IS_PAYING)
|
|
119
119
|
*/
|
|
120
|
-
userIsPaying:
|
|
120
|
+
userIsPaying: boolean;
|
|
121
121
|
/**
|
|
122
122
|
* Authentication token representing privileges given to the Actor run,
|
|
123
123
|
* it can be passed to various Apify APIs (APIFY_TOKEN)
|
|
@@ -170,17 +170,9 @@ export interface ApifyEnv {
|
|
|
170
170
|
apiPublicBaseUrl: string | null;
|
|
171
171
|
chromeExecutablePath: string | null;
|
|
172
172
|
dedicatedCpus: string | null;
|
|
173
|
-
disableOutdatedWarning: 1 | null;
|
|
174
173
|
fact: string | null;
|
|
175
174
|
inputSecretsPrivateKeyFile: string | null;
|
|
176
175
|
inputSecretsPrivateKeyPassphrase: string | null;
|
|
177
|
-
/**
|
|
178
|
-
* Defines the path to a local directory where KeyValueStore, Dataset, and RequestQueue
|
|
179
|
-
* store their data. Typically, it is set to ./storage. If omitted, you should define the
|
|
180
|
-
* APIFY_TOKEN environment variable instead. See more info on combination of this and
|
|
181
|
-
* 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)
|
|
182
|
-
*/
|
|
183
|
-
localStorageDir: string | null;
|
|
184
176
|
/**
|
|
185
177
|
* Specifies the minimum log level, which can be one of the following values (in order of severity): DEBUG, INFO, WARNING and ERROR
|
|
186
178
|
* (APIFY_LOG_LEVEL)
|
|
@@ -196,7 +188,6 @@ export interface ApifyEnv {
|
|
|
196
188
|
* The key of the input record in the Actor’s default key-value store (ACTOR_INPUT_KEY)
|
|
197
189
|
*/
|
|
198
190
|
inputKey: string | null;
|
|
199
|
-
sdkLatestVersion: string | null;
|
|
200
191
|
systemInfoIntervalMillis: string | null;
|
|
201
192
|
workflowKey: string | null;
|
|
202
193
|
actorBuildNumber: string | null;
|
|
@@ -222,11 +213,38 @@ export interface Timeout {
|
|
|
222
213
|
*/
|
|
223
214
|
timeout?: number | 'inherit';
|
|
224
215
|
}
|
|
225
|
-
export interface
|
|
216
|
+
export interface ChildRunOptions {
|
|
217
|
+
/**
|
|
218
|
+
* Local name for the child run, unique across all Actors and tasks started by this run.
|
|
219
|
+
*
|
|
220
|
+
* If a `READY`, `RUNNING` or `SUCCEEDED` run is already tracked under this name, it is returned instead of
|
|
221
|
+
* starting a new one, including after a migration or resurrection of this run. A run that was aborted or timed out
|
|
222
|
+
* is resurrected with the given options, once it finishes aborting or timing out. A run that failed is replaced
|
|
223
|
+
* by a new one. Reusing the name for a different Actor, task or input throws, unless the tracked run is replaced.
|
|
224
|
+
*/
|
|
225
|
+
runName?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Gracefully abort the child run when this run is gracefully aborted. Requires `runName`.
|
|
228
|
+
*
|
|
229
|
+
* The latest call under the same `runName` sets the value. Once this run is being aborted, a call with this option
|
|
230
|
+
* throws instead of starting, resurrecting or returning a run. A hard abort, timeout or crash of this run leaves
|
|
231
|
+
* the child run running.
|
|
232
|
+
*
|
|
233
|
+
* A run started with a custom `token` is aborted with that token, except for a run started before a migration or
|
|
234
|
+
* resurrection of this run, which is aborted with the default client.
|
|
235
|
+
* @default false
|
|
236
|
+
*/
|
|
237
|
+
abortWithParent?: boolean;
|
|
238
|
+
}
|
|
239
|
+
export interface CallOptions extends Omit<ActorCallOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
|
|
226
240
|
}
|
|
227
|
-
export interface StartOptions extends Omit<ActorStartOptions, 'waitForFinish' | 'runTimeoutSecs'>, Token, Timeout {
|
|
241
|
+
export interface StartOptions extends Omit<ActorStartOptions, 'waitForFinish' | 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
|
|
228
242
|
}
|
|
229
|
-
export interface CallTaskOptions extends Omit<TaskCallOptions, 'runTimeoutSecs'>, Token, Timeout {
|
|
243
|
+
export interface CallTaskOptions extends Omit<TaskCallOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
|
|
244
|
+
}
|
|
245
|
+
export interface ResurrectOptions extends Omit<RunResurrectOptions, 'runTimeoutSecs' | 'maxItems'>, Token, Timeout {
|
|
246
|
+
}
|
|
247
|
+
export interface StartTaskOptions extends Omit<TaskStartOptions, 'waitForFinish' | 'runTimeoutSecs' | 'maxItems'>, Token, Timeout, ChildRunOptions {
|
|
230
248
|
}
|
|
231
249
|
export interface AbortOptions extends RunAbortOptions, Token {
|
|
232
250
|
/** Exit with given status message */
|
|
@@ -305,6 +323,11 @@ export interface MetamorphOptions {
|
|
|
305
323
|
customAfterSleepMillis?: number;
|
|
306
324
|
}
|
|
307
325
|
export interface RebootOptions {
|
|
326
|
+
/**
|
|
327
|
+
* Amount of time, in seconds, to wait for the `persistState` and `migrating` event handlers before rebooting.
|
|
328
|
+
* @default 30
|
|
329
|
+
*/
|
|
330
|
+
timeoutSecs?: number;
|
|
308
331
|
/** @internal */
|
|
309
332
|
customAfterSleepMillis?: number;
|
|
310
333
|
}
|
|
@@ -492,6 +515,25 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
492
515
|
* @ignore
|
|
493
516
|
*/
|
|
494
517
|
abort(runId: string, options?: AbortOptions): Promise<ClientActorRun>;
|
|
518
|
+
/**
|
|
519
|
+
* Resurrects a finished Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
520
|
+
*
|
|
521
|
+
* Only finished runs (SUCCEEDED, FAILED, ABORTED or TIMED-OUT) can be resurrected. The run goes back to the RUNNING
|
|
522
|
+
* status and keeps its default storages. Options you leave out keep the values of the original run.
|
|
523
|
+
*
|
|
524
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
525
|
+
*
|
|
526
|
+
* For more information about Actors, read the
|
|
527
|
+
* [documentation](https://docs.apify.com/actor).
|
|
528
|
+
*
|
|
529
|
+
* **Example usage:**
|
|
530
|
+
*
|
|
531
|
+
* ```js
|
|
532
|
+
* const run = await Actor.resurrect(runId);
|
|
533
|
+
* ```
|
|
534
|
+
* @ignore
|
|
535
|
+
*/
|
|
536
|
+
resurrect(runId: string, options?: ResurrectOptions): Promise<ClientActorRun>;
|
|
495
537
|
/**
|
|
496
538
|
* Runs an actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
497
539
|
*
|
|
@@ -519,6 +561,43 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
519
561
|
* @ignore
|
|
520
562
|
*/
|
|
521
563
|
callTask(taskId: string, input?: Dictionary, options?: CallTaskOptions): Promise<ClientActorRun>;
|
|
564
|
+
/**
|
|
565
|
+
* Clients for the child runs started with the `runName` option, keyed by that name, including the runs started
|
|
566
|
+
* before a migration or resurrection of this run. Each client points to the current run under its name.
|
|
567
|
+
*
|
|
568
|
+
* ```js
|
|
569
|
+
* await Actor.childRuns['my-child'].waitForFinish();
|
|
570
|
+
* ```
|
|
571
|
+
*
|
|
572
|
+
* A run started with a custom `token` uses that token, except for a run started before a migration or
|
|
573
|
+
* resurrection, which uses the default client. The tracked runs, including the earlier runs replaced
|
|
574
|
+
* under the same name, are stored in the default key-value store under the `__ACTOR_CHILD_RUNS` key.
|
|
575
|
+
*/
|
|
576
|
+
get childRuns(): Record<string, RunClient>;
|
|
577
|
+
/**
|
|
578
|
+
* Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
|
|
579
|
+
* unlike `Actor.callTask`, this method just starts the run without waiting for finish.
|
|
580
|
+
*
|
|
581
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
582
|
+
*
|
|
583
|
+
* For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
|
|
584
|
+
*
|
|
585
|
+
* **Example usage:**
|
|
586
|
+
*
|
|
587
|
+
* ```js
|
|
588
|
+
* const run = await Actor.startTask('bob/some-task');
|
|
589
|
+
* ```
|
|
590
|
+
*
|
|
591
|
+
* @param taskId
|
|
592
|
+
* Allowed formats are `username/task-name`, `userId/task-name` or task ID.
|
|
593
|
+
* @param [input]
|
|
594
|
+
* Input overrides for the Actor task. If it is an object, it will be stringified to
|
|
595
|
+
* JSON and its content type set to `application/json; charset=utf-8`.
|
|
596
|
+
* Provided input will be merged with Actor task input.
|
|
597
|
+
* @param [options]
|
|
598
|
+
* @ignore
|
|
599
|
+
*/
|
|
600
|
+
startTask(taskId: string, input?: Dictionary, options?: StartTaskOptions): Promise<ClientActorRun>;
|
|
522
601
|
/**
|
|
523
602
|
* Transforms this Actor run to an Actor run of a given Actor. The system stops the current container and starts
|
|
524
603
|
* the new container instead. All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key
|
|
@@ -557,11 +636,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
557
636
|
/**
|
|
558
637
|
* Sets the status message for the current Actor run.
|
|
559
638
|
*
|
|
560
|
-
* @returns The
|
|
639
|
+
* @returns The updated Run object, or `undefined` when no run was updated: when run locally,
|
|
640
|
+
* or when the update failed or timed out (a warning is logged in that case).
|
|
561
641
|
* For more information, see the [Actor Runs](https://docs.apify.com/api/v2#/reference/actor-runs/) API endpoints.
|
|
562
642
|
* @ignore
|
|
563
643
|
*/
|
|
564
|
-
setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
|
|
644
|
+
setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun | undefined>;
|
|
565
645
|
/**
|
|
566
646
|
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
567
647
|
*
|
|
@@ -588,6 +668,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
588
668
|
* @param item Object or array of objects containing data to be stored in the default dataset.
|
|
589
669
|
* The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
|
|
590
670
|
* @param eventName If provided, the method will attempt to charge for the event for each pushed item.
|
|
671
|
+
* Not supported in multi-tenant Server Actor runs, which charge per request with `Actor.charge()`.
|
|
591
672
|
* @ignore
|
|
592
673
|
*/
|
|
593
674
|
pushData(item: Data | Data[], eventName?: string | undefined): Promise<ChargeResult>;
|
|
@@ -638,6 +719,35 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
638
719
|
* @ignore
|
|
639
720
|
*/
|
|
640
721
|
getValue<T = unknown>(key: string): Promise<T | null>;
|
|
722
|
+
/**
|
|
723
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
724
|
+
*
|
|
725
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
726
|
+
* For example, calling the following code:
|
|
727
|
+
* ```js
|
|
728
|
+
* const value = await Actor.getValue('my-key');
|
|
729
|
+
* ```
|
|
730
|
+
*
|
|
731
|
+
* is equivalent to:
|
|
732
|
+
* ```js
|
|
733
|
+
* const store = await Actor.openKeyValueStore();
|
|
734
|
+
* const value = await store.getValue('my-key');
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
|
|
738
|
+
*
|
|
739
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
740
|
+
* and {@link KeyValueStore.getValue}.
|
|
741
|
+
*
|
|
742
|
+
* @param key Unique record key.
|
|
743
|
+
* @param defaultValue Fallback that will be returned if no value if present in the storage.
|
|
744
|
+
* @returns
|
|
745
|
+
* Returns a promise that resolves to an object, string
|
|
746
|
+
* or [`Buffer`](https://nodejs.org/api/buffer.html), depending
|
|
747
|
+
* on the MIME content type of the record, or the provided default value.
|
|
748
|
+
* @ignore
|
|
749
|
+
*/
|
|
750
|
+
getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
641
751
|
/**
|
|
642
752
|
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
|
|
643
753
|
*
|
|
@@ -677,11 +787,15 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
677
787
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
678
788
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
679
789
|
*
|
|
680
|
-
* When running locally
|
|
681
|
-
*
|
|
790
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
791
|
+
* working directory. A storage backend that doesn't read the default key-value store's directory under
|
|
792
|
+
* the storage directory (e.g. in-memory storage) also gets the file `apify run` writes there.
|
|
682
793
|
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
794
|
+
* Google Sheets sharing links in `requestsFromUrl` entries (from the "Link remote text file" option) are
|
|
795
|
+
* replaced with the links of their CSV exports.
|
|
796
|
+
*
|
|
797
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
798
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
685
799
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
686
800
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest.
|
|
687
801
|
*
|
|
@@ -701,14 +815,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
701
815
|
*/
|
|
702
816
|
getInput<T = Dictionary | string | Buffer>(): Promise<T>;
|
|
703
817
|
/**
|
|
704
|
-
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the
|
|
818
|
+
* Reads the input from a `<inputKey>` or `<inputKey>.json` file in the given directory, for local runs
|
|
705
819
|
* whose default key-value store holds no input record. Mirrors how `ApifyFileSystemStorageBackend` adopts
|
|
706
820
|
* such files inside the store directory: the `.json` file is JSON, the bare one is bytes that
|
|
707
821
|
* {@link parseInputValue} tries as JSON5. Both files present is an error rather than a guess.
|
|
708
822
|
*
|
|
709
823
|
* @returns `undefined` when running on the platform or when neither file exists.
|
|
710
824
|
*/
|
|
711
|
-
private
|
|
825
|
+
private readInputFromDirectory;
|
|
712
826
|
/**
|
|
713
827
|
* Opens a key-value store and returns a promise resolving to an instance of the {@link KeyValueStore} class.
|
|
714
828
|
*
|
|
@@ -804,6 +918,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
804
918
|
* rather than batching via `count` — this gives finer control over budget consumption
|
|
805
919
|
* and avoids situations where more work is requested than the budget allows.
|
|
806
920
|
*
|
|
921
|
+
* **Note:** `idempotencyKey` is scoped to the whole run, not to `requestId`. In a multi-tenant
|
|
922
|
+
* Server Actor run, a key reused across requests charges only the first caller, so it must
|
|
923
|
+
* be globally unique (e.g. derived from `requestId`).
|
|
924
|
+
*
|
|
807
925
|
* @param options The name of the event to charge for and the number of events to be charged.
|
|
808
926
|
* @ignore
|
|
809
927
|
*/
|
|
@@ -813,6 +931,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
813
931
|
* @ignore
|
|
814
932
|
*/
|
|
815
933
|
getChargingManager(): ChargingManager;
|
|
934
|
+
/**
|
|
935
|
+
* Fetches the current Actor run from the Apify API. The result is cached for the lifetime of the Actor,
|
|
936
|
+
* so use `Actor.apifyClient.run(runId).get()` instead when you need fresh data such as the run status.
|
|
937
|
+
* Resolves to `undefined` when not running on the Apify platform.
|
|
938
|
+
*/
|
|
939
|
+
getCurrentRun(): Promise<ClientActorRun | undefined>;
|
|
816
940
|
/**
|
|
817
941
|
* Modifies Actor env vars so parsing respects the structure of {@link ApifyEnv} interface.
|
|
818
942
|
*/
|
|
@@ -1010,6 +1134,29 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1010
1134
|
* @param [options]
|
|
1011
1135
|
*/
|
|
1012
1136
|
static callTask(taskId: string, input?: Dictionary, options?: CallTaskOptions): Promise<ClientActorRun>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Runs an Actor task on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
|
|
1139
|
+
* unlike `Actor.callTask`, this method just starts the run without waiting for finish.
|
|
1140
|
+
*
|
|
1141
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
1142
|
+
*
|
|
1143
|
+
* For more information about Actor tasks, read the [documentation](https://docs.apify.com/tasks).
|
|
1144
|
+
*
|
|
1145
|
+
* **Example usage:**
|
|
1146
|
+
*
|
|
1147
|
+
* ```js
|
|
1148
|
+
* const run = await Actor.startTask('bob/some-task');
|
|
1149
|
+
* ```
|
|
1150
|
+
*
|
|
1151
|
+
* @param taskId
|
|
1152
|
+
* Allowed formats are `username/task-name`, `userId/task-name` or task ID.
|
|
1153
|
+
* @param [input]
|
|
1154
|
+
* Input overrides for the Actor task. If it is an object, it will be stringified to
|
|
1155
|
+
* JSON and its content type set to `application/json; charset=utf-8`.
|
|
1156
|
+
* Provided input will be merged with Actor task input.
|
|
1157
|
+
* @param [options]
|
|
1158
|
+
*/
|
|
1159
|
+
static startTask(taskId: string, input?: Dictionary, options?: StartTaskOptions): Promise<ClientActorRun>;
|
|
1013
1160
|
/**
|
|
1014
1161
|
* Runs an Actor on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable),
|
|
1015
1162
|
* unlike `Actor.call`, this method just starts the run without waiting for finish.
|
|
@@ -1033,6 +1180,19 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1033
1180
|
* @param [options]
|
|
1034
1181
|
*/
|
|
1035
1182
|
static start(actorId: string, input?: Dictionary, options?: StartOptions): Promise<ClientActorRun>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Clients for the child runs started with the `runName` option, keyed by that name, including the runs started
|
|
1185
|
+
* before a migration or resurrection of this run. Each client points to the current run under its name.
|
|
1186
|
+
*
|
|
1187
|
+
* ```js
|
|
1188
|
+
* await Actor.childRuns['my-child'].waitForFinish();
|
|
1189
|
+
* ```
|
|
1190
|
+
*
|
|
1191
|
+
* A run started with a custom `token` uses that token, except for a run started before a migration or
|
|
1192
|
+
* resurrection, which uses the default client. The tracked runs, including the earlier runs replaced
|
|
1193
|
+
* under the same name, are stored in the default key-value store under the `__ACTOR_CHILD_RUNS` key.
|
|
1194
|
+
*/
|
|
1195
|
+
static get childRuns(): Record<string, RunClient>;
|
|
1036
1196
|
/**
|
|
1037
1197
|
* Aborts given Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
1038
1198
|
*
|
|
@@ -1048,6 +1208,24 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1048
1208
|
* ```
|
|
1049
1209
|
*/
|
|
1050
1210
|
static abort(runId: string, options?: AbortOptions): Promise<ClientActorRun>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Resurrects a finished Actor run on the Apify platform using the current user account (determined by the `APIFY_TOKEN` environment variable).
|
|
1213
|
+
*
|
|
1214
|
+
* Only finished runs (SUCCEEDED, FAILED, ABORTED or TIMED-OUT) can be resurrected. The run goes back to the RUNNING
|
|
1215
|
+
* status and keeps its default storages. Options you leave out keep the values of the original run.
|
|
1216
|
+
*
|
|
1217
|
+
* The result of the function is an {@link ActorRun} object that contains details about the Actor run.
|
|
1218
|
+
*
|
|
1219
|
+
* For more information about Actors, read the
|
|
1220
|
+
* [documentation](https://docs.apify.com/actor).
|
|
1221
|
+
*
|
|
1222
|
+
* **Example usage:**
|
|
1223
|
+
*
|
|
1224
|
+
* ```js
|
|
1225
|
+
* const run = await Actor.resurrect(runId);
|
|
1226
|
+
* ```
|
|
1227
|
+
*/
|
|
1228
|
+
static resurrect(runId: string, options?: ResurrectOptions): Promise<ClientActorRun>;
|
|
1051
1229
|
/**
|
|
1052
1230
|
* Transforms this Actor run to an Actor run of a given Actor. The system stops the current container and starts
|
|
1053
1231
|
* the new container instead. All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key
|
|
@@ -1086,10 +1264,11 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1086
1264
|
* @param [options]
|
|
1087
1265
|
* @param [options.isStatusMessageTerminal] If `true`, the status message will be marked as terminal.
|
|
1088
1266
|
* This is required for the last status message of the run. Default value is `false`.
|
|
1089
|
-
* @returns The
|
|
1267
|
+
* @returns The updated Run object, or `undefined` when no run was updated: when run locally,
|
|
1268
|
+
* or when the update failed or timed out (a warning is logged in that case).
|
|
1090
1269
|
* For more information, see the [Actor Runs](https://docs.apify.com/api/v2#/reference/actor-runs/) API endpoints.
|
|
1091
1270
|
*/
|
|
1092
|
-
static setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun>;
|
|
1271
|
+
static setStatusMessage(statusMessage: string, options?: SetStatusMessageOptions): Promise<ClientActorRun | undefined>;
|
|
1093
1272
|
/**
|
|
1094
1273
|
* Stores an object or an array of objects to the default {@link Dataset} of the current Actor run.
|
|
1095
1274
|
*
|
|
@@ -1141,6 +1320,7 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1141
1320
|
* @param item Object or array of objects containing data to be stored in the default dataset.
|
|
1142
1321
|
* The objects must be serializable to JSON and the JSON representation of each object must be smaller than 9MB.
|
|
1143
1322
|
* @param eventName If provided, the method will attempt to charge for the event for each pushed item.
|
|
1323
|
+
* Not supported in multi-tenant Server Actor runs, which charge per request with `Actor.charge()`.
|
|
1144
1324
|
*/
|
|
1145
1325
|
static pushData<Data extends Dictionary = Dictionary>(item: Data | Data[], eventName: string): Promise<ChargeResult>;
|
|
1146
1326
|
/**
|
|
@@ -1188,6 +1368,34 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1188
1368
|
* if the record is missing.
|
|
1189
1369
|
*/
|
|
1190
1370
|
static getValue<T = unknown>(key: string): Promise<T | null>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Gets a value from the default {@link KeyValueStore} associated with the current Actor run.
|
|
1373
|
+
*
|
|
1374
|
+
* This is just a convenient shortcut for {@link KeyValueStore.getValue}.
|
|
1375
|
+
* For example, calling the following code:
|
|
1376
|
+
* ```js
|
|
1377
|
+
* const value = await Actor.getValue('my-key');
|
|
1378
|
+
* ```
|
|
1379
|
+
*
|
|
1380
|
+
* is equivalent to:
|
|
1381
|
+
* ```js
|
|
1382
|
+
* const store = await Actor.openKeyValueStore();
|
|
1383
|
+
* const value = await store.getValue('my-key');
|
|
1384
|
+
* ```
|
|
1385
|
+
*
|
|
1386
|
+
* To store the value to the default key-value store, you can use the {@link Actor.setValue} function.
|
|
1387
|
+
*
|
|
1388
|
+
* For more information, see {@link Actor.openKeyValueStore}
|
|
1389
|
+
* and {@link KeyValueStore.getValue}.
|
|
1390
|
+
*
|
|
1391
|
+
* @param key Unique record key.
|
|
1392
|
+
* @param defaultValue Fallback that will be returned if no value if present in the storage.
|
|
1393
|
+
* @returns
|
|
1394
|
+
* Returns a promise that resolves to an object, string
|
|
1395
|
+
* or [`Buffer`](https://nodejs.org/api/buffer.html), depending
|
|
1396
|
+
* on the MIME content type of the record, or the provided default value.
|
|
1397
|
+
*/
|
|
1398
|
+
static getValue<T = unknown>(key: string, defaultValue: T): Promise<T>;
|
|
1191
1399
|
/**
|
|
1192
1400
|
* Stores or deletes a value in the default {@link KeyValueStore} associated with the current Actor run.
|
|
1193
1401
|
*
|
|
@@ -1230,11 +1438,14 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1230
1438
|
* A record stored as `application/octet-stream` — which is what a local input file without an
|
|
1231
1439
|
* extension is read as — is parsed with JSON5 when it parses, and returned as a `Buffer` otherwise.
|
|
1232
1440
|
*
|
|
1233
|
-
* When running locally
|
|
1234
|
-
*
|
|
1441
|
+
* When running locally, the input may instead be a `<inputKey>` or `<inputKey>.json` file in the current
|
|
1442
|
+
* working directory.
|
|
1235
1443
|
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1444
|
+
* Google Sheets sharing links in `requestsFromUrl` entries (from the "Link remote text file" option) are
|
|
1445
|
+
* replaced with the links of their CSV exports.
|
|
1446
|
+
*
|
|
1447
|
+
* Throws an {@link ActorInputError} when no input is found (`code: 'NOT_FOUND'`), when the input is
|
|
1448
|
+
* found in more than one place (`'MULTIPLE_FILES'`), when a JSON input does not parse
|
|
1238
1449
|
* (`'PARSE_FAILED'`) or when its secret fields cannot be decrypted (`'DECRYPTION_FAILED'`). If your
|
|
1239
1450
|
* Actor can run without input, catch the `'NOT_FOUND'` case and rethrow the rest:
|
|
1240
1451
|
* ```js
|
|
@@ -1348,6 +1559,10 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1348
1559
|
* rather than batching via `count` — this gives finer control over budget consumption
|
|
1349
1560
|
* and avoids situations where more work is requested than the budget allows.
|
|
1350
1561
|
*
|
|
1562
|
+
* **Note:** `idempotencyKey` is scoped to the whole run, not to `requestId`. In a multi-tenant
|
|
1563
|
+
* Server Actor run, a key reused across requests charges only the first caller, so it must
|
|
1564
|
+
* be globally unique (e.g. derived from `requestId`).
|
|
1565
|
+
*
|
|
1351
1566
|
* @param options The name of the event to charge for and the number of events to be charged.
|
|
1352
1567
|
*/
|
|
1353
1568
|
static charge(options: ChargeOptions): Promise<ChargeResult>;
|
|
@@ -1375,6 +1590,12 @@ export declare class Actor<Data extends Dictionary = Dictionary> {
|
|
|
1375
1590
|
* Returns `true` when code is running on Apify platform and `false` otherwise (for example locally).
|
|
1376
1591
|
*/
|
|
1377
1592
|
static isAtHome(): boolean;
|
|
1593
|
+
/**
|
|
1594
|
+
* Fetches the current Actor run from the Apify API. The result is cached for the lifetime of the Actor,
|
|
1595
|
+
* so use `Actor.apifyClient.run(runId).get()` instead when you need fresh data such as the run status.
|
|
1596
|
+
* Resolves to `undefined` when not running on the Apify platform.
|
|
1597
|
+
*/
|
|
1598
|
+
static getCurrentRun(): Promise<ClientActorRun | undefined>;
|
|
1378
1599
|
/** Default {@link ApifyClient} instance. */
|
|
1379
1600
|
static get apifyClient(): ApifyClient;
|
|
1380
1601
|
/** Default {@link Configuration} instance. */
|