apify 2.3.1-beta.4 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/package.json +69 -128
- package/build/actor.d.ts +0 -113
- package/build/actor.d.ts.map +0 -1
- package/build/actor.js +0 -582
- package/build/actor.js.map +0 -1
- package/build/apify.d.ts +0 -752
- package/build/apify.d.ts.map +0 -1
- package/build/apify.js +0 -877
- package/build/apify.js.map +0 -1
- package/build/autoscaling/autoscaled_pool.d.ts +0 -384
- package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/build/autoscaling/autoscaled_pool.js +0 -557
- package/build/autoscaling/autoscaled_pool.js.map +0 -1
- package/build/autoscaling/snapshotter.d.ts +0 -278
- package/build/autoscaling/snapshotter.d.ts.map +0 -1
- package/build/autoscaling/snapshotter.js +0 -447
- package/build/autoscaling/snapshotter.js.map +0 -1
- package/build/autoscaling/system_status.d.ts +0 -224
- package/build/autoscaling/system_status.d.ts.map +0 -1
- package/build/autoscaling/system_status.js +0 -228
- package/build/autoscaling/system_status.js.map +0 -1
- package/build/browser_launchers/browser_launcher.d.ts +0 -154
- package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
- package/build/browser_launchers/browser_launcher.js +0 -160
- package/build/browser_launchers/browser_launcher.js.map +0 -1
- package/build/browser_launchers/browser_plugin.d.ts +0 -23
- package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
- package/build/browser_launchers/browser_plugin.js +0 -25
- package/build/browser_launchers/browser_plugin.js.map +0 -1
- package/build/browser_launchers/playwright_launcher.d.ts +0 -131
- package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
- package/build/browser_launchers/playwright_launcher.js +0 -150
- package/build/browser_launchers/playwright_launcher.js.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
- package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.js +0 -197
- package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
- package/build/cache_container.d.ts +0 -31
- package/build/cache_container.d.ts.map +0 -1
- package/build/cache_container.js +0 -48
- package/build/cache_container.js.map +0 -1
- package/build/configuration.d.ts +0 -226
- package/build/configuration.d.ts.map +0 -1
- package/build/configuration.js +0 -325
- package/build/configuration.js.map +0 -1
- package/build/constants.d.ts +0 -37
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -41
- package/build/constants.js.map +0 -1
- package/build/crawlers/basic_crawler.d.ts +0 -443
- package/build/crawlers/basic_crawler.d.ts.map +0 -1
- package/build/crawlers/basic_crawler.js +0 -664
- package/build/crawlers/basic_crawler.js.map +0 -1
- package/build/crawlers/browser_crawler.d.ts +0 -512
- package/build/crawlers/browser_crawler.d.ts.map +0 -1
- package/build/crawlers/browser_crawler.js +0 -540
- package/build/crawlers/browser_crawler.js.map +0 -1
- package/build/crawlers/cheerio_crawler.d.ts +0 -931
- package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
- package/build/crawlers/cheerio_crawler.js +0 -913
- package/build/crawlers/cheerio_crawler.js.map +0 -1
- package/build/crawlers/crawler_extension.d.ts +0 -10
- package/build/crawlers/crawler_extension.d.ts.map +0 -1
- package/build/crawlers/crawler_extension.js +0 -19
- package/build/crawlers/crawler_extension.js.map +0 -1
- package/build/crawlers/crawler_utils.d.ts +0 -34
- package/build/crawlers/crawler_utils.d.ts.map +0 -1
- package/build/crawlers/crawler_utils.js +0 -87
- package/build/crawlers/crawler_utils.js.map +0 -1
- package/build/crawlers/playwright_crawler.d.ts +0 -448
- package/build/crawlers/playwright_crawler.d.ts.map +0 -1
- package/build/crawlers/playwright_crawler.js +0 -299
- package/build/crawlers/playwright_crawler.js.map +0 -1
- package/build/crawlers/puppeteer_crawler.d.ts +0 -425
- package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
- package/build/crawlers/puppeteer_crawler.js +0 -299
- package/build/crawlers/puppeteer_crawler.js.map +0 -1
- package/build/crawlers/statistics.d.ts +0 -185
- package/build/crawlers/statistics.d.ts.map +0 -1
- package/build/crawlers/statistics.js +0 -331
- package/build/crawlers/statistics.js.map +0 -1
- package/build/enqueue_links/click_elements.d.ts +0 -179
- package/build/enqueue_links/click_elements.d.ts.map +0 -1
- package/build/enqueue_links/click_elements.js +0 -434
- package/build/enqueue_links/click_elements.js.map +0 -1
- package/build/enqueue_links/enqueue_links.d.ts +0 -117
- package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/build/enqueue_links/enqueue_links.js +0 -163
- package/build/enqueue_links/enqueue_links.js.map +0 -1
- package/build/enqueue_links/shared.d.ts +0 -42
- package/build/enqueue_links/shared.d.ts.map +0 -1
- package/build/enqueue_links/shared.js +0 -121
- package/build/enqueue_links/shared.js.map +0 -1
- package/build/errors.d.ts +0 -29
- package/build/errors.d.ts.map +0 -1
- package/build/errors.js +0 -38
- package/build/errors.js.map +0 -1
- package/build/events.d.ts +0 -11
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -147
- package/build/events.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/main.d.ts +0 -179
- package/build/main.d.ts.map +0 -1
- package/build/main.js +0 -81
- package/build/main.js.map +0 -1
- package/build/playwright_utils.d.ts +0 -9
- package/build/playwright_utils.d.ts.map +0 -1
- package/build/playwright_utils.js +0 -90
- package/build/playwright_utils.js.map +0 -1
- package/build/proxy_configuration.d.ts +0 -411
- package/build/proxy_configuration.d.ts.map +0 -1
- package/build/proxy_configuration.js +0 -517
- package/build/proxy_configuration.js.map +0 -1
- package/build/pseudo_url.d.ts +0 -86
- package/build/pseudo_url.d.ts.map +0 -1
- package/build/pseudo_url.js +0 -153
- package/build/pseudo_url.js.map +0 -1
- package/build/puppeteer_request_interception.d.ts +0 -8
- package/build/puppeteer_request_interception.d.ts.map +0 -1
- package/build/puppeteer_request_interception.js +0 -235
- package/build/puppeteer_request_interception.js.map +0 -1
- package/build/puppeteer_utils.d.ts +0 -250
- package/build/puppeteer_utils.d.ts.map +0 -1
- package/build/puppeteer_utils.js +0 -551
- package/build/puppeteer_utils.js.map +0 -1
- package/build/request.d.ts +0 -180
- package/build/request.d.ts.map +0 -1
- package/build/request.js +0 -261
- package/build/request.js.map +0 -1
- package/build/request_list.d.ts +0 -581
- package/build/request_list.d.ts.map +0 -1
- package/build/request_list.js +0 -826
- package/build/request_list.js.map +0 -1
- package/build/serialization.d.ts +0 -5
- package/build/serialization.d.ts.map +0 -1
- package/build/serialization.js +0 -139
- package/build/serialization.js.map +0 -1
- package/build/session_pool/errors.d.ts +0 -11
- package/build/session_pool/errors.d.ts.map +0 -1
- package/build/session_pool/errors.js +0 -18
- package/build/session_pool/errors.js.map +0 -1
- package/build/session_pool/events.d.ts +0 -5
- package/build/session_pool/events.d.ts.map +0 -1
- package/build/session_pool/events.js +0 -6
- package/build/session_pool/events.js.map +0 -1
- package/build/session_pool/session.d.ts +0 -286
- package/build/session_pool/session.d.ts.map +0 -1
- package/build/session_pool/session.js +0 -355
- package/build/session_pool/session.js.map +0 -1
- package/build/session_pool/session_pool.d.ts +0 -280
- package/build/session_pool/session_pool.d.ts.map +0 -1
- package/build/session_pool/session_pool.js +0 -393
- package/build/session_pool/session_pool.js.map +0 -1
- package/build/session_pool/session_utils.d.ts +0 -4
- package/build/session_pool/session_utils.d.ts.map +0 -1
- package/build/session_pool/session_utils.js +0 -24
- package/build/session_pool/session_utils.js.map +0 -1
- package/build/stealth/hiding_tricks.d.ts +0 -22
- package/build/stealth/hiding_tricks.d.ts.map +0 -1
- package/build/stealth/hiding_tricks.js +0 -308
- package/build/stealth/hiding_tricks.js.map +0 -1
- package/build/stealth/stealth.d.ts +0 -56
- package/build/stealth/stealth.d.ts.map +0 -1
- package/build/stealth/stealth.js +0 -125
- package/build/stealth/stealth.js.map +0 -1
- package/build/storages/dataset.d.ts +0 -288
- package/build/storages/dataset.d.ts.map +0 -1
- package/build/storages/dataset.js +0 -480
- package/build/storages/dataset.js.map +0 -1
- package/build/storages/key_value_store.d.ts +0 -243
- package/build/storages/key_value_store.d.ts.map +0 -1
- package/build/storages/key_value_store.js +0 -462
- package/build/storages/key_value_store.js.map +0 -1
- package/build/storages/request_queue.d.ts +0 -318
- package/build/storages/request_queue.d.ts.map +0 -1
- package/build/storages/request_queue.js +0 -636
- package/build/storages/request_queue.js.map +0 -1
- package/build/storages/storage_manager.d.ts +0 -87
- package/build/storages/storage_manager.d.ts.map +0 -1
- package/build/storages/storage_manager.js +0 -150
- package/build/storages/storage_manager.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build/typedefs.d.ts +0 -146
- package/build/typedefs.d.ts.map +0 -1
- package/build/typedefs.js +0 -88
- package/build/typedefs.js.map +0 -1
- package/build/utils.d.ts +0 -175
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -731
- package/build/utils.js.map +0 -1
- package/build/utils_log.d.ts +0 -41
- package/build/utils_log.d.ts.map +0 -1
- package/build/utils_log.js +0 -192
- package/build/utils_log.js.map +0 -1
- package/build/utils_request.d.ts +0 -77
- package/build/utils_request.d.ts.map +0 -1
- package/build/utils_request.js +0 -385
- package/build/utils_request.js.map +0 -1
- package/build/utils_social.d.ts +0 -210
- package/build/utils_social.d.ts.map +0 -1
- package/build/utils_social.js +0 -787
- package/build/utils_social.js.map +0 -1
- package/build/validators.d.ts +0 -23
- package/build/validators.d.ts.map +0 -1
- package/build/validators.js +0 -29
- package/build/validators.js.map +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
declare var _default: CacheContainer;
|
|
2
|
-
export default _default;
|
|
3
|
-
/**
|
|
4
|
-
* Used to manage all globally created caches, such as request queue cache
|
|
5
|
-
* or dataset cache. Before creation of this class, those caches were
|
|
6
|
-
* created as module scoped globals - untouchable. This proved problematic
|
|
7
|
-
* especially in tests, where caches would prevent test separation.
|
|
8
|
-
* @property {Object<string, LruCache>} caches
|
|
9
|
-
* @ignore
|
|
10
|
-
*/
|
|
11
|
-
declare class CacheContainer {
|
|
12
|
-
caches: Map<any, any>;
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} name
|
|
15
|
-
* @param {number} maxSize
|
|
16
|
-
* @return {LruCache}
|
|
17
|
-
*/
|
|
18
|
-
openCache(name: string, maxSize: number): LruCache;
|
|
19
|
-
/**
|
|
20
|
-
* @param {string} name
|
|
21
|
-
* @return {?LruCache}
|
|
22
|
-
*/
|
|
23
|
-
getCache(name: string): LruCache | null;
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} name
|
|
26
|
-
*/
|
|
27
|
-
clearCache(name: string): void;
|
|
28
|
-
clearAllCaches(): void;
|
|
29
|
-
}
|
|
30
|
-
import { LruCache } from "@apify/datastructures/lru_cache";
|
|
31
|
-
//# sourceMappingURL=cache_container.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache_container.d.ts","sourceRoot":"","sources":["../src/cache_container.js"],"names":[],"mappings":";;AAEA;;;;;;;GAOG;AACH;IAEQ,sBAAuB;IAG3B;;;;OAIG;IACH,gBAJW,MAAM,WACN,MAAM,GACL,QAAQ,CASnB;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,QAAQ,QAIpB;IAED;;OAEG;IACH,iBAFW,MAAM,QAKhB;IAED,uBAEC;CACJ"}
|
package/build/cache_container.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const datastructures_1 = require("@apify/datastructures");
|
|
4
|
-
/**
|
|
5
|
-
* Used to manage all globally created caches, such as request queue cache
|
|
6
|
-
* or dataset cache. Before creation of this class, those caches were
|
|
7
|
-
* created as module scoped globals - untouchable. This proved problematic
|
|
8
|
-
* especially in tests, where caches would prevent test separation.
|
|
9
|
-
* @property {Object<string, LruCache>} caches
|
|
10
|
-
* @ignore
|
|
11
|
-
*/
|
|
12
|
-
class CacheContainer {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.caches = new Map();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} name
|
|
18
|
-
* @param {number} maxSize
|
|
19
|
-
* @return {LruCache}
|
|
20
|
-
*/
|
|
21
|
-
openCache(name, maxSize) {
|
|
22
|
-
let cache = this.caches.get(name);
|
|
23
|
-
if (!cache) {
|
|
24
|
-
cache = new datastructures_1.LruCache({ maxLength: maxSize });
|
|
25
|
-
this.caches.set(name, cache);
|
|
26
|
-
}
|
|
27
|
-
return cache;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @param {string} name
|
|
31
|
-
* @return {?LruCache}
|
|
32
|
-
*/
|
|
33
|
-
getCache(name) {
|
|
34
|
-
return this.caches.get(name);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @param {string} name
|
|
38
|
-
*/
|
|
39
|
-
clearCache(name) {
|
|
40
|
-
const cache = this.caches.get(name);
|
|
41
|
-
cache.clear();
|
|
42
|
-
}
|
|
43
|
-
clearAllCaches() {
|
|
44
|
-
this.caches.forEach((cache) => cache.clear());
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = new CacheContainer();
|
|
48
|
-
//# sourceMappingURL=cache_container.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache_container.js","sourceRoot":"","sources":["../src/cache_container.js"],"names":[],"mappings":";;AAAA,0DAAiD;AAEjD;;;;;;;GAOG;AACH,MAAM,cAAc;IAChB;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,OAAO;QACnB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE;YACR,KAAK,GAAG,IAAI,yBAAQ,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAChC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAI;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,KAAK,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAED,cAAc;QACV,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAClD,CAAC;CACJ;AAED,kBAAe,IAAI,cAAc,EAAE,CAAC"}
|
package/build/configuration.d.ts
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* `Configuration` is a value object holding the SDK configuration. We can use it in two ways:
|
|
4
|
-
*
|
|
5
|
-
* 1. When using `Apify` class, we can get the instance configuration via `sdk.config`
|
|
6
|
-
* ```js
|
|
7
|
-
* const { Apify } = require('apify');
|
|
8
|
-
*
|
|
9
|
-
* const sdk = new Apify({ token: '123' });
|
|
10
|
-
* console.log(sdk.config.get('token')); // '123'
|
|
11
|
-
* ```
|
|
12
|
-
* 2. To get the global configuration (singleton instance). It will respect the environment variables.
|
|
13
|
-
* ```js
|
|
14
|
-
* console.log(Configuration.getGlobalConfig().get('token')); // returns the token from APIFY_TOKEN env var
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* ## Supported Configuration Options
|
|
18
|
-
*
|
|
19
|
-
* Key | Environment Variable | Default Value
|
|
20
|
-
* ---|---|---
|
|
21
|
-
* `defaultDatasetId` | `APIFY_DEFAULT_DATASET_ID` | `'default'`
|
|
22
|
-
* `defaultKeyValueStoreId` | `APIFY_DEFAULT_KEY_VALUE_STORE_ID` | `'default'`
|
|
23
|
-
* `defaultRequestQueueId` | `APIFY_DEFAULT_REQUEST_QUEUE_ID` | `'default'`
|
|
24
|
-
* `localStorageDir` | `APIFY_LOCAL_STORAGE_DIR` | `'./apify_storage'`
|
|
25
|
-
* `localStorageEnableWalMode` | `APIFY_LOCAL_STORAGE_ENABLE_WAL_MODE` | `true`
|
|
26
|
-
* `persistStateIntervalMillis` | `APIFY_PERSIST_STATE_INTERVAL_MILLIS` | `60e3`
|
|
27
|
-
* `token` | `APIFY_TOKEN` | -
|
|
28
|
-
*
|
|
29
|
-
* ## Advanced Configuration Options
|
|
30
|
-
*
|
|
31
|
-
* Key | Environment Variable | Default Value
|
|
32
|
-
* ---|---|---
|
|
33
|
-
* `actorEventsWsUrl` | `APIFY_ACTOR_EVENTS_WS_URL` | -
|
|
34
|
-
* `actorId` | `APIFY_ACTOR_ID` | -
|
|
35
|
-
* `actorRunId` | `APIFY_ACTOR_RUN_ID` | -
|
|
36
|
-
* `actorTaskId` | `APIFY_ACTOR_TASK_ID` | -
|
|
37
|
-
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com'`
|
|
38
|
-
* `containerPort` | `APIFY_CONTAINER_PORT` | `4321`
|
|
39
|
-
* `containerUrl` | `APIFY_CONTAINER_URL` | `'http://localhost:4321'`
|
|
40
|
-
* `inputKey` | `APIFY_INPUT_KEY` | `'INPUT'`
|
|
41
|
-
* `isAtHome` | `APIFY_IS_AT_HOME` | -
|
|
42
|
-
* `metamorphAfterSleepMillis` | `APIFY_METAMORPH_AFTER_SLEEP_MILLIS` | `300e3`
|
|
43
|
-
* `proxyHostname` | `APIFY_PROXY_HOSTNAME` | `'proxy.apify.com'`
|
|
44
|
-
* `proxyPassword` | `APIFY_PROXY_PASSWORD` | -
|
|
45
|
-
* `proxyPort` | `APIFY_PROXY_PORT` | `8000`
|
|
46
|
-
* `proxyStatusUrl` | `APIFY_PROXY_STATUS_URL` | `'http://proxy.apify.com'`
|
|
47
|
-
* `userId` | `APIFY_USER_ID` | -
|
|
48
|
-
*
|
|
49
|
-
* ## Not Supported environment variables
|
|
50
|
-
*
|
|
51
|
-
* - `MEMORY_MBYTES`
|
|
52
|
-
* - `HEADLESS`
|
|
53
|
-
* - `XVFB`
|
|
54
|
-
* - `CHROME_EXECUTABLE_PATH`
|
|
55
|
-
*/
|
|
56
|
-
export class Configuration {
|
|
57
|
-
static ENV_MAP: {
|
|
58
|
-
APIFY_TOKEN: string;
|
|
59
|
-
APIFY_LOCAL_STORAGE_DIR: string;
|
|
60
|
-
APIFY_LOCAL_STORAGE_ENABLE_WAL_MODE: string;
|
|
61
|
-
APIFY_DEFAULT_DATASET_ID: string;
|
|
62
|
-
APIFY_DEFAULT_KEY_VALUE_STORE_ID: string;
|
|
63
|
-
APIFY_DEFAULT_REQUEST_QUEUE_ID: string;
|
|
64
|
-
APIFY_METAMORPH_AFTER_SLEEP_MILLIS: string;
|
|
65
|
-
APIFY_PERSIST_STATE_INTERVAL_MILLIS: string;
|
|
66
|
-
APIFY_TEST_PERSIST_INTERVAL_MILLIS: string;
|
|
67
|
-
APIFY_ACTOR_EVENTS_WS_URL: string;
|
|
68
|
-
APIFY_INPUT_KEY: string;
|
|
69
|
-
APIFY_ACTOR_ID: string;
|
|
70
|
-
APIFY_API_BASE_URL: string;
|
|
71
|
-
APIFY_IS_AT_HOME: string;
|
|
72
|
-
APIFY_ACTOR_RUN_ID: string;
|
|
73
|
-
APIFY_ACTOR_TASK_ID: string;
|
|
74
|
-
APIFY_CONTAINER_PORT: string;
|
|
75
|
-
APIFY_CONTAINER_URL: string;
|
|
76
|
-
APIFY_USER_ID: string;
|
|
77
|
-
APIFY_PROXY_HOSTNAME: string;
|
|
78
|
-
APIFY_PROXY_PASSWORD: string;
|
|
79
|
-
APIFY_PROXY_STATUS_URL: string;
|
|
80
|
-
APIFY_PROXY_PORT: string;
|
|
81
|
-
};
|
|
82
|
-
static ENV_MAP_REVERSED: {};
|
|
83
|
-
static BOOLEAN_VARS: string[];
|
|
84
|
-
static INTEGER_VARS: string[];
|
|
85
|
-
static DEFAULTS: {
|
|
86
|
-
defaultKeyValueStoreId: string;
|
|
87
|
-
defaultDatasetId: string;
|
|
88
|
-
defaultRequestQueueId: string;
|
|
89
|
-
inputKey: string;
|
|
90
|
-
apiBaseUrl: string;
|
|
91
|
-
proxyStatusUrl: string;
|
|
92
|
-
proxyHostname: string;
|
|
93
|
-
proxyPort: number;
|
|
94
|
-
containerPort: number;
|
|
95
|
-
containerUrl: string;
|
|
96
|
-
metamorphAfterSleepMillis: number;
|
|
97
|
-
persistStateIntervalMillis: number;
|
|
98
|
-
localStorageEnableWalMode: boolean;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Provides access to the current-instance-scoped Configuration without passing it around in parameters.
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
static storage: AsyncLocalStorage<any>;
|
|
105
|
-
/**
|
|
106
|
-
* Returns the global configuration instance. It will respect the environment variables.
|
|
107
|
-
* When used inside SDK instance (`sdk.main()`), the return value is equal to `sdk.config`.
|
|
108
|
-
*
|
|
109
|
-
* @return {Configuration}
|
|
110
|
-
*/
|
|
111
|
-
static getGlobalConfig(): Configuration;
|
|
112
|
-
/**
|
|
113
|
-
* Creates new `Configuration` instance with provided options. Env vars will have precedence over those.
|
|
114
|
-
*
|
|
115
|
-
* @param {Record<string, number | string | boolean>} options
|
|
116
|
-
*/
|
|
117
|
-
constructor(options?: Record<string, number | string | boolean>);
|
|
118
|
-
options: Map<string, string | number | boolean>;
|
|
119
|
-
services: Map<any, any>;
|
|
120
|
-
/**
|
|
121
|
-
* Returns configured value. First checks the environment variables, then provided configuration,
|
|
122
|
-
* fallbacks to the `defaultValue` argument if provided, otherwise uses the default value as described
|
|
123
|
-
* in the above section.
|
|
124
|
-
*
|
|
125
|
-
* @param {string} key
|
|
126
|
-
* @param {string | number | boolean} [defaultValue]
|
|
127
|
-
* @return {string | number | boolean}
|
|
128
|
-
*/
|
|
129
|
-
get(key: string, defaultValue?: string | number | boolean | undefined): string | number | boolean;
|
|
130
|
-
/**
|
|
131
|
-
* @param {string} key
|
|
132
|
-
* @param {number | string | boolean} value
|
|
133
|
-
* @return {boolean}
|
|
134
|
-
* @private
|
|
135
|
-
*/
|
|
136
|
-
private _castEnvValue;
|
|
137
|
-
/**
|
|
138
|
-
* Sets value for given option. Only affects this `Configuration` instance, the value will not be propagated down to the env var.
|
|
139
|
-
* To reset a value, we can omit the `value` argument or pass `undefined` there.
|
|
140
|
-
*
|
|
141
|
-
* @param {string} key
|
|
142
|
-
* @param {string | number | boolean} [value]
|
|
143
|
-
*/
|
|
144
|
-
set(key: string, value?: string | number | boolean | undefined): void;
|
|
145
|
-
/**
|
|
146
|
-
* Returns cached instance of {@link ApifyClient} using options as defined in the environment variables or in
|
|
147
|
-
* this {@link Configuration} instance. Only first call of this method will create the client, following calls will
|
|
148
|
-
* return the same client instance.
|
|
149
|
-
*
|
|
150
|
-
* Caching works based on the API URL and token, so calling this method with different options will return
|
|
151
|
-
* multiple instances, one for each variant of the options.
|
|
152
|
-
*
|
|
153
|
-
* @param {object} [options]
|
|
154
|
-
* @param {string} [options.token]
|
|
155
|
-
* @param {string} [options.maxRetries]
|
|
156
|
-
* @param {string} [options.minDelayBetweenRetriesMillis]
|
|
157
|
-
* @return {ApifyClient}
|
|
158
|
-
* @internal
|
|
159
|
-
*/
|
|
160
|
-
getClient(options?: {
|
|
161
|
-
token?: string | undefined;
|
|
162
|
-
maxRetries?: string | undefined;
|
|
163
|
-
minDelayBetweenRetriesMillis?: string | undefined;
|
|
164
|
-
} | undefined): ApifyClient;
|
|
165
|
-
/**
|
|
166
|
-
* Returns cached instance of {@link ApifyStorageLocal} using options as defined in the environment variables or in
|
|
167
|
-
* this {@link Configuration} instance. Only first call of this method will create the client, following calls will return
|
|
168
|
-
* the same client instance.
|
|
169
|
-
*
|
|
170
|
-
* Caching works based on the `storageDir` option, so calling this method with different `storageDir` will return
|
|
171
|
-
* multiple instances, one for each directory.
|
|
172
|
-
*
|
|
173
|
-
* @param {object} [options]
|
|
174
|
-
* @param {string} [options.storageDir]
|
|
175
|
-
* @param {boolean} [options.enableWalMode=true]
|
|
176
|
-
* @return {ApifyStorageLocal}
|
|
177
|
-
* @internal
|
|
178
|
-
*/
|
|
179
|
-
getStorageLocal(options?: {
|
|
180
|
-
storageDir?: string | undefined;
|
|
181
|
-
enableWalMode?: boolean | undefined;
|
|
182
|
-
} | undefined): ApifyStorageLocal;
|
|
183
|
-
/**
|
|
184
|
-
* Returns cached (singleton) instance of a service by its name. If the service does not exist yet, it will be created
|
|
185
|
-
* via the `createCallback`. To have multiple instances of one service, we can use unique values in the `cacheKey`.
|
|
186
|
-
*
|
|
187
|
-
* @param {string} name
|
|
188
|
-
* @param {Function} createCallback
|
|
189
|
-
* @param {string} [cacheKey]
|
|
190
|
-
* @return {unknown}
|
|
191
|
-
* @private
|
|
192
|
-
*/
|
|
193
|
-
private _getService;
|
|
194
|
-
/**
|
|
195
|
-
* Creates an instance of ApifyClient using options as defined in the environment variables or in this `Configuration` instance.
|
|
196
|
-
*
|
|
197
|
-
* @param {object} [options]
|
|
198
|
-
* @param {string} [options.token]
|
|
199
|
-
* @param {string} [options.maxRetries]
|
|
200
|
-
* @param {string} [options.minDelayBetweenRetriesMillis]
|
|
201
|
-
* @return {ApifyClient}
|
|
202
|
-
* @internal
|
|
203
|
-
*/
|
|
204
|
-
createClient(options?: {
|
|
205
|
-
token?: string | undefined;
|
|
206
|
-
maxRetries?: string | undefined;
|
|
207
|
-
minDelayBetweenRetriesMillis?: string | undefined;
|
|
208
|
-
} | undefined): ApifyClient;
|
|
209
|
-
/**
|
|
210
|
-
* Creates an instance of ApifyStorageLocal using options as defined in the environment variables or in this `Configuration` instance.
|
|
211
|
-
*
|
|
212
|
-
* @param {object} [options]
|
|
213
|
-
* @param {string} [options.storageDir]
|
|
214
|
-
* @param {boolean} [options.enableWalMode=true]
|
|
215
|
-
* @return {ApifyStorageLocal}
|
|
216
|
-
* @internal
|
|
217
|
-
*/
|
|
218
|
-
createStorageLocal(options?: {
|
|
219
|
-
storageDir?: string | undefined;
|
|
220
|
-
enableWalMode?: boolean | undefined;
|
|
221
|
-
} | undefined): ApifyStorageLocal;
|
|
222
|
-
}
|
|
223
|
-
import { ApifyClient } from "apify-client/dist/apify_client";
|
|
224
|
-
import { ApifyStorageLocal } from "@apify/storage-local";
|
|
225
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
226
|
-
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.js"],"names":[],"mappings":";AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH;IAEI;;;;;;;;;;;;;;;;;;;;;;;;MA8BE;IAGF,4BAGO;IAEP,8BAAoD;IAEpD,8BAAqE;IAErE;;;;;;;;;;;;;;MAcE;IAEF;;;OAGG;IACH,uCAAyC;IAmLzC;;;;;OAKG;IACH,0BAFY,aAAa,CAOxB;IA5LD;;;;OAIG;IACH,sBAFW,OAAO,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAYnD;IATG,gDAA+C;IAC/C,wBAAyB;IAU7B;;;;;;;;OAQG;IACH,SAJW,MAAM,yDAEL,MAAM,GAAG,MAAM,GAAG,OAAO,CAkBpC;IAED;;;;;OAKG;IACH,sBAWC;IAED;;;;;;OAMG;IACH,SAHW,MAAM,uDAKhB;IAED;;;;;;;;;;;;;;OAcG;IACH;;;;oBAHY,WAAW,CAStB;IAED;;;;;;;;;;;;;OAaG;IACH;;;oBAHY,iBAAiB,CAM5B;IAED;;;;;;;;;OASG;IACH,oBAQC;IAED;;;;;;;;;OASG;IACH;;;;oBAHY,WAAW,CAStB;IAED;;;;;;;;OAQG;IACH;;;oBAHY,iBAAiB,CAe5B;CAcJ"}
|
package/build/configuration.js
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Configuration = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const consts_1 = require("@apify/consts");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const storage_local_1 = require("@apify/storage-local");
|
|
8
|
-
const apify_client_1 = require("apify-client");
|
|
9
|
-
const async_hooks_1 = require("async_hooks");
|
|
10
|
-
const utils_log_1 = (0, tslib_1.__importDefault)(require("./utils_log"));
|
|
11
|
-
/**
|
|
12
|
-
* `Configuration` is a value object holding the SDK configuration. We can use it in two ways:
|
|
13
|
-
*
|
|
14
|
-
* 1. When using `Apify` class, we can get the instance configuration via `sdk.config`
|
|
15
|
-
* ```js
|
|
16
|
-
* const { Apify } = require('apify');
|
|
17
|
-
*
|
|
18
|
-
* const sdk = new Apify({ token: '123' });
|
|
19
|
-
* console.log(sdk.config.get('token')); // '123'
|
|
20
|
-
* ```
|
|
21
|
-
* 2. To get the global configuration (singleton instance). It will respect the environment variables.
|
|
22
|
-
* ```js
|
|
23
|
-
* console.log(Configuration.getGlobalConfig().get('token')); // returns the token from APIFY_TOKEN env var
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ## Supported Configuration Options
|
|
27
|
-
*
|
|
28
|
-
* Key | Environment Variable | Default Value
|
|
29
|
-
* ---|---|---
|
|
30
|
-
* `defaultDatasetId` | `APIFY_DEFAULT_DATASET_ID` | `'default'`
|
|
31
|
-
* `defaultKeyValueStoreId` | `APIFY_DEFAULT_KEY_VALUE_STORE_ID` | `'default'`
|
|
32
|
-
* `defaultRequestQueueId` | `APIFY_DEFAULT_REQUEST_QUEUE_ID` | `'default'`
|
|
33
|
-
* `localStorageDir` | `APIFY_LOCAL_STORAGE_DIR` | `'./apify_storage'`
|
|
34
|
-
* `localStorageEnableWalMode` | `APIFY_LOCAL_STORAGE_ENABLE_WAL_MODE` | `true`
|
|
35
|
-
* `persistStateIntervalMillis` | `APIFY_PERSIST_STATE_INTERVAL_MILLIS` | `60e3`
|
|
36
|
-
* `token` | `APIFY_TOKEN` | -
|
|
37
|
-
*
|
|
38
|
-
* ## Advanced Configuration Options
|
|
39
|
-
*
|
|
40
|
-
* Key | Environment Variable | Default Value
|
|
41
|
-
* ---|---|---
|
|
42
|
-
* `actorEventsWsUrl` | `APIFY_ACTOR_EVENTS_WS_URL` | -
|
|
43
|
-
* `actorId` | `APIFY_ACTOR_ID` | -
|
|
44
|
-
* `actorRunId` | `APIFY_ACTOR_RUN_ID` | -
|
|
45
|
-
* `actorTaskId` | `APIFY_ACTOR_TASK_ID` | -
|
|
46
|
-
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com'`
|
|
47
|
-
* `containerPort` | `APIFY_CONTAINER_PORT` | `4321`
|
|
48
|
-
* `containerUrl` | `APIFY_CONTAINER_URL` | `'http://localhost:4321'`
|
|
49
|
-
* `inputKey` | `APIFY_INPUT_KEY` | `'INPUT'`
|
|
50
|
-
* `isAtHome` | `APIFY_IS_AT_HOME` | -
|
|
51
|
-
* `metamorphAfterSleepMillis` | `APIFY_METAMORPH_AFTER_SLEEP_MILLIS` | `300e3`
|
|
52
|
-
* `proxyHostname` | `APIFY_PROXY_HOSTNAME` | `'proxy.apify.com'`
|
|
53
|
-
* `proxyPassword` | `APIFY_PROXY_PASSWORD` | -
|
|
54
|
-
* `proxyPort` | `APIFY_PROXY_PORT` | `8000`
|
|
55
|
-
* `proxyStatusUrl` | `APIFY_PROXY_STATUS_URL` | `'http://proxy.apify.com'`
|
|
56
|
-
* `userId` | `APIFY_USER_ID` | -
|
|
57
|
-
*
|
|
58
|
-
* ## Not Supported environment variables
|
|
59
|
-
*
|
|
60
|
-
* - `MEMORY_MBYTES`
|
|
61
|
-
* - `HEADLESS`
|
|
62
|
-
* - `XVFB`
|
|
63
|
-
* - `CHROME_EXECUTABLE_PATH`
|
|
64
|
-
*/
|
|
65
|
-
class Configuration {
|
|
66
|
-
/**
|
|
67
|
-
* Creates new `Configuration` instance with provided options. Env vars will have precedence over those.
|
|
68
|
-
*
|
|
69
|
-
* @param {Record<string, number | string | boolean>} options
|
|
70
|
-
*/
|
|
71
|
-
constructor(options = {}) {
|
|
72
|
-
this.options = new Map(Object.entries(options));
|
|
73
|
-
this.services = new Map();
|
|
74
|
-
if (!this.get('localStorageDir') && !this.get('token')) {
|
|
75
|
-
const dir = (0, path_1.join)(process.cwd(), './apify_storage');
|
|
76
|
-
this.set('localStorageDir', dir);
|
|
77
|
-
// eslint-disable-next-line max-len
|
|
78
|
-
utils_log_1.default.warning(`Neither ${consts_1.ENV_VARS.LOCAL_STORAGE_DIR} nor ${consts_1.ENV_VARS.TOKEN} environment variable is set, defaulting to ${consts_1.ENV_VARS.LOCAL_STORAGE_DIR}="${dir}"`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Returns configured value. First checks the environment variables, then provided configuration,
|
|
83
|
-
* fallbacks to the `defaultValue` argument if provided, otherwise uses the default value as described
|
|
84
|
-
* in the above section.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} key
|
|
87
|
-
* @param {string | number | boolean} [defaultValue]
|
|
88
|
-
* @return {string | number | boolean}
|
|
89
|
-
*/
|
|
90
|
-
get(key, defaultValue) {
|
|
91
|
-
// prefer env vars
|
|
92
|
-
const envKey = Configuration.ENV_MAP_REVERSED[key] ?? key;
|
|
93
|
-
const envValue = process.env[envKey];
|
|
94
|
-
if (envValue != null) {
|
|
95
|
-
return this._castEnvValue(key, envValue);
|
|
96
|
-
}
|
|
97
|
-
// check instance level options
|
|
98
|
-
if (this.options.has(key)) {
|
|
99
|
-
return this.options.get(key);
|
|
100
|
-
}
|
|
101
|
-
// fallback to defaults
|
|
102
|
-
return defaultValue ?? Configuration.DEFAULTS[key] ?? envValue;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* @param {string} key
|
|
106
|
-
* @param {number | string | boolean} value
|
|
107
|
-
* @return {boolean}
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
110
|
-
_castEnvValue(key, value) {
|
|
111
|
-
if (Configuration.INTEGER_VARS.includes(key)) {
|
|
112
|
-
return +value;
|
|
113
|
-
}
|
|
114
|
-
if (Configuration.BOOLEAN_VARS.includes(key)) {
|
|
115
|
-
// 0, false and empty string are considered falsy values
|
|
116
|
-
return !['0', 'false', ''].includes(value.toLowerCase());
|
|
117
|
-
}
|
|
118
|
-
return value;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Sets value for given option. Only affects this `Configuration` instance, the value will not be propagated down to the env var.
|
|
122
|
-
* To reset a value, we can omit the `value` argument or pass `undefined` there.
|
|
123
|
-
*
|
|
124
|
-
* @param {string} key
|
|
125
|
-
* @param {string | number | boolean} [value]
|
|
126
|
-
*/
|
|
127
|
-
set(key, value) {
|
|
128
|
-
this.options.set(key, value);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Returns cached instance of {@link ApifyClient} using options as defined in the environment variables or in
|
|
132
|
-
* this {@link Configuration} instance. Only first call of this method will create the client, following calls will
|
|
133
|
-
* return the same client instance.
|
|
134
|
-
*
|
|
135
|
-
* Caching works based on the API URL and token, so calling this method with different options will return
|
|
136
|
-
* multiple instances, one for each variant of the options.
|
|
137
|
-
*
|
|
138
|
-
* @param {object} [options]
|
|
139
|
-
* @param {string} [options.token]
|
|
140
|
-
* @param {string} [options.maxRetries]
|
|
141
|
-
* @param {string} [options.minDelayBetweenRetriesMillis]
|
|
142
|
-
* @return {ApifyClient}
|
|
143
|
-
* @internal
|
|
144
|
-
*/
|
|
145
|
-
getClient(options = {}) {
|
|
146
|
-
const baseUrl = options.baseUrl ?? this.get('apiBaseUrl');
|
|
147
|
-
const token = options.token ?? this.get('token');
|
|
148
|
-
const cacheKey = `${baseUrl}~${token}`;
|
|
149
|
-
return this._getService('ApifyClient', () => this.createClient(options), cacheKey);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Returns cached instance of {@link ApifyStorageLocal} using options as defined in the environment variables or in
|
|
153
|
-
* this {@link Configuration} instance. Only first call of this method will create the client, following calls will return
|
|
154
|
-
* the same client instance.
|
|
155
|
-
*
|
|
156
|
-
* Caching works based on the `storageDir` option, so calling this method with different `storageDir` will return
|
|
157
|
-
* multiple instances, one for each directory.
|
|
158
|
-
*
|
|
159
|
-
* @param {object} [options]
|
|
160
|
-
* @param {string} [options.storageDir]
|
|
161
|
-
* @param {boolean} [options.enableWalMode=true]
|
|
162
|
-
* @return {ApifyStorageLocal}
|
|
163
|
-
* @internal
|
|
164
|
-
*/
|
|
165
|
-
getStorageLocal(options = {}) {
|
|
166
|
-
const cacheKey = options.storageDir ?? this.get('localStorageDir');
|
|
167
|
-
return this._getService('ApifyStorageLocal', () => this.createStorageLocal(options), cacheKey);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Returns cached (singleton) instance of a service by its name. If the service does not exist yet, it will be created
|
|
171
|
-
* via the `createCallback`. To have multiple instances of one service, we can use unique values in the `cacheKey`.
|
|
172
|
-
*
|
|
173
|
-
* @param {string} name
|
|
174
|
-
* @param {Function} createCallback
|
|
175
|
-
* @param {string} [cacheKey]
|
|
176
|
-
* @return {unknown}
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
_getService(name, createCallback, cacheKey = name) {
|
|
180
|
-
cacheKey = `${name}~${cacheKey}`;
|
|
181
|
-
if (!this.services.has(cacheKey)) {
|
|
182
|
-
this.services.set(cacheKey, createCallback());
|
|
183
|
-
}
|
|
184
|
-
return this.services.get(cacheKey);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Creates an instance of ApifyClient using options as defined in the environment variables or in this `Configuration` instance.
|
|
188
|
-
*
|
|
189
|
-
* @param {object} [options]
|
|
190
|
-
* @param {string} [options.token]
|
|
191
|
-
* @param {string} [options.maxRetries]
|
|
192
|
-
* @param {string} [options.minDelayBetweenRetriesMillis]
|
|
193
|
-
* @return {ApifyClient}
|
|
194
|
-
* @internal
|
|
195
|
-
*/
|
|
196
|
-
createClient(options = {}) {
|
|
197
|
-
return new apify_client_1.ApifyClient({
|
|
198
|
-
baseUrl: this.get('apiBaseUrl'),
|
|
199
|
-
token: this.get('token'),
|
|
200
|
-
...options, // allow overriding the instance configuration
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Creates an instance of ApifyStorageLocal using options as defined in the environment variables or in this `Configuration` instance.
|
|
205
|
-
*
|
|
206
|
-
* @param {object} [options]
|
|
207
|
-
* @param {string} [options.storageDir]
|
|
208
|
-
* @param {boolean} [options.enableWalMode=true]
|
|
209
|
-
* @return {ApifyStorageLocal}
|
|
210
|
-
* @internal
|
|
211
|
-
*/
|
|
212
|
-
createStorageLocal(options = {}) {
|
|
213
|
-
const storageDir = options.storageDir ?? this.get('localStorageDir');
|
|
214
|
-
const enableWalMode = options.enableWalMode ?? this.get('localStorageEnableWalMode');
|
|
215
|
-
const storage = new storage_local_1.ApifyStorageLocal({ ...options, storageDir, enableWalMode });
|
|
216
|
-
process.on('exit', () => {
|
|
217
|
-
// TODO this is not public API, need to update
|
|
218
|
-
// storage local with some teardown
|
|
219
|
-
storage.dbConnections.closeAllConnections();
|
|
220
|
-
});
|
|
221
|
-
return storage;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Returns the global configuration instance. It will respect the environment variables.
|
|
225
|
-
* When used inside SDK instance (`sdk.main()`), the return value is equal to `sdk.config`.
|
|
226
|
-
*
|
|
227
|
-
* @return {Configuration}
|
|
228
|
-
*/
|
|
229
|
-
static getGlobalConfig() {
|
|
230
|
-
return Configuration.storage.getStore() ?? (() => {
|
|
231
|
-
Configuration.globalConfig ?? (Configuration.globalConfig = new Configuration());
|
|
232
|
-
return Configuration.globalConfig;
|
|
233
|
-
})();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
exports.Configuration = Configuration;
|
|
237
|
-
// maps environment variables to config keys (e.g. `APIFY_PROXY_PORT` to `proxyPort`)
|
|
238
|
-
Object.defineProperty(Configuration, "ENV_MAP", {
|
|
239
|
-
enumerable: true,
|
|
240
|
-
configurable: true,
|
|
241
|
-
writable: true,
|
|
242
|
-
value: {
|
|
243
|
-
APIFY_TOKEN: 'token',
|
|
244
|
-
APIFY_LOCAL_STORAGE_DIR: 'localStorageDir',
|
|
245
|
-
APIFY_LOCAL_STORAGE_ENABLE_WAL_MODE: 'localStorageEnableWalMode',
|
|
246
|
-
APIFY_DEFAULT_DATASET_ID: 'defaultDatasetId',
|
|
247
|
-
APIFY_DEFAULT_KEY_VALUE_STORE_ID: 'defaultKeyValueStoreId',
|
|
248
|
-
APIFY_DEFAULT_REQUEST_QUEUE_ID: 'defaultRequestQueueId',
|
|
249
|
-
APIFY_METAMORPH_AFTER_SLEEP_MILLIS: 'metamorphAfterSleepMillis',
|
|
250
|
-
APIFY_PERSIST_STATE_INTERVAL_MILLIS: 'persistStateIntervalMillis',
|
|
251
|
-
APIFY_TEST_PERSIST_INTERVAL_MILLIS: 'persistStateIntervalMillis',
|
|
252
|
-
APIFY_ACTOR_EVENTS_WS_URL: 'actorEventsWsUrl',
|
|
253
|
-
APIFY_INPUT_KEY: 'inputKey',
|
|
254
|
-
APIFY_ACTOR_ID: 'actorId',
|
|
255
|
-
APIFY_API_BASE_URL: 'apiBaseUrl',
|
|
256
|
-
APIFY_IS_AT_HOME: 'isAtHome',
|
|
257
|
-
APIFY_ACTOR_RUN_ID: 'actorRunId',
|
|
258
|
-
APIFY_ACTOR_TASK_ID: 'actorTaskId',
|
|
259
|
-
APIFY_CONTAINER_PORT: 'containerPort',
|
|
260
|
-
APIFY_CONTAINER_URL: 'containerUrl',
|
|
261
|
-
APIFY_USER_ID: 'userId',
|
|
262
|
-
APIFY_PROXY_HOSTNAME: 'proxyHostname',
|
|
263
|
-
APIFY_PROXY_PASSWORD: 'proxyPassword',
|
|
264
|
-
APIFY_PROXY_STATUS_URL: 'proxyStatusUrl',
|
|
265
|
-
APIFY_PROXY_PORT: 'proxyPort',
|
|
266
|
-
// not supported, use env vars directly:
|
|
267
|
-
// APIFY_MEMORY_MBYTES: 'memoryMbytes',
|
|
268
|
-
// APIFY_HEADLESS: 'headless',
|
|
269
|
-
// APIFY_XVFB: 'xvfb',
|
|
270
|
-
// APIFY_CHROME_EXECUTABLE_PATH: 'chromeExecutablePath',
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
// maps config keys to environment variables (e.g. `proxyPort` to `APIFY_PROXY_PORT`)
|
|
274
|
-
Object.defineProperty(Configuration, "ENV_MAP_REVERSED", {
|
|
275
|
-
enumerable: true,
|
|
276
|
-
configurable: true,
|
|
277
|
-
writable: true,
|
|
278
|
-
value: Object.entries(Configuration.ENV_MAP).reduce((obj, [key, value]) => {
|
|
279
|
-
obj[value] = key;
|
|
280
|
-
return obj;
|
|
281
|
-
}, {})
|
|
282
|
-
});
|
|
283
|
-
Object.defineProperty(Configuration, "BOOLEAN_VARS", {
|
|
284
|
-
enumerable: true,
|
|
285
|
-
configurable: true,
|
|
286
|
-
writable: true,
|
|
287
|
-
value: ['localStorageEnableWalMode']
|
|
288
|
-
});
|
|
289
|
-
Object.defineProperty(Configuration, "INTEGER_VARS", {
|
|
290
|
-
enumerable: true,
|
|
291
|
-
configurable: true,
|
|
292
|
-
writable: true,
|
|
293
|
-
value: ['proxyPort', 'memoryMbytes', 'containerPort']
|
|
294
|
-
});
|
|
295
|
-
Object.defineProperty(Configuration, "DEFAULTS", {
|
|
296
|
-
enumerable: true,
|
|
297
|
-
configurable: true,
|
|
298
|
-
writable: true,
|
|
299
|
-
value: {
|
|
300
|
-
defaultKeyValueStoreId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID],
|
|
301
|
-
defaultDatasetId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_DATASET_ID],
|
|
302
|
-
defaultRequestQueueId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_REQUEST_QUEUE_ID],
|
|
303
|
-
inputKey: 'INPUT',
|
|
304
|
-
apiBaseUrl: 'https://api.apify.com',
|
|
305
|
-
proxyStatusUrl: 'http://proxy.apify.com',
|
|
306
|
-
proxyHostname: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.PROXY_HOSTNAME],
|
|
307
|
-
proxyPort: +consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.PROXY_PORT],
|
|
308
|
-
containerPort: +consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.CONTAINER_PORT],
|
|
309
|
-
containerUrl: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.CONTAINER_URL],
|
|
310
|
-
metamorphAfterSleepMillis: 300e3,
|
|
311
|
-
persistStateIntervalMillis: 60e3,
|
|
312
|
-
localStorageEnableWalMode: true,
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
/**
|
|
316
|
-
* Provides access to the current-instance-scoped Configuration without passing it around in parameters.
|
|
317
|
-
* @internal
|
|
318
|
-
*/
|
|
319
|
-
Object.defineProperty(Configuration, "storage", {
|
|
320
|
-
enumerable: true,
|
|
321
|
-
configurable: true,
|
|
322
|
-
writable: true,
|
|
323
|
-
value: new async_hooks_1.AsyncLocalStorage()
|
|
324
|
-
});
|
|
325
|
-
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.js"],"names":[],"mappings":";;;;AAAA,0CAAyD;AACzD,+BAA4B;AAC5B,wDAAyD;AACzD,+CAA2C;AAC3C,6CAAgD;AAChD,yEAA8B;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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