apify 3.0.0-beta.9 → 3.0.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 +8 -12
- package/actor.d.ts +136 -138
- package/actor.d.ts.map +1 -1
- package/actor.js +162 -164
- package/actor.js.map +1 -1
- package/configuration.d.ts +168 -0
- package/configuration.d.ts.map +1 -0
- package/configuration.js +184 -0
- package/configuration.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/index.mjs +4 -0
- package/key_value_store.d.ts +17 -0
- package/key_value_store.d.ts.map +1 -0
- package/key_value_store.js +26 -0
- package/key_value_store.js.map +1 -0
- package/package.json +22 -17
- package/platform_event_manager.d.ts +3 -0
- package/platform_event_manager.d.ts.map +1 -1
- package/platform_event_manager.js +11 -4
- package/platform_event_manager.js.map +1 -1
- package/proxy_configuration.d.ts +9 -6
- package/proxy_configuration.d.ts.map +1 -1
- package/proxy_configuration.js +13 -7
- package/proxy_configuration.js.map +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils.js +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Configuration as CoreConfiguration } from '@crawlee/core';
|
|
2
|
+
import type { ConfigurationOptions as CoreConfigurationOptions } from '@crawlee/core';
|
|
3
|
+
export interface ConfigurationOptions extends CoreConfigurationOptions {
|
|
4
|
+
metamorphAfterSleepMillis?: number;
|
|
5
|
+
actorEventsWsUrl?: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
actorId?: string;
|
|
8
|
+
actorRunId?: string;
|
|
9
|
+
actorTaskId?: string;
|
|
10
|
+
apiBaseUrl?: string;
|
|
11
|
+
containerPort?: number;
|
|
12
|
+
containerUrl?: string;
|
|
13
|
+
proxyHostname?: string;
|
|
14
|
+
proxyPassword?: string;
|
|
15
|
+
proxyPort?: number;
|
|
16
|
+
proxyStatusUrl?: string;
|
|
17
|
+
isAtHome?: boolean;
|
|
18
|
+
userId?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `Configuration` is a value object holding the SDK configuration. We can use it in two ways:
|
|
22
|
+
*
|
|
23
|
+
* 1. When using `Actor` class, we can get the instance configuration via `sdk.config`
|
|
24
|
+
*
|
|
25
|
+
* ```javascript
|
|
26
|
+
* import { Actor } from 'apify';
|
|
27
|
+
* import { BasicCrawler } from 'crawlee';
|
|
28
|
+
*
|
|
29
|
+
* const sdk = new Actor({ token: '123' });
|
|
30
|
+
* console.log(sdk.config.get('token')); // '123'
|
|
31
|
+
*
|
|
32
|
+
* const crawler = new BasicCrawler({
|
|
33
|
+
* // ... crawler options
|
|
34
|
+
* }, sdk.config);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* 2. To get the global configuration (singleton instance). It will respect the environment variables.
|
|
38
|
+
*
|
|
39
|
+
* ```javascript
|
|
40
|
+
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
41
|
+
*
|
|
42
|
+
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
43
|
+
* const crawler = new BasicCrawler({ ... }, config);
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* ## Supported Configuration Options
|
|
47
|
+
*
|
|
48
|
+
* Key | Environment Variable | Default Value
|
|
49
|
+
* ---|---|---
|
|
50
|
+
* `memoryMbytes` | `APIFY_MEMORY_MBYTES` | -
|
|
51
|
+
* `headless` | `APIFY_HEADLESS` | -
|
|
52
|
+
* `persistStateIntervalMillis` | `APIFY_PERSIST_STATE_INTERVAL_MILLIS` | `60e3`
|
|
53
|
+
* `token` | `APIFY_TOKEN` | -
|
|
54
|
+
* `isAtHome` | `APIFY_IS_AT_HOME` | -
|
|
55
|
+
* `defaultDatasetId` | `APIFY_DEFAULT_DATASET_ID` | `'default'`
|
|
56
|
+
* `defaultKeyValueStoreId` | `APIFY_DEFAULT_KEY_VALUE_STORE_ID` | `'default'`
|
|
57
|
+
* `defaultRequestQueueId` | `APIFY_DEFAULT_REQUEST_QUEUE_ID` | `'default'`
|
|
58
|
+
*
|
|
59
|
+
* ## Advanced Configuration Options
|
|
60
|
+
*
|
|
61
|
+
* Key | Environment Variable | Default Value
|
|
62
|
+
* ---|---|---
|
|
63
|
+
* `actorEventsWsUrl` | `APIFY_ACTOR_EVENTS_WS_URL` | -
|
|
64
|
+
* `actorId` | `APIFY_ACTOR_ID` | -
|
|
65
|
+
* `actorRunId` | `APIFY_ACTOR_RUN_ID` | -
|
|
66
|
+
* `actorTaskId` | `APIFY_ACTOR_TASK_ID` | -
|
|
67
|
+
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com'`
|
|
68
|
+
* `containerPort` | `APIFY_CONTAINER_PORT` | `4321`
|
|
69
|
+
* `containerUrl` | `APIFY_CONTAINER_URL` | `'http://localhost:4321'`
|
|
70
|
+
* `inputKey` | `APIFY_INPUT_KEY` | `'INPUT'`
|
|
71
|
+
* `metamorphAfterSleepMillis` | `APIFY_METAMORPH_AFTER_SLEEP_MILLIS` | `300e3`
|
|
72
|
+
* `proxyHostname` | `APIFY_PROXY_HOSTNAME` | `'proxy.apify.com'`
|
|
73
|
+
* `proxyPassword` | `APIFY_PROXY_PASSWORD` | -
|
|
74
|
+
* `proxyPort` | `APIFY_PROXY_PORT` | `8000`
|
|
75
|
+
* `proxyStatusUrl` | `APIFY_PROXY_STATUS_URL` | `'http://proxy.apify.com'`
|
|
76
|
+
* `userId` | `APIFY_USER_ID` | -
|
|
77
|
+
* `xvfb` | `APIFY_XVFB` | -
|
|
78
|
+
* `chromeExecutablePath` | `APIFY_CHROME_EXECUTABLE_PATH` | -
|
|
79
|
+
* `defaultBrowserPath` | `APIFY_DEFAULT_BROWSER_PATH` | -
|
|
80
|
+
*/
|
|
81
|
+
export declare class Configuration extends CoreConfiguration {
|
|
82
|
+
/** @inheritDoc */
|
|
83
|
+
static globalConfig?: Configuration;
|
|
84
|
+
protected static ENV_MAP: {
|
|
85
|
+
APIFY_AVAILABLE_MEMORY_RATIO: string;
|
|
86
|
+
APIFY_PURGE_ON_START: string;
|
|
87
|
+
APIFY_MEMORY_MBYTES: string;
|
|
88
|
+
APIFY_DEFAULT_DATASET_ID: string;
|
|
89
|
+
APIFY_DEFAULT_KEY_VALUE_STORE_ID: string;
|
|
90
|
+
APIFY_DEFAULT_REQUEST_QUEUE_ID: string;
|
|
91
|
+
APIFY_INPUT_KEY: string;
|
|
92
|
+
APIFY_PERSIST_STATE_INTERVAL_MILLIS: string;
|
|
93
|
+
APIFY_HEADLESS: string;
|
|
94
|
+
APIFY_XVFB: string;
|
|
95
|
+
APIFY_CHROME_EXECUTABLE_PATH: string;
|
|
96
|
+
APIFY_DEFAULT_BROWSER_PATH: string;
|
|
97
|
+
APIFY_DISABLE_BROWSER_SANDBOX: string;
|
|
98
|
+
APIFY_TOKEN: string;
|
|
99
|
+
APIFY_METAMORPH_AFTER_SLEEP_MILLIS: string;
|
|
100
|
+
APIFY_TEST_PERSIST_INTERVAL_MILLIS: string;
|
|
101
|
+
APIFY_ACTOR_EVENTS_WS_URL: string;
|
|
102
|
+
APIFY_ACTOR_ID: string;
|
|
103
|
+
APIFY_API_BASE_URL: string;
|
|
104
|
+
APIFY_IS_AT_HOME: string;
|
|
105
|
+
APIFY_ACTOR_RUN_ID: string;
|
|
106
|
+
APIFY_ACTOR_TASK_ID: string;
|
|
107
|
+
APIFY_CONTAINER_PORT: string;
|
|
108
|
+
APIFY_CONTAINER_URL: string;
|
|
109
|
+
APIFY_USER_ID: string;
|
|
110
|
+
APIFY_PROXY_HOSTNAME: string;
|
|
111
|
+
APIFY_PROXY_PASSWORD: string;
|
|
112
|
+
APIFY_PROXY_STATUS_URL: string;
|
|
113
|
+
APIFY_PROXY_PORT: string;
|
|
114
|
+
CRAWLEE_AVAILABLE_MEMORY_RATIO: string;
|
|
115
|
+
CRAWLEE_PURGE_ON_START: string;
|
|
116
|
+
CRAWLEE_MEMORY_MBYTES: string;
|
|
117
|
+
CRAWLEE_DEFAULT_DATASET_ID: string;
|
|
118
|
+
CRAWLEE_DEFAULT_KEY_VALUE_STORE_ID: string; /** @inheritDoc */
|
|
119
|
+
CRAWLEE_DEFAULT_REQUEST_QUEUE_ID: string;
|
|
120
|
+
CRAWLEE_INPUT_KEY: string;
|
|
121
|
+
CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS: string;
|
|
122
|
+
CRAWLEE_HEADLESS: string;
|
|
123
|
+
CRAWLEE_XVFB: string;
|
|
124
|
+
CRAWLEE_CHROME_EXECUTABLE_PATH: string;
|
|
125
|
+
CRAWLEE_DEFAULT_BROWSER_PATH: string;
|
|
126
|
+
CRAWLEE_DISABLE_BROWSER_SANDBOX: string;
|
|
127
|
+
CRAWLEE_LOG_LEVEL: string;
|
|
128
|
+
};
|
|
129
|
+
protected static INTEGER_VARS: string[];
|
|
130
|
+
protected static BOOLEAN_VARS: string[];
|
|
131
|
+
protected static DEFAULTS: {
|
|
132
|
+
defaultKeyValueStoreId: string;
|
|
133
|
+
defaultDatasetId: string;
|
|
134
|
+
defaultRequestQueueId: string;
|
|
135
|
+
inputKey: string;
|
|
136
|
+
apiBaseUrl: string;
|
|
137
|
+
proxyStatusUrl: string;
|
|
138
|
+
proxyHostname: string;
|
|
139
|
+
proxyPort: number;
|
|
140
|
+
containerPort: number;
|
|
141
|
+
containerUrl: string;
|
|
142
|
+
metamorphAfterSleepMillis: number;
|
|
143
|
+
persistStateIntervalMillis: number;
|
|
144
|
+
maxUsedCpuRatio: number;
|
|
145
|
+
availableMemoryRatio: number;
|
|
146
|
+
storageClientOptions: {};
|
|
147
|
+
purgeOnStart: boolean;
|
|
148
|
+
systemInfoIntervalMillis: number;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* @inheritDoc
|
|
152
|
+
*/
|
|
153
|
+
get<T extends keyof ConfigurationOptions, U extends ConfigurationOptions[T]>(key: T, defaultValue?: U): U;
|
|
154
|
+
/**
|
|
155
|
+
* @inheritDoc
|
|
156
|
+
*/
|
|
157
|
+
set(key: keyof ConfigurationOptions, value?: any): void;
|
|
158
|
+
/**
|
|
159
|
+
* @inheritDoc
|
|
160
|
+
*/
|
|
161
|
+
static getGlobalConfig(): Configuration;
|
|
162
|
+
/**
|
|
163
|
+
* Resets global configuration instance. The default instance holds configuration based on env vars,
|
|
164
|
+
* if we want to change them, we need to first reset the global state. Used mainly for testing purposes.
|
|
165
|
+
*/
|
|
166
|
+
static resetGlobalState(): void;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEtF,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IAClE,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;IAChD,kBAAkB;IAClB,OAAgB,YAAY,CAAC,EAAE,aAAa,CAAC;IAG7C,iBAA0B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAJjC,kBAAkB;;;;;;;;;;MAwChB;IAEF,iBAA0B,YAAY,WAAsF;IAE5H,iBAA0B,YAAY,WAAuC;IAE7E,iBAA0B,QAAQ;;;;;;;;;;;;;;;;;;MAchC;IAEF;;OAEG;IACM,GAAG,CAAC,CAAC,SAAS,MAAM,oBAAoB,EAAE,CAAC,SAAS,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;IAIlH;;OAEG;IACM,GAAG,CAAC,GAAG,EAAE,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,GAAG;IAIzD;;OAEG;WACa,eAAe,IAAI,aAAa;IAShD;;;OAGG;WACa,gBAAgB,IAAI,IAAI;CAG3C"}
|
package/configuration.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Configuration = void 0;
|
|
5
|
+
const consts_1 = require("@apify/consts");
|
|
6
|
+
const core_1 = require("@crawlee/core");
|
|
7
|
+
/**
|
|
8
|
+
* `Configuration` is a value object holding the SDK configuration. We can use it in two ways:
|
|
9
|
+
*
|
|
10
|
+
* 1. When using `Actor` class, we can get the instance configuration via `sdk.config`
|
|
11
|
+
*
|
|
12
|
+
* ```javascript
|
|
13
|
+
* import { Actor } from 'apify';
|
|
14
|
+
* import { BasicCrawler } from 'crawlee';
|
|
15
|
+
*
|
|
16
|
+
* const sdk = new Actor({ token: '123' });
|
|
17
|
+
* console.log(sdk.config.get('token')); // '123'
|
|
18
|
+
*
|
|
19
|
+
* const crawler = new BasicCrawler({
|
|
20
|
+
* // ... crawler options
|
|
21
|
+
* }, sdk.config);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* 2. To get the global configuration (singleton instance). It will respect the environment variables.
|
|
25
|
+
*
|
|
26
|
+
* ```javascript
|
|
27
|
+
* import { BasicCrawler, Configuration } from 'crawlee';
|
|
28
|
+
*
|
|
29
|
+
* const config = new Configuration({ persistStateIntervalMillis: 30_000 });
|
|
30
|
+
* const crawler = new BasicCrawler({ ... }, config);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## Supported Configuration Options
|
|
34
|
+
*
|
|
35
|
+
* Key | Environment Variable | Default Value
|
|
36
|
+
* ---|---|---
|
|
37
|
+
* `memoryMbytes` | `APIFY_MEMORY_MBYTES` | -
|
|
38
|
+
* `headless` | `APIFY_HEADLESS` | -
|
|
39
|
+
* `persistStateIntervalMillis` | `APIFY_PERSIST_STATE_INTERVAL_MILLIS` | `60e3`
|
|
40
|
+
* `token` | `APIFY_TOKEN` | -
|
|
41
|
+
* `isAtHome` | `APIFY_IS_AT_HOME` | -
|
|
42
|
+
* `defaultDatasetId` | `APIFY_DEFAULT_DATASET_ID` | `'default'`
|
|
43
|
+
* `defaultKeyValueStoreId` | `APIFY_DEFAULT_KEY_VALUE_STORE_ID` | `'default'`
|
|
44
|
+
* `defaultRequestQueueId` | `APIFY_DEFAULT_REQUEST_QUEUE_ID` | `'default'`
|
|
45
|
+
*
|
|
46
|
+
* ## Advanced Configuration Options
|
|
47
|
+
*
|
|
48
|
+
* Key | Environment Variable | Default Value
|
|
49
|
+
* ---|---|---
|
|
50
|
+
* `actorEventsWsUrl` | `APIFY_ACTOR_EVENTS_WS_URL` | -
|
|
51
|
+
* `actorId` | `APIFY_ACTOR_ID` | -
|
|
52
|
+
* `actorRunId` | `APIFY_ACTOR_RUN_ID` | -
|
|
53
|
+
* `actorTaskId` | `APIFY_ACTOR_TASK_ID` | -
|
|
54
|
+
* `apiBaseUrl` | `APIFY_API_BASE_URL` | `'https://api.apify.com'`
|
|
55
|
+
* `containerPort` | `APIFY_CONTAINER_PORT` | `4321`
|
|
56
|
+
* `containerUrl` | `APIFY_CONTAINER_URL` | `'http://localhost:4321'`
|
|
57
|
+
* `inputKey` | `APIFY_INPUT_KEY` | `'INPUT'`
|
|
58
|
+
* `metamorphAfterSleepMillis` | `APIFY_METAMORPH_AFTER_SLEEP_MILLIS` | `300e3`
|
|
59
|
+
* `proxyHostname` | `APIFY_PROXY_HOSTNAME` | `'proxy.apify.com'`
|
|
60
|
+
* `proxyPassword` | `APIFY_PROXY_PASSWORD` | -
|
|
61
|
+
* `proxyPort` | `APIFY_PROXY_PORT` | `8000`
|
|
62
|
+
* `proxyStatusUrl` | `APIFY_PROXY_STATUS_URL` | `'http://proxy.apify.com'`
|
|
63
|
+
* `userId` | `APIFY_USER_ID` | -
|
|
64
|
+
* `xvfb` | `APIFY_XVFB` | -
|
|
65
|
+
* `chromeExecutablePath` | `APIFY_CHROME_EXECUTABLE_PATH` | -
|
|
66
|
+
* `defaultBrowserPath` | `APIFY_DEFAULT_BROWSER_PATH` | -
|
|
67
|
+
*/
|
|
68
|
+
class Configuration extends (_b = core_1.Configuration) {
|
|
69
|
+
/**
|
|
70
|
+
* @inheritDoc
|
|
71
|
+
*/
|
|
72
|
+
get(key, defaultValue) {
|
|
73
|
+
return super.get(key, defaultValue);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @inheritDoc
|
|
77
|
+
*/
|
|
78
|
+
set(key, value) {
|
|
79
|
+
super.set(key, value);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @inheritDoc
|
|
83
|
+
*/
|
|
84
|
+
static getGlobalConfig() {
|
|
85
|
+
if (Configuration.storage.getStore()) {
|
|
86
|
+
return Configuration.storage.getStore();
|
|
87
|
+
}
|
|
88
|
+
Configuration.globalConfig ?? (Configuration.globalConfig = new Configuration());
|
|
89
|
+
return Configuration.globalConfig;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Resets global configuration instance. The default instance holds configuration based on env vars,
|
|
93
|
+
* if we want to change them, we need to first reset the global state. Used mainly for testing purposes.
|
|
94
|
+
*/
|
|
95
|
+
static resetGlobalState() {
|
|
96
|
+
delete this.globalConfig;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.Configuration = Configuration;
|
|
100
|
+
_a = Configuration;
|
|
101
|
+
// maps environment variables to config keys (e.g. `APIFY_MEMORY_MBYTES` to `memoryMbytes`)
|
|
102
|
+
Object.defineProperty(Configuration, "ENV_MAP", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: {
|
|
107
|
+
// regular crawlee env vars are also supported
|
|
108
|
+
...Reflect.get(_b, "ENV_MAP", _a),
|
|
109
|
+
// support crawlee env vars prefixed with `APIFY_` too
|
|
110
|
+
APIFY_AVAILABLE_MEMORY_RATIO: 'availableMemoryRatio',
|
|
111
|
+
APIFY_PURGE_ON_START: 'purgeOnStart',
|
|
112
|
+
APIFY_MEMORY_MBYTES: 'memoryMbytes',
|
|
113
|
+
APIFY_DEFAULT_DATASET_ID: 'defaultDatasetId',
|
|
114
|
+
APIFY_DEFAULT_KEY_VALUE_STORE_ID: 'defaultKeyValueStoreId',
|
|
115
|
+
APIFY_DEFAULT_REQUEST_QUEUE_ID: 'defaultRequestQueueId',
|
|
116
|
+
APIFY_INPUT_KEY: 'inputKey',
|
|
117
|
+
APIFY_PERSIST_STATE_INTERVAL_MILLIS: 'persistStateIntervalMillis',
|
|
118
|
+
APIFY_HEADLESS: 'headless',
|
|
119
|
+
APIFY_XVFB: 'xvfb',
|
|
120
|
+
APIFY_CHROME_EXECUTABLE_PATH: 'chromeExecutablePath',
|
|
121
|
+
APIFY_DEFAULT_BROWSER_PATH: 'defaultBrowserPath',
|
|
122
|
+
APIFY_DISABLE_BROWSER_SANDBOX: 'disableBrowserSandbox',
|
|
123
|
+
// as well as apify specific ones
|
|
124
|
+
APIFY_TOKEN: 'token',
|
|
125
|
+
APIFY_METAMORPH_AFTER_SLEEP_MILLIS: 'metamorphAfterSleepMillis',
|
|
126
|
+
APIFY_TEST_PERSIST_INTERVAL_MILLIS: 'persistStateIntervalMillis',
|
|
127
|
+
APIFY_ACTOR_EVENTS_WS_URL: 'actorEventsWsUrl',
|
|
128
|
+
APIFY_ACTOR_ID: 'actorId',
|
|
129
|
+
APIFY_API_BASE_URL: 'apiBaseUrl',
|
|
130
|
+
APIFY_IS_AT_HOME: 'isAtHome',
|
|
131
|
+
APIFY_ACTOR_RUN_ID: 'actorRunId',
|
|
132
|
+
APIFY_ACTOR_TASK_ID: 'actorTaskId',
|
|
133
|
+
APIFY_CONTAINER_PORT: 'containerPort',
|
|
134
|
+
APIFY_CONTAINER_URL: 'containerUrl',
|
|
135
|
+
APIFY_USER_ID: 'userId',
|
|
136
|
+
APIFY_PROXY_HOSTNAME: 'proxyHostname',
|
|
137
|
+
APIFY_PROXY_PASSWORD: 'proxyPassword',
|
|
138
|
+
APIFY_PROXY_STATUS_URL: 'proxyStatusUrl',
|
|
139
|
+
APIFY_PROXY_PORT: 'proxyPort',
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(Configuration, "INTEGER_VARS", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: [...Reflect.get(_b, "INTEGER_VARS", _a), 'proxyPort', 'containerPort', 'metamorphAfterSleepMillis']
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(Configuration, "BOOLEAN_VARS", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: [...Reflect.get(_b, "BOOLEAN_VARS", _a), 'isAtHome']
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(Configuration, "DEFAULTS", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: {
|
|
159
|
+
...Reflect.get(_b, "DEFAULTS", _a),
|
|
160
|
+
defaultKeyValueStoreId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID],
|
|
161
|
+
defaultDatasetId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_DATASET_ID],
|
|
162
|
+
defaultRequestQueueId: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.DEFAULT_REQUEST_QUEUE_ID],
|
|
163
|
+
inputKey: 'INPUT',
|
|
164
|
+
apiBaseUrl: 'https://api.apify.com',
|
|
165
|
+
proxyStatusUrl: 'http://proxy.apify.com',
|
|
166
|
+
proxyHostname: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.PROXY_HOSTNAME],
|
|
167
|
+
proxyPort: +consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.PROXY_PORT],
|
|
168
|
+
containerPort: +consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.CONTAINER_PORT],
|
|
169
|
+
containerUrl: consts_1.LOCAL_ENV_VARS[consts_1.ENV_VARS.CONTAINER_URL],
|
|
170
|
+
metamorphAfterSleepMillis: 300e3,
|
|
171
|
+
persistStateIntervalMillis: 60e3, // This value is mentioned in jsdoc in `events.js`, if you update it here, update it there too.
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
// monkey patch the core class so it respects the new options too
|
|
175
|
+
core_1.Configuration.getGlobalConfig = Configuration.getGlobalConfig;
|
|
176
|
+
// @ts-expect-error protected property
|
|
177
|
+
core_1.Configuration.ENV_MAP = Configuration.ENV_MAP;
|
|
178
|
+
// @ts-expect-error protected property
|
|
179
|
+
core_1.Configuration.INTEGER_VARS = Configuration.INTEGER_VARS;
|
|
180
|
+
// @ts-expect-error protected property
|
|
181
|
+
core_1.Configuration.BOOLEAN_VARS = Configuration.BOOLEAN_VARS;
|
|
182
|
+
// @ts-expect-error protected property
|
|
183
|
+
core_1.Configuration.DEFAULTS = Configuration.DEFAULTS;
|
|
184
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"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"}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './actor';
|
|
2
|
+
export * from './configuration';
|
|
2
3
|
export * from './proxy_configuration';
|
|
3
4
|
export * from './platform_event_manager';
|
|
5
|
+
export * from './key_value_store';
|
|
6
|
+
export { Dataset, DatasetDataOptions, DatasetIteratorOptions, DatasetConsumer, DatasetMapper, DatasetReducer, DatasetOptions, DatasetContent, RequestQueue, QueueOperationInfo, RequestQueueOperationOptions, RequestQueueOptions, QueueOperationInfoOptions, KeyConsumer, KeyValueStoreOptions, RecordOptions, KeyValueStoreIteratorOptions, } from '@crawlee/core';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EACnI,YAAY,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,yBAAyB,EAC9G,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,4BAA4B,GACjF,MAAM,eAAe,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestQueue = exports.Dataset = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./actor"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./configuration"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./proxy_configuration"), exports);
|
|
6
8
|
tslib_1.__exportStar(require("./platform_event_manager"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./key_value_store"), exports);
|
|
10
|
+
var core_1 = require("@crawlee/core");
|
|
11
|
+
Object.defineProperty(exports, "Dataset", { enumerable: true, get: function () { return core_1.Dataset; } });
|
|
12
|
+
Object.defineProperty(exports, "RequestQueue", { enumerable: true, get: function () { return core_1.RequestQueue; } });
|
|
7
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,kDAAwB;AACxB,0DAAgC;AAChC,gEAAsC;AACtC,mEAAyC;AACzC,4DAAkC;AAClC,sCAIuB;AAHnB,+FAAA,OAAO,OAAA;AACP,oGAAA,YAAY,OAAA"}
|
package/index.mjs
CHANGED
|
@@ -2,6 +2,10 @@ import mod from "./index.js";
|
|
|
2
2
|
|
|
3
3
|
export default mod;
|
|
4
4
|
export const Actor = mod.Actor;
|
|
5
|
+
export const Configuration = mod.Configuration;
|
|
6
|
+
export const Dataset = mod.Dataset;
|
|
5
7
|
export const EXIT_CODES = mod.EXIT_CODES;
|
|
8
|
+
export const KeyValueStore = mod.KeyValueStore;
|
|
6
9
|
export const PlatformEventManager = mod.PlatformEventManager;
|
|
7
10
|
export const ProxyConfiguration = mod.ProxyConfiguration;
|
|
11
|
+
export const RequestQueue = mod.RequestQueue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StorageManagerOptions } from '@crawlee/core';
|
|
2
|
+
import { KeyValueStore as CoreKeyValueStore } from '@crawlee/core';
|
|
3
|
+
/**
|
|
4
|
+
* @inheritDoc
|
|
5
|
+
*/
|
|
6
|
+
export declare class KeyValueStore extends CoreKeyValueStore {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a URL for the given key that may be used to publicly
|
|
9
|
+
* access the value in the remote key-value store.
|
|
10
|
+
*/
|
|
11
|
+
getPublicUrl(key: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* @inheritDoc
|
|
14
|
+
*/
|
|
15
|
+
static open(storeIdOrName?: string | null, options?: StorageManagerOptions): Promise<KeyValueStore>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=key_value_store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key_value_store.d.ts","sourceRoot":"","sources":["../src/key_value_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEnE;;GAEG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIjC;;OAEG;WACmB,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,aAAa,CAAC;CAGzH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyValueStore = void 0;
|
|
4
|
+
const core_1 = require("@crawlee/core");
|
|
5
|
+
/**
|
|
6
|
+
* @inheritDoc
|
|
7
|
+
*/
|
|
8
|
+
class KeyValueStore extends core_1.KeyValueStore {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a URL for the given key that may be used to publicly
|
|
11
|
+
* access the value in the remote key-value store.
|
|
12
|
+
*/
|
|
13
|
+
getPublicUrl(key) {
|
|
14
|
+
return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static async open(storeIdOrName, options = {}) {
|
|
20
|
+
return super.open(storeIdOrName, options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.KeyValueStore = KeyValueStore;
|
|
24
|
+
// @ts-expect-error extension of the core class to make this only a type-issue
|
|
25
|
+
core_1.KeyValueStore.prototype.getPublicUrl = KeyValueStore.prototype.getPublicUrl;
|
|
26
|
+
//# sourceMappingURL=key_value_store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key_value_store.js","sourceRoot":"","sources":["../src/key_value_store.ts"],"names":[],"mappings":";;;AACA,wCAAmE;AAEnE;;GAEG;AACH,MAAa,aAAc,SAAQ,oBAAiB;IAChD;;;OAGG;IACH,YAAY,CAAC,GAAW;QACpB,OAAO,6CAA6C,IAAI,CAAC,EAAE,YAAY,GAAG,EAAE,CAAC;IACjF,CAAC;IAED;;OAEG;IACH,MAAM,CAAU,KAAK,CAAC,IAAI,CAAC,aAA6B,EAAE,UAAiC,EAAE;QACzF,OAAO,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAA6B,CAAC;IAC1E,CAAC;CACJ;AAfD,sCAeC;AAED,8EAA8E;AAC9E,oBAAiB,CAAC,SAAS,CAAC,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apify",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"module": "./index.mjs",
|
|
10
|
+
"types": "./index.d.ts",
|
|
9
11
|
"exports": {
|
|
10
12
|
".": {
|
|
11
13
|
"import": "./index.mjs",
|
|
12
|
-
"require": "./index.js"
|
|
13
|
-
|
|
14
|
+
"require": "./index.js",
|
|
15
|
+
"types": "./index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
14
18
|
},
|
|
15
19
|
"keywords": [
|
|
16
20
|
"apify",
|
|
@@ -33,12 +37,12 @@
|
|
|
33
37
|
"license": "Apache-2.0",
|
|
34
38
|
"repository": {
|
|
35
39
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/apify/apify-
|
|
40
|
+
"url": "git+https://github.com/apify/apify-ts"
|
|
37
41
|
},
|
|
38
42
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/apify/apify-
|
|
43
|
+
"url": "https://github.com/apify/apify-ts/issues"
|
|
40
44
|
},
|
|
41
|
-
"homepage": "https://
|
|
45
|
+
"homepage": "https://apify.github.io/apify-ts/",
|
|
42
46
|
"scripts": {
|
|
43
47
|
"build": "npm run clean && npm run compile && npm run copy && npm run fixApifyExport",
|
|
44
48
|
"clean": "rimraf ./dist",
|
|
@@ -50,15 +54,16 @@
|
|
|
50
54
|
"access": "public"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"@apify/consts": "^
|
|
54
|
-
"@apify/log": "^1.
|
|
55
|
-
"@apify/utilities": "^1.
|
|
56
|
-
"@crawlee/core": "^3.0.0-beta.
|
|
57
|
-
"@crawlee/types": "^3.0.0-beta.
|
|
58
|
-
"@crawlee/utils": "^3.0.0-beta.
|
|
59
|
-
"
|
|
60
|
-
"apify-client": "^2.5.0",
|
|
57
|
+
"@apify/consts": "^2.0.0",
|
|
58
|
+
"@apify/log": "^2.1.0",
|
|
59
|
+
"@apify/utilities": "^2.1.1",
|
|
60
|
+
"@crawlee/core": "^3.0.0-beta.78",
|
|
61
|
+
"@crawlee/types": "^3.0.0-beta.78",
|
|
62
|
+
"@crawlee/utils": "^3.0.0-beta.78",
|
|
63
|
+
"apify-client": "^2.6.0-beta.1",
|
|
61
64
|
"ow": "^0.28.1",
|
|
62
|
-
"
|
|
63
|
-
|
|
65
|
+
"semver": "^7.3.7",
|
|
66
|
+
"ws": "^7.5.8"
|
|
67
|
+
},
|
|
68
|
+
"gitHead": "bd3c4777d4dade393590bccefd651b4f2facffae"
|
|
64
69
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventManager } from '@crawlee/core';
|
|
2
|
+
import { Configuration } from './configuration';
|
|
2
3
|
/**
|
|
3
4
|
* Gets an instance of a Node.js'
|
|
4
5
|
* [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
|
|
@@ -37,8 +38,10 @@ import { EventManager } from '@crawlee/core';
|
|
|
37
38
|
* you can achieve the same effect using `setInterval()` and listening for the `migrating` event.
|
|
38
39
|
*/
|
|
39
40
|
export declare class PlatformEventManager extends EventManager {
|
|
41
|
+
readonly config: Configuration;
|
|
40
42
|
/** Websocket connection to actor events. */
|
|
41
43
|
private eventsWs?;
|
|
44
|
+
constructor(config?: Configuration);
|
|
42
45
|
/**
|
|
43
46
|
* Initializes `Actor.events` event emitter by creating a connection to a websocket that provides them.
|
|
44
47
|
* This is an internal function that is automatically called by `Actor.main()`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform_event_manager.d.ts","sourceRoot":"","sources":["../src/platform_event_manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"platform_event_manager.d.ts","sourceRoot":"","sources":["../src/platform_event_manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,YAAY,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;aAIpB,MAAM;IAHpC,4CAA4C;IAC5C,OAAO,CAAC,QAAQ,CAAC,CAAY;gBAEC,MAAM,gBAAkC;IAItE;;;OAGG;IACY,IAAI;IAiBnB,OAAO,CAAC,yBAAyB;IAgCjC;;;;OAIG;IACY,KAAK;CAQvB"}
|
|
@@ -6,6 +6,7 @@ const consts_1 = require("@apify/consts");
|
|
|
6
6
|
const ws_1 = tslib_1.__importDefault(require("ws"));
|
|
7
7
|
const core_1 = require("@crawlee/core");
|
|
8
8
|
const utilities_1 = require("@apify/utilities");
|
|
9
|
+
const configuration_1 = require("./configuration");
|
|
9
10
|
/**
|
|
10
11
|
* Gets an instance of a Node.js'
|
|
11
12
|
* [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
|
|
@@ -44,8 +45,14 @@ const utilities_1 = require("@apify/utilities");
|
|
|
44
45
|
* you can achieve the same effect using `setInterval()` and listening for the `migrating` event.
|
|
45
46
|
*/
|
|
46
47
|
class PlatformEventManager extends core_1.EventManager {
|
|
47
|
-
constructor() {
|
|
48
|
-
super(
|
|
48
|
+
constructor(config = configuration_1.Configuration.getGlobalConfig()) {
|
|
49
|
+
super();
|
|
50
|
+
Object.defineProperty(this, "config", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: config
|
|
55
|
+
});
|
|
49
56
|
/** Websocket connection to actor events. */
|
|
50
57
|
Object.defineProperty(this, "eventsWs", {
|
|
51
58
|
enumerable: true,
|
|
@@ -63,7 +70,7 @@ class PlatformEventManager extends core_1.EventManager {
|
|
|
63
70
|
return;
|
|
64
71
|
}
|
|
65
72
|
await super.init();
|
|
66
|
-
const eventsWsUrl =
|
|
73
|
+
const eventsWsUrl = this.config.get('actorEventsWsUrl');
|
|
67
74
|
// Locally there is no web socket to connect, so just print a log message.
|
|
68
75
|
if (!eventsWsUrl) {
|
|
69
76
|
this.log.debug(`Environment variable ${consts_1.ENV_VARS.ACTOR_EVENTS_WS_URL} is not set, no events from Apify platform will be emitted.`);
|
|
@@ -95,7 +102,7 @@ class PlatformEventManager extends core_1.EventManager {
|
|
|
95
102
|
this.log.exception(err, 'web socket connection failed');
|
|
96
103
|
});
|
|
97
104
|
this.eventsWs.on('close', () => {
|
|
98
|
-
this.log.
|
|
105
|
+
this.log.debug('web socket has been closed');
|
|
99
106
|
this.eventsWs = undefined;
|
|
100
107
|
});
|
|
101
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform_event_manager.js","sourceRoot":"","sources":["../src/platform_event_manager.ts"],"names":[],"mappings":";;;;AAAA,0CAA4D;AAC5D,oDAA2B;AAC3B,wCAAwD;AACxD,gDAAuD;
|
|
1
|
+
{"version":3,"file":"platform_event_manager.js","sourceRoot":"","sources":["../src/platform_event_manager.ts"],"names":[],"mappings":";;;;AAAA,0CAA4D;AAC5D,oDAA2B;AAC3B,wCAAwD;AACxD,gDAAuD;AACvD,mDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,oBAAqB,SAAQ,mBAAY;IAIlD,YAA8B,SAAS,6BAAa,CAAC,eAAe,EAAE;QAClE,KAAK,EAAE,CAAC;;;;;mBADkB;;QAH9B,4CAA4C;QAC5C;;;;;WAA6B;IAI7B,CAAC;IAED;;;OAGG;IACM,KAAK,CAAC,IAAI;QACf,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,OAAO;SACV;QAED,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAExD,0EAA0E;QAC1E,IAAI,CAAC,WAAW,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wBAAwB,iBAAQ,CAAC,mBAAmB,6DAA6D,CAAC,CAAC;YAClI,OAAO;SACV;QAED,IAAI,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAEO,yBAAyB,CAAC,WAAmB;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAS,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,IAAI;gBACA,MAAM,EACF,IAAI,EACJ,IAAI,GACP,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAE7B,IAAI,IAAI,KAAK,0BAAiB,CAAC,SAAS,EAAE;oBACtC,IAAA,+BAAmB,EAAC,IAAI,CAAC,SAAS,CAAC,YAAa,CAAC,CAAC,CAAC,4CAA4C;oBAC/F,IAAI,CAAC,MAAM,CAAC,IAAI,+CAA0B,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;iBACpE;aACJ;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAY,EAAE,0BAA0B,CAAC,CAAC;aAChE;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC9B,iFAAiF;YACjF,IAAI,GAAG,CAAC,OAAO,KAAK,4DAA4D;gBAAE,OAAO;YAEzF,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,8BAA8B,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAC3B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAC7C,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,OAAO;SACV;QAED,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;CACJ;AA1ED,oDA0EC"}
|
package/proxy_configuration.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProxyConfigurationOptions as CoreProxyConfigurationOptions, ProxyInfo as CoreProxyInfo } from '@crawlee/core';
|
|
2
|
+
import { ProxyConfiguration as CoreProxyConfiguration } from '@crawlee/core';
|
|
3
|
+
import { Configuration } from './configuration';
|
|
2
4
|
export interface ProxyConfigurationOptions extends CoreProxyConfigurationOptions {
|
|
3
5
|
/**
|
|
4
6
|
* User's password for the proxy. By default, it is taken from the `APIFY_PROXY_PASSWORD`
|
|
@@ -54,11 +56,11 @@ export interface ProxyConfigurationOptions extends CoreProxyConfigurationOptions
|
|
|
54
56
|
* const crawler = new CheerioCrawler({
|
|
55
57
|
* // ...
|
|
56
58
|
* proxyConfiguration,
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
+
* requestHandler({ proxyInfo }) {
|
|
60
|
+
* // Getting used proxy URL
|
|
59
61
|
* const proxyUrl = proxyInfo.url;
|
|
60
62
|
*
|
|
61
|
-
*
|
|
63
|
+
* // Getting ID of used Session
|
|
62
64
|
* const sessionIdentifier = proxyInfo.sessionId;
|
|
63
65
|
* }
|
|
64
66
|
* })
|
|
@@ -114,7 +116,7 @@ export interface ProxyInfo extends CoreProxyInfo {
|
|
|
114
116
|
* const crawler = new CheerioCrawler({
|
|
115
117
|
* // ...
|
|
116
118
|
* proxyConfiguration,
|
|
117
|
-
*
|
|
119
|
+
* requestHandler({ proxyInfo }) {
|
|
118
120
|
* const usedProxyUrl = proxyInfo.url; // Getting the proxy URL
|
|
119
121
|
* }
|
|
120
122
|
* })
|
|
@@ -123,6 +125,7 @@ export interface ProxyInfo extends CoreProxyInfo {
|
|
|
123
125
|
* @category Scaling
|
|
124
126
|
*/
|
|
125
127
|
export declare class ProxyConfiguration extends CoreProxyConfiguration {
|
|
128
|
+
readonly config: Configuration;
|
|
126
129
|
private groups;
|
|
127
130
|
private countryCode?;
|
|
128
131
|
private password?;
|
|
@@ -145,7 +148,7 @@ export declare class ProxyConfiguration extends CoreProxyConfiguration {
|
|
|
145
148
|
/**
|
|
146
149
|
* This function creates a new {@link ProxyInfo} info object.
|
|
147
150
|
* It is used by CheerioCrawler and PuppeteerCrawler to generate proxy URLs and also to allow the user to inspect
|
|
148
|
-
* the currently used proxy via the
|
|
151
|
+
* the currently used proxy via the requestHandler parameter `proxyInfo`.
|
|
149
152
|
* Use it if you want to work with a rich representation of a proxy URL.
|
|
150
153
|
* If you need the URL string only, use {@link ProxyConfiguration.newUrl}.
|
|
151
154
|
* @param [sessionId]
|