apify 3.7.3-beta.96 → 4.0.0-beta.100

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/actor.d.ts +379 -139
  3. package/dist/actor.js +764 -500
  4. package/dist/apify_dataset_backend.d.ts +19 -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 +23 -0
  9. package/dist/apify_key_value_store_backend.js +56 -0
  10. package/dist/apify_request_queue_backend.d.ts +78 -0
  11. package/dist/apify_request_queue_backend.js +114 -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 +39 -44
  19. package/dist/charging.js +245 -292
  20. package/dist/charging_storage_backend.d.ts +53 -0
  21. package/dist/charging_storage_backend.js +105 -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 +85 -144
  25. package/dist/configuration.js +138 -174
  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 +10 -4
  33. package/dist/index.js +12 -22
  34. package/dist/input-schemas.d.ts +1 -1
  35. package/dist/input-schemas.js +12 -18
  36. package/dist/platform_event_manager.d.ts +15 -10
  37. package/dist/platform_event_manager.js +193 -63
  38. package/dist/proxy_configuration.d.ts +52 -72
  39. package/dist/proxy_configuration.js +176 -221
  40. package/dist/smart_apify_storage_backend.d.ts +52 -0
  41. package/dist/smart_apify_storage_backend.js +73 -0
  42. package/dist/storage.d.ts +6 -24
  43. package/dist/storage.js +1 -79
  44. package/dist/utils.d.ts +30 -0
  45. package/dist/utils.js +81 -23
  46. package/package.json +38 -43
  47. package/dist/index.mjs +0 -19
  48. package/dist/key_value_store.d.ts +0 -16
  49. package/dist/key_value_store.js +0 -40
  50. package/dist/patched_apify_client.d.ts +0 -25
  51. package/dist/patched_apify_client.js +0 -75
@@ -0,0 +1,29 @@
1
+ import type { RequestOptions } from '@crawlee/core';
2
+ /** Request options that the `globs` and `pseudoUrls` input editors can attach to a single URL pattern. */
3
+ export interface UrlPatternRequestOptions extends Pick<RequestOptions, 'method' | 'payload' | 'label' | 'userData' | 'headers'> {
4
+ }
5
+ /** A single item of an input schema array field using the `globs` editor. */
6
+ export interface GlobInput extends UrlPatternRequestOptions {
7
+ glob: string;
8
+ }
9
+ /** A single item of an input schema array field using the `pseudoUrls` editor. */
10
+ export interface PseudoUrlInput extends UrlPatternRequestOptions {
11
+ purl: string;
12
+ }
13
+ export interface UrlPatternFilters {
14
+ /** Value of an input schema field using the `globs` editor. */
15
+ globs?: readonly (string | GlobInput)[];
16
+ /** Value of an input schema field using the `pseudoUrls` editor. */
17
+ pseudoUrls?: readonly (string | PseudoUrlInput)[];
18
+ }
19
+ /**
20
+ * Turns the `globs` and `pseudoUrls` input editor values into a `transformRequestFunction` that skips requests
21
+ * matching no pattern (all requests pass when no pattern is given) and applies the options of the matched pattern.
22
+ * When a URL matches multiple patterns, the first one wins, with globs checked before pseudo-URLs. The matched
23
+ * pattern's options shallowly override the request's fields, including `userData` (no deep merge, like in v3).
24
+ *
25
+ * ```ts
26
+ * await enqueueLinks({ transformRequestFunction: createTransformRequestFunction({ globs: input.globs }) });
27
+ * ```
28
+ */
29
+ export declare function createTransformRequestFunction({ globs, pseudoUrls, }: UrlPatternFilters): (request: RequestOptions) => RequestOptions | false | 'unchanged';
@@ -0,0 +1,52 @@
1
+ import { Minimatch } from 'minimatch';
2
+ import { purlToRegExp } from '@apify/pseudo_url';
3
+ /**
4
+ * Turns the `globs` and `pseudoUrls` input editor values into a `transformRequestFunction` that skips requests
5
+ * matching no pattern (all requests pass when no pattern is given) and applies the options of the matched pattern.
6
+ * When a URL matches multiple patterns, the first one wins, with globs checked before pseudo-URLs. The matched
7
+ * pattern's options shallowly override the request's fields, including `userData` (no deep merge, like in v3).
8
+ *
9
+ * ```ts
10
+ * await enqueueLinks({ transformRequestFunction: createTransformRequestFunction({ globs: input.globs }) });
11
+ * ```
12
+ */
13
+ export function createTransformRequestFunction({ globs = [], pseudoUrls = [], }) {
14
+ const patterns = [
15
+ ...globs.flatMap((item) => {
16
+ if (item == null) {
17
+ return [];
18
+ }
19
+ const { glob, ...options } = typeof item === 'string' ? { glob: item } : item;
20
+ const trimmedGlob = typeof glob === 'string' ? glob.trim() : '';
21
+ if (trimmedGlob.length === 0) {
22
+ return [];
23
+ }
24
+ const minimatch = new Minimatch(trimmedGlob, { nocase: true });
25
+ return [{ matches: (url) => minimatch.match(url), options }];
26
+ }),
27
+ ...pseudoUrls.flatMap((item) => {
28
+ if (item == null) {
29
+ return [];
30
+ }
31
+ const { purl, ...options } = typeof item === 'string' ? { purl: item } : item;
32
+ if (typeof purl !== 'string' || purl.trim().length === 0) {
33
+ return [];
34
+ }
35
+ let regexp;
36
+ try {
37
+ regexp = purlToRegExp(purl);
38
+ }
39
+ catch (cause) {
40
+ throw new Error(`Invalid pseudoUrl pattern '${purl}': ${cause.message}`, { cause });
41
+ }
42
+ return [{ matches: (url) => regexp.test(url), options }];
43
+ }),
44
+ ];
45
+ if (patterns.length === 0) {
46
+ return () => 'unchanged';
47
+ }
48
+ return (request) => {
49
+ const matched = patterns.find(({ matches }) => matches(request.url));
50
+ return matched ? { ...request, ...matched.options } : false;
51
+ };
52
+ }
@@ -0,0 +1,31 @@
1
+ /** Why {@link Actor.getInput} could not produce the input. */
2
+ export type ActorInputErrorCode =
3
+ /** No input record in the default key-value store, and locally no input file either. */
4
+ 'NOT_FOUND'
5
+ /** The input is in more than one place — both `<inputKey>` and `<inputKey>.json` in one directory, or in the store and in the working directory — so none is picked. */
6
+ | 'MULTIPLE_FILES'
7
+ /** The secret fields of the input could not be decrypted; `cause` holds the underlying error. */
8
+ | 'DECRYPTION_FAILED'
9
+ /** A JSON input record or file does not parse; `cause` holds the parser error. */
10
+ | 'PARSE_FAILED';
11
+ /**
12
+ * Thrown by {@link Actor.getInput} when the Actor input cannot be produced. `code` says why, and
13
+ * `cause` carries the underlying error where there is one. Anything else thrown by `getInput()`, such as
14
+ * an Apify API error, is not an input problem and is passed through as is.
15
+ *
16
+ * ```js
17
+ * try {
18
+ * input = await Actor.getInput();
19
+ * } catch (error) {
20
+ * if (!(error instanceof ActorInputError) || error.code !== 'NOT_FOUND') throw error;
21
+ * input = {};
22
+ * }
23
+ * ```
24
+ */
25
+ export declare class ActorInputError extends Error {
26
+ readonly name = "ActorInputError";
27
+ readonly code: ActorInputErrorCode;
28
+ constructor(code: ActorInputErrorCode, message: string, options?: {
29
+ cause?: unknown;
30
+ });
31
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Thrown by {@link Actor.getInput} when the Actor input cannot be produced. `code` says why, and
3
+ * `cause` carries the underlying error where there is one. Anything else thrown by `getInput()`, such as
4
+ * an Apify API error, is not an input problem and is passed through as is.
5
+ *
6
+ * ```js
7
+ * try {
8
+ * input = await Actor.getInput();
9
+ * } catch (error) {
10
+ * if (!(error instanceof ActorInputError) || error.code !== 'NOT_FOUND') throw error;
11
+ * input = {};
12
+ * }
13
+ * ```
14
+ */
15
+ export class ActorInputError extends Error {
16
+ name = 'ActorInputError';
17
+ code;
18
+ constructor(code, message, options) {
19
+ super(message, options);
20
+ this.code = code;
21
+ }
22
+ }
@@ -0,0 +1,12 @@
1
+ import type { Dictionary } from '@crawlee/types';
2
+ /**
3
+ * Turns a Google Sheets sharing link into the link of its CSV export, other URLs are returned unchanged.
4
+ * @internal
5
+ */
6
+ export declare function toGoogleSheetsCsvUrl(url: string): string;
7
+ /**
8
+ * Replaces Google Sheets sharing links in the `requestsFromUrl` entries of the input's array fields (as produced by
9
+ * the "Link remote text file" option of the `requestListSources` editor) with the links of their CSV exports.
10
+ * @internal
11
+ */
12
+ export declare function fixGoogleSheetsUrls<T extends Dictionary>(input: T): T;
@@ -0,0 +1,26 @@
1
+ // Links published to the web (`/spreadsheets/d/e/<id>/pub?output=csv`) and links that already point at an export
2
+ // (`/gviz/...`, `/export...`) are downloadable as they are, so they're left alone.
3
+ const GOOGLE_SHEETS_URL_REGEX = /^(https:\/\/docs\.google\.com\/spreadsheets\/d\/(?!e\/)(?:\w|-)+)(\/(?:gviz|export)\b)?/;
4
+ /**
5
+ * Turns a Google Sheets sharing link into the link of its CSV export, other URLs are returned unchanged.
6
+ * @internal
7
+ */
8
+ export function toGoogleSheetsCsvUrl(url) {
9
+ const match = GOOGLE_SHEETS_URL_REGEX.exec(url);
10
+ return match && !match[2] ? `${match[1]}/gviz/tq?tqx=out:csv` : url;
11
+ }
12
+ /**
13
+ * Replaces Google Sheets sharing links in the `requestsFromUrl` entries of the input's array fields (as produced by
14
+ * the "Link remote text file" option of the `requestListSources` editor) with the links of their CSV exports.
15
+ * @internal
16
+ */
17
+ export function fixGoogleSheetsUrls(input) {
18
+ return Object.fromEntries(Object.entries(input).map(([key, value]) => [
19
+ key,
20
+ Array.isArray(value)
21
+ ? value.map((item) => typeof item?.requestsFromUrl === 'string'
22
+ ? { ...item, requestsFromUrl: toGoogleSheetsCsvUrl(item.requestsFromUrl) }
23
+ : item)
24
+ : value,
25
+ ]));
26
+ }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  export * from './actor.js';
2
- export type { OpenStorageOptions, StorageAlias, StorageId, StorageName, StorageIdentifier, StorageIdentifierWithoutAlias, } from './storage.js';
2
+ export { ApifyStorageBackend, type ApifyStorageBackendOptions } from './apify_storage_backend.js';
3
+ export { ApifyFileSystemStorageBackend, type ApifyFileSystemStorageOptions, } from './apify_file_system_storage_backend.js';
4
+ export type { RequestQueueAccessMode } from './apify_request_queue_backend.js';
5
+ export { ArgumentValidationError } from './utils.js';
6
+ export { ActorInputError, type ActorInputErrorCode } from './errors.js';
7
+ export { createTransformRequestFunction, type GlobInput, type PseudoUrlInput, type UrlPatternFilters, type UrlPatternRequestOptions, } from './enqueue_links_filters.js';
8
+ export type { OpenStorageOptions, StorageAlias, StorageId, StorageName, StorageIdentifier } from './storage.js';
3
9
  export { ChargeOptions, ChargeResult, ActorPricingInfo, ChargingManager } from './charging.js';
4
10
  export * from './configuration.js';
5
11
  export * from './proxy_configuration.js';
6
12
  export * from './platform_event_manager.js';
7
- export * from './key_value_store.js';
8
- export { Dataset, DatasetDataOptions, DatasetIteratorOptions, DatasetConsumer, DatasetMapper, DatasetReducer, DatasetOptions, DatasetContent, RequestQueue, QueueOperationInfo, RequestQueueOperationOptions, RequestQueueOptions, KeyConsumer, KeyValueStoreOptions, RecordOptions, KeyValueStoreIteratorOptions, log, Log, LoggerOptions, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
9
- export { ApifyClient, ApifyClientOptions } from 'apify-client';
13
+ export { Dataset, DatasetDataOptions, DatasetIteratorOptions, DatasetConsumer, DatasetMapper, DatasetReducer, DatasetOptions, DatasetContent, RequestQueue, RequestQueueOperationOptions, RequestQueueOptions, KeyValueStore, KeyConsumer, KeyValueStoreOptions, RecordOptions, KeyValueStoreIteratorOptions, log, Log, LoggerOptions, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
14
+ export type { QueueOperationInfo } from '@crawlee/types';
15
+ export { ApifyClient, ApifyClientOptions, ApifyApiError, InvalidRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, InvalidResponseBodyError, ResponseValidationError, } from 'apify-client';
package/dist/index.js CHANGED
@@ -1,22 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApifyClient = exports.LoggerText = exports.LoggerJson = exports.Logger = exports.LogLevel = exports.Log = exports.log = exports.RequestQueue = exports.Dataset = exports.ChargingManager = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./actor.js"), exports);
6
- var charging_js_1 = require("./charging.js");
7
- Object.defineProperty(exports, "ChargingManager", { enumerable: true, get: function () { return charging_js_1.ChargingManager; } });
8
- tslib_1.__exportStar(require("./configuration.js"), exports);
9
- tslib_1.__exportStar(require("./proxy_configuration.js"), exports);
10
- tslib_1.__exportStar(require("./platform_event_manager.js"), exports);
11
- tslib_1.__exportStar(require("./key_value_store.js"), exports);
12
- var core_1 = require("@crawlee/core");
13
- Object.defineProperty(exports, "Dataset", { enumerable: true, get: function () { return core_1.Dataset; } });
14
- Object.defineProperty(exports, "RequestQueue", { enumerable: true, get: function () { return core_1.RequestQueue; } });
15
- Object.defineProperty(exports, "log", { enumerable: true, get: function () { return core_1.log; } });
16
- Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return core_1.Log; } });
17
- Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return core_1.LogLevel; } });
18
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } });
19
- Object.defineProperty(exports, "LoggerJson", { enumerable: true, get: function () { return core_1.LoggerJson; } });
20
- Object.defineProperty(exports, "LoggerText", { enumerable: true, get: function () { return core_1.LoggerText; } });
21
- var apify_client_1 = require("apify-client");
22
- Object.defineProperty(exports, "ApifyClient", { enumerable: true, get: function () { return apify_client_1.ApifyClient; } });
1
+ export * from './actor.js';
2
+ export { ApifyStorageBackend } from './apify_storage_backend.js';
3
+ export { ApifyFileSystemStorageBackend, } from './apify_file_system_storage_backend.js';
4
+ export { ArgumentValidationError } from './utils.js';
5
+ export { ActorInputError } from './errors.js';
6
+ export { createTransformRequestFunction, } from './enqueue_links_filters.js';
7
+ export { ChargingManager } from './charging.js';
8
+ export * from './configuration.js';
9
+ export * from './proxy_configuration.js';
10
+ export * from './platform_event_manager.js';
11
+ export { Dataset, RequestQueue, KeyValueStore, log, Log, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
12
+ export { ApifyClient, ApifyApiError, InvalidRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, InvalidResponseBodyError, ResponseValidationError, } from 'apify-client';
@@ -1,4 +1,4 @@
1
- import type { Dictionary } from '@crawlee/utils';
1
+ import type { Dictionary } from '@crawlee/types';
2
2
  /**
3
3
  * @ignore
4
4
  */
@@ -1,11 +1,7 @@
1
- "use strict";
2
1
  // TODO: https://github.com/apify/apify-shared-js/issues/547
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getDefaultsFromInputSchema = exports.readInputSchema = exports.noActorInputSchemaDefinedMarker = void 0;
5
- const tslib_1 = require("tslib");
6
- const node_fs_1 = require("node:fs");
7
- const node_path_1 = require("node:path");
8
- const node_process_1 = tslib_1.__importDefault(require("node:process"));
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import process from 'node:process';
9
5
  // These paths are used *if* there is no `input` field in the actor.json configuration file!
10
6
  const DEFAULT_INPUT_SCHEMA_PATHS = [
11
7
  ['.actor', 'INPUT_SCHEMA.json'],
@@ -16,8 +12,8 @@ const DEFAULT_INPUT_SCHEMA_PATHS = [
16
12
  const ACTOR_SPECIFICATION_FOLDER = '.actor';
17
13
  const LOCAL_CONFIG_NAME = 'actor.json';
18
14
  const readJSONIfExists = (path) => {
19
- if ((0, node_fs_1.existsSync)(path)) {
20
- const content = (0, node_fs_1.readFileSync)(path, 'utf8');
15
+ if (existsSync(path)) {
16
+ const content = readFileSync(path, 'utf8');
21
17
  return JSON.parse(content);
22
18
  }
23
19
  return null;
@@ -25,21 +21,21 @@ const readJSONIfExists = (path) => {
25
21
  /**
26
22
  * @ignore
27
23
  */
28
- exports.noActorInputSchemaDefinedMarker = Symbol.for('apify.noActorInputSchemaDefined');
29
- const readInputSchema = () => {
30
- const localConfig = readJSONIfExists((0, node_path_1.join)(node_process_1.default.cwd(), ACTOR_SPECIFICATION_FOLDER, LOCAL_CONFIG_NAME));
24
+ export const noActorInputSchemaDefinedMarker = Symbol.for('apify.noActorInputSchemaDefined');
25
+ export const readInputSchema = () => {
26
+ const localConfig = readJSONIfExists(join(process.cwd(), ACTOR_SPECIFICATION_FOLDER, LOCAL_CONFIG_NAME));
31
27
  // Input schema nested in the actor config
32
28
  if (typeof localConfig?.input === 'object') {
33
29
  return localConfig.input;
34
30
  }
35
31
  // Input schema path from the actor config
36
32
  if (typeof localConfig?.input === 'string') {
37
- const fullPath = (0, node_path_1.join)(node_process_1.default.cwd(), ACTOR_SPECIFICATION_FOLDER, localConfig.input);
33
+ const fullPath = join(process.cwd(), ACTOR_SPECIFICATION_FOLDER, localConfig.input);
38
34
  return readJSONIfExists(fullPath);
39
35
  }
40
36
  // Try to find it from possible default paths
41
37
  for (const path of DEFAULT_INPUT_SCHEMA_PATHS) {
42
- const fullPath = (0, node_path_1.join)(node_process_1.default.cwd(), ...path);
38
+ const fullPath = join(process.cwd(), ...path);
43
39
  const result = readJSONIfExists(fullPath);
44
40
  if (result) {
45
41
  return result;
@@ -47,12 +43,11 @@ const readInputSchema = () => {
47
43
  }
48
44
  // If we are in an Actor context, BUT we do not have an input schema defined, we want to skip the warning
49
45
  if (!localConfig?.input) {
50
- return exports.noActorInputSchemaDefinedMarker;
46
+ return noActorInputSchemaDefinedMarker;
51
47
  }
52
48
  return null;
53
49
  };
54
- exports.readInputSchema = readInputSchema;
55
- const getDefaultsFromInputSchema = (inputSchema) => {
50
+ export const getDefaultsFromInputSchema = (inputSchema) => {
56
51
  const defaults = {};
57
52
  for (const [key, fieldSchema] of Object.entries(inputSchema.properties)) {
58
53
  if (fieldSchema.default !== undefined) {
@@ -61,4 +56,3 @@ const getDefaultsFromInputSchema = (inputSchema) => {
61
56
  }
62
57
  return defaults;
63
58
  };
64
- exports.getDefaultsFromInputSchema = getDefaultsFromInputSchema;
@@ -1,3 +1,4 @@
1
+ import type { EventTypeName } from '@crawlee/core';
1
2
  import { EventManager } from '@crawlee/core';
2
3
  import { Configuration } from './configuration.js';
3
4
  /**
@@ -26,15 +27,10 @@ import { Configuration } from './configuration.js';
26
27
  * You can use it to persist the state of the Actor and gracefully stop your in-progress tasks,
27
28
  * so that they are not interrupted by the migration.
28
29
  * For example, this is used by the {@link RequestList} class.
29
- * If you pass `gracefulShutdown: true` to {@link Actor.init}, the SDK will automatically call
30
- * {@link Actor.reboot} when this event is received, which speeds up the migration and lets the
31
- * run continue on a new worker.
32
30
  * - `aborting`: `void`
33
31
  * When a user aborts an Actor run on the Apify platform, they can choose to abort gracefully to allow
34
32
  * the Actor some time before getting killed. This graceful abort emits the `aborting` event which the SDK
35
33
  * uses to gracefully stop running crawls and you can use it to do your own cleanup as well.
36
- * If you pass `gracefulShutdown: true` to {@link Actor.init}, the SDK will automatically call
37
- * {@link Actor.exit} when this event is received.
38
34
  * - `persistState`: `{ "isMigrating": Boolean }`
39
35
  * Emitted in regular intervals (by default 60 seconds) to notify all components of Apify SDK that it is time to persist
40
36
  * their state, in order to avoid repeating all work when the Actor restarts.
@@ -42,18 +38,27 @@ import { Configuration } from './configuration.js';
42
38
  * in which case the `isMigrating` flag is set to `true`. Otherwise the flag is `false`.
43
39
  * Note that the `persistState` event is provided merely for user convenience,
44
40
  * you can achieve the same effect using `setInterval()` and listening for the `migrating` event.
41
+ *
42
+ * The connection to the platform events websocket is re-established after it drops, unless it was closed
43
+ * with a code signalling a permanent condition (e.g. `1008` for an unknown run ID).
45
44
  */
46
45
  export declare class PlatformEventManager extends EventManager {
47
- readonly config: Configuration;
48
- /** Websocket connection to Actor events. */
49
- private eventsWs?;
50
- constructor(config?: Configuration);
46
+ #private;
47
+ readonly configuration: Configuration;
48
+ /**
49
+ * @param internalListeners Listeners of the SDK itself, kept apart from the ones registered with `on()`, so that
50
+ * user code can neither remove them with `off()` nor see them in `listeners()`.
51
+ */
52
+ constructor(configuration?: Configuration, internalListeners?: Partial<Record<EventTypeName, (...args: any[]) => unknown>>);
53
+ emit(event: EventTypeName, ...args: unknown[]): void;
54
+ waitForAllListenersToComplete(): Promise<boolean>;
51
55
  /**
52
56
  * Initializes `Actor.events` event emitter by creating a connection to a websocket that provides them.
53
57
  * This is an internal function that is automatically called by `Actor.main()`.
58
+ *
59
+ * Rejects if the first connection cannot be established. Later drops are handled by reconnecting.
54
60
  */
55
61
  init(): Promise<void>;
56
- private createWebSocketConnection;
57
62
  /**
58
63
  * Closes websocket providing events from Actor infrastructure and also stops sending internal events
59
64
  * of Apify package such as `persistState`.