@crawlee/core 4.0.0-beta.2 → 4.0.0-beta.200
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 +17 -13
- package/byte_utils.d.ts +17 -0
- package/byte_utils.js +42 -0
- package/configuration.d.ts +88 -234
- package/configuration.js +162 -230
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/errors.d.ts +43 -10
- package/errors.js +57 -12
- package/events/event_manager.d.ts +35 -9
- package/events/event_manager.js +12 -13
- package/events/index.d.ts +1 -1
- package/events/index.js +0 -1
- package/events/local_event_manager.d.ts +15 -5
- package/events/local_event_manager.js +39 -42
- package/events/system_info.d.ts +38 -0
- package/events/system_info.js +1 -0
- package/index.d.ts +8 -11
- package/index.js +9 -10
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +81 -3
- package/log.js +134 -1
- package/memory-storage/consts.d.ts +4 -0
- package/memory-storage/consts.js +4 -0
- package/memory-storage/index.d.ts +1 -0
- package/memory-storage/index.js +1 -0
- package/memory-storage/memory-storage.d.ts +43 -0
- package/memory-storage/memory-storage.js +158 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
- package/memory-storage/resource-clients/common/base-client.js +6 -0
- package/memory-storage/resource-clients/dataset.d.ts +40 -0
- package/memory-storage/resource-clients/dataset.js +106 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +56 -0
- package/memory-storage/resource-clients/key-value-store.js +180 -0
- package/memory-storage/resource-clients/request-queue.d.ts +77 -0
- package/memory-storage/resource-clients/request-queue.js +414 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned_or_injected.d.ts +58 -0
- package/owned_or_injected.js +98 -0
- package/package.json +19 -20
- package/proxy_configuration.d.ts +29 -155
- package/proxy_configuration.js +38 -183
- package/recoverable_state.d.ts +177 -0
- package/recoverable_state.js +268 -0
- package/request.d.ts +62 -81
- package/request.js +125 -220
- package/serialization.d.ts +0 -1
- package/serialization.js +18 -18
- package/service_locator.d.ts +168 -0
- package/service_locator.js +255 -0
- package/storages/batched_adds.d.ts +37 -0
- package/storages/batched_adds.js +73 -0
- package/storages/dataset.d.ts +120 -56
- package/storages/dataset.js +299 -148
- package/storages/index.d.ts +9 -8
- package/storages/index.js +5 -8
- package/storages/key_value_store.d.ts +192 -65
- package/storages/key_value_store.js +453 -193
- package/storages/key_value_store_codec.d.ts +32 -0
- package/storages/key_value_store_codec.js +113 -0
- package/storages/request_dedup_cache.d.ts +22 -0
- package/storages/request_dedup_cache.js +48 -0
- package/storages/request_list.d.ts +55 -137
- package/storages/request_list.js +272 -245
- package/storages/request_loader.d.ts +127 -0
- package/storages/request_loader.js +36 -0
- package/storages/request_manager.d.ts +119 -0
- package/storages/request_manager.js +1 -0
- package/storages/request_manager_tandem.d.ts +94 -0
- package/storages/request_manager_tandem.js +200 -0
- package/storages/request_queue.d.ts +293 -48
- package/storages/request_queue.js +766 -216
- package/storages/storage_instance_manager.d.ts +86 -0
- package/storages/storage_instance_manager.js +256 -0
- package/storages/storage_stats.d.ts +48 -0
- package/storages/storage_stats.js +29 -0
- package/storages/transaction.d.ts +271 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +59 -11
- package/storages/utils.js +75 -15
- package/system-info/cpu-info.d.ts +67 -0
- package/system-info/cpu-info.js +216 -0
- package/system-info/memory-info.d.ts +31 -0
- package/system-info/memory-info.js +115 -0
- package/system-info/ps-tree.d.ts +17 -0
- package/system-info/ps-tree.js +144 -0
- package/system-info/runtime.d.ts +14 -0
- package/system-info/runtime.js +80 -0
- package/typedefs.d.ts +0 -6
- package/typedefs.js +0 -1
- package/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -18
- package/validators.js +14 -18
- package/autoscaling/autoscaled_pool.d.ts +0 -300
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js +0 -533
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts +0 -4
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js +0 -4
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts +0 -189
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js +0 -292
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts +0 -181
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js +0 -169
- package/autoscaling/system_status.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/cookie_utils.d.ts +0 -43
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js +0 -113
- package/cookie_utils.js.map +0 -1
- package/crawlers/crawler_commons.d.ts +0 -199
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js +0 -116
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_extension.d.ts +0 -12
- package/crawlers/crawler_extension.d.ts.map +0 -1
- package/crawlers/crawler_extension.js +0 -14
- package/crawlers/crawler_extension.js.map +0 -1
- package/crawlers/crawler_utils.d.ts +0 -10
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js +0 -12
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts +0 -59
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js +0 -118
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts +0 -54
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js +0 -309
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts +0 -7
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js +0 -7
- package/crawlers/index.js.map +0 -1
- package/crawlers/statistics.d.ts +0 -204
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js +0 -346
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts +0 -242
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js +0 -250
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts +0 -3
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js +0 -3
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts +0 -67
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js +0 -190
- package/enqueue_links/shared.js.map +0 -1
- package/errors.d.ts.map +0 -1
- package/errors.js.map +0 -1
- package/events/event_manager.d.ts.map +0 -1
- package/events/event_manager.js.map +0 -1
- package/events/index.d.ts.map +0 -1
- package/events/index.js.map +0 -1
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js.map +0 -1
- package/http_clients/base-http-client.d.ts +0 -134
- package/http_clients/base-http-client.d.ts.map +0 -1
- package/http_clients/base-http-client.js +0 -33
- package/http_clients/base-http-client.js.map +0 -1
- package/http_clients/form-data-like.d.ts +0 -67
- package/http_clients/form-data-like.d.ts.map +0 -1
- package/http_clients/form-data-like.js +0 -5
- package/http_clients/form-data-like.js.map +0 -1
- package/http_clients/got-scraping-http-client.d.ts +0 -15
- package/http_clients/got-scraping-http-client.d.ts.map +0 -1
- package/http_clients/got-scraping-http-client.js +0 -69
- package/http_clients/got-scraping-http-client.js.map +0 -1
- package/http_clients/index.d.ts +0 -3
- package/http_clients/index.d.ts.map +0 -1
- package/http_clients/index.js +0 -3
- package/http_clients/index.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/log.d.ts.map +0 -1
- package/log.js.map +0 -1
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts +0 -134
- package/router.d.ts.map +0 -1
- package/router.js +0 -164
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/session_pool/consts.d.ts +0 -4
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js +0 -4
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts +0 -8
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js +0 -12
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts +0 -3
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js +0 -3
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts +0 -6
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js +0 -6
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts +0 -199
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js +0 -271
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts +0 -251
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js +0 -375
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts +0 -13
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js +0 -14
- package/storages/access_checking.js.map +0 -1
- package/storages/dataset.d.ts.map +0 -1
- package/storages/dataset.js.map +0 -1
- package/storages/index.d.ts.map +0 -1
- package/storages/index.js.map +0 -1
- package/storages/key_value_store.d.ts.map +0 -1
- package/storages/key_value_store.js.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_provider.d.ts +0 -307
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -555
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js.map +0 -1
- package/storages/request_queue_v2.d.ts +0 -87
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js +0 -438
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts +0 -245
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js +0 -430
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -58
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -105
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/typedefs.d.ts.map +0 -1
- package/typedefs.js.map +0 -1
- package/validators.d.ts.map +0 -1
- package/validators.js.map +0 -1
package/router.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { MissingRouteError } from './errors.js';
|
|
2
|
-
const defaultRoute = Symbol('default-route');
|
|
3
|
-
/**
|
|
4
|
-
* Simple router that works based on request labels. This instance can then serve as a `requestHandler` of your crawler.
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* import { Router, CheerioCrawler, CheerioCrawlingContext } from 'crawlee';
|
|
8
|
-
*
|
|
9
|
-
* const router = Router.create<CheerioCrawlingContext>();
|
|
10
|
-
*
|
|
11
|
-
* // we can also use factory methods for specific crawling contexts, the above equals to:
|
|
12
|
-
* // import { createCheerioRouter } from 'crawlee';
|
|
13
|
-
* // const router = createCheerioRouter();
|
|
14
|
-
*
|
|
15
|
-
* router.addHandler('label-a', async (ctx) => {
|
|
16
|
-
* ctx.log.info('...');
|
|
17
|
-
* });
|
|
18
|
-
* router.addDefaultHandler(async (ctx) => {
|
|
19
|
-
* ctx.log.info('...');
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* const crawler = new CheerioCrawler({
|
|
23
|
-
* requestHandler: router,
|
|
24
|
-
* });
|
|
25
|
-
* await crawler.run();
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* Alternatively we can use the default router instance from crawler object:
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { CheerioCrawler } from 'crawlee';
|
|
32
|
-
*
|
|
33
|
-
* const crawler = new CheerioCrawler();
|
|
34
|
-
*
|
|
35
|
-
* crawler.router.addHandler('label-a', async (ctx) => {
|
|
36
|
-
* ctx.log.info('...');
|
|
37
|
-
* });
|
|
38
|
-
* crawler.router.addDefaultHandler(async (ctx) => {
|
|
39
|
-
* ctx.log.info('...');
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* await crawler.run();
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* For convenience, we can also define the routes right when creating the router:
|
|
46
|
-
*
|
|
47
|
-
* ```ts
|
|
48
|
-
* import { CheerioCrawler, createCheerioRouter } from 'crawlee';
|
|
49
|
-
* const crawler = new CheerioCrawler({
|
|
50
|
-
* requestHandler: createCheerioRouter({
|
|
51
|
-
* 'label-a': async (ctx) => { ... },
|
|
52
|
-
* 'label-b': async (ctx) => { ... },
|
|
53
|
-
* })},
|
|
54
|
-
* });
|
|
55
|
-
* await crawler.run();
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* Middlewares are also supported via the `router.use` method. There can be multiple
|
|
59
|
-
* middlewares for a single router, they will be executed sequentially in the same
|
|
60
|
-
* order as they were registered.
|
|
61
|
-
*
|
|
62
|
-
* ```ts
|
|
63
|
-
* crawler.router.use(async (ctx) => {
|
|
64
|
-
* ctx.log.info('...');
|
|
65
|
-
* });
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export class Router {
|
|
69
|
-
routes = new Map();
|
|
70
|
-
middlewares = [];
|
|
71
|
-
/**
|
|
72
|
-
* use Router.create() instead!
|
|
73
|
-
* @ignore
|
|
74
|
-
*/
|
|
75
|
-
constructor() { }
|
|
76
|
-
/**
|
|
77
|
-
* Registers new route handler for given label.
|
|
78
|
-
*/
|
|
79
|
-
addHandler(label, handler) {
|
|
80
|
-
this.validate(label);
|
|
81
|
-
this.routes.set(label, handler);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Registers default route handler.
|
|
85
|
-
*/
|
|
86
|
-
addDefaultHandler(handler) {
|
|
87
|
-
this.validate(defaultRoute);
|
|
88
|
-
this.routes.set(defaultRoute, handler);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Registers a middleware that will be fired before the matching route handler.
|
|
92
|
-
* Multiple middlewares can be registered, they will be fired in the same order.
|
|
93
|
-
*/
|
|
94
|
-
use(middleware) {
|
|
95
|
-
this.middlewares.push(middleware);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns route handler for given label. If no label is provided, the default request handler will be returned.
|
|
99
|
-
*/
|
|
100
|
-
getHandler(label) {
|
|
101
|
-
if (label && this.routes.has(label)) {
|
|
102
|
-
return this.routes.get(label);
|
|
103
|
-
}
|
|
104
|
-
if (this.routes.has(defaultRoute)) {
|
|
105
|
-
return this.routes.get(defaultRoute);
|
|
106
|
-
}
|
|
107
|
-
throw new MissingRouteError(`Route not found for label '${String(label)}'.` +
|
|
108
|
-
' You must set up a route for this label or a default route.' +
|
|
109
|
-
' Use `requestHandler`, `router.addHandler` or `router.addDefaultHandler`.');
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Throws when the label already exists in our registry.
|
|
113
|
-
*/
|
|
114
|
-
validate(label) {
|
|
115
|
-
if (this.routes.has(label)) {
|
|
116
|
-
const message = label === defaultRoute
|
|
117
|
-
? `Default route is already defined!`
|
|
118
|
-
: `Route for label '${String(label)}' is already defined!`;
|
|
119
|
-
throw new Error(message);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Creates new router instance. This instance can then serve as a `requestHandler` of your crawler.
|
|
124
|
-
*
|
|
125
|
-
* ```ts
|
|
126
|
-
* import { Router, CheerioCrawler, CheerioCrawlingContext } from 'crawlee';
|
|
127
|
-
*
|
|
128
|
-
* const router = Router.create<CheerioCrawlingContext>();
|
|
129
|
-
* router.addHandler('label-a', async (ctx) => {
|
|
130
|
-
* ctx.log.info('...');
|
|
131
|
-
* });
|
|
132
|
-
* router.addDefaultHandler(async (ctx) => {
|
|
133
|
-
* ctx.log.info('...');
|
|
134
|
-
* });
|
|
135
|
-
*
|
|
136
|
-
* const crawler = new CheerioCrawler({
|
|
137
|
-
* requestHandler: router,
|
|
138
|
-
* });
|
|
139
|
-
* await crawler.run();
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
static create(routes) {
|
|
143
|
-
const router = new Router();
|
|
144
|
-
const obj = Object.create(Function.prototype);
|
|
145
|
-
obj.addHandler = router.addHandler.bind(router);
|
|
146
|
-
obj.addDefaultHandler = router.addDefaultHandler.bind(router);
|
|
147
|
-
obj.getHandler = router.getHandler.bind(router);
|
|
148
|
-
obj.use = router.use.bind(router);
|
|
149
|
-
for (const [label, handler] of Object.entries(routes ?? {})) {
|
|
150
|
-
router.addHandler(label, handler);
|
|
151
|
-
}
|
|
152
|
-
const func = async function (context) {
|
|
153
|
-
const { url, loadedUrl, label } = context.request;
|
|
154
|
-
context.log.debug('Page opened.', { label, url: loadedUrl ?? url });
|
|
155
|
-
for (const middleware of router.middlewares) {
|
|
156
|
-
await middleware(context);
|
|
157
|
-
}
|
|
158
|
-
return router.getHandler(label)(context);
|
|
159
|
-
};
|
|
160
|
-
Object.setPrototypeOf(func, obj);
|
|
161
|
-
return func;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=router.js.map
|
package/router.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAa7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,OAAO,MAAM;IACE,MAAM,GAA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M,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEjC,OAAO,IAAyC,CAAC;IACrD,CAAC;CACJ"}
|
package/serialization.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,QAAQ,EAAY,MAAM,aAAa,CAAC;AAwD7E;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlE;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAMnH;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAU/E"}
|
package/serialization.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAE/D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAe,SAAQ,QAAQ;IAKrB;IAJJ,MAAM,GAAG,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,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/session_pool/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAkB,CAAC;AACpD,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAC1D,eAAO,MAAM,aAAa,OAAO,CAAC"}
|
package/session_pool/consts.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/session_pool/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC"}
|
package/session_pool/errors.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/session_pool/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,OAAO;gBAA3B,kBAAkB,EAAE,OAAO;CAInD"}
|
package/session_pool/errors.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ignore
|
|
3
|
-
*/
|
|
4
|
-
export class CookieParseError extends Error {
|
|
5
|
-
cookieHeaderString;
|
|
6
|
-
constructor(cookieHeaderString) {
|
|
7
|
-
super(`Could not parse cookie header string: ${cookieHeaderString}`);
|
|
8
|
-
this.cookieHeaderString = cookieHeaderString;
|
|
9
|
-
Error.captureStackTrace(this, CookieParseError);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/session_pool/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAClB;IAArB,YAAqB,kBAA2B;QAC5C,KAAK,CAAC,yCAAyC,kBAAkB,EAAE,CAAC,CAAC;QADpD,uBAAkB,GAAlB,kBAAkB,CAAS;QAE5C,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;CACJ"}
|
package/session_pool/events.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/session_pool/events.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,mBAAmB,CAAC"}
|
package/session_pool/events.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/session_pool/events.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC"}
|
package/session_pool/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session_pool/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
package/session_pool/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session_pool/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import type { Cookie as CookieObject, Dictionary } from '@crawlee/types';
|
|
2
|
-
import type { Cookie, SerializedCookieJar } from 'tough-cookie';
|
|
3
|
-
import { CookieJar } from 'tough-cookie';
|
|
4
|
-
import type { Log } from '@apify/log';
|
|
5
|
-
import type { ResponseLike } from '../cookie_utils.js';
|
|
6
|
-
/**
|
|
7
|
-
* Persistable {@link Session} state.
|
|
8
|
-
*/
|
|
9
|
-
export interface SessionState {
|
|
10
|
-
id: string;
|
|
11
|
-
cookieJar: SerializedCookieJar;
|
|
12
|
-
userData: object;
|
|
13
|
-
errorScore: number;
|
|
14
|
-
maxErrorScore: number;
|
|
15
|
-
errorScoreDecrement: number;
|
|
16
|
-
usageCount: number;
|
|
17
|
-
maxUsageCount: number;
|
|
18
|
-
expiresAt: string;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
}
|
|
21
|
-
export interface SessionOptions {
|
|
22
|
-
/** Id of session used for generating fingerprints. It is used as proxy session name. */
|
|
23
|
-
id?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Number of seconds after which the session is considered as expired.
|
|
26
|
-
* @default 3000
|
|
27
|
-
*/
|
|
28
|
-
maxAgeSecs?: number;
|
|
29
|
-
/** Object where custom user data can be stored. For example custom headers. */
|
|
30
|
-
userData?: Dictionary;
|
|
31
|
-
/**
|
|
32
|
-
* Maximum number of marking session as blocked usage.
|
|
33
|
-
* If the `errorScore` reaches the `maxErrorScore` session is marked as block and it is thrown away.
|
|
34
|
-
* It starts at 0. Calling the `markBad` function increases the `errorScore` by 1.
|
|
35
|
-
* Calling the `markGood` will decrease the `errorScore` by `errorScoreDecrement`
|
|
36
|
-
* @default 3
|
|
37
|
-
*/
|
|
38
|
-
maxErrorScore?: number;
|
|
39
|
-
/**
|
|
40
|
-
* It is used for healing the session.
|
|
41
|
-
* For example: if your session is marked bad two times, but it is successful on the third attempt it's errorScore
|
|
42
|
-
* is decremented by this number.
|
|
43
|
-
* @default 0.5
|
|
44
|
-
*/
|
|
45
|
-
errorScoreDecrement?: number;
|
|
46
|
-
/** Date of creation. */
|
|
47
|
-
createdAt?: Date;
|
|
48
|
-
/** Date of expiration. */
|
|
49
|
-
expiresAt?: Date;
|
|
50
|
-
/**
|
|
51
|
-
* Indicates how many times the session has been used.
|
|
52
|
-
* @default 0
|
|
53
|
-
*/
|
|
54
|
-
usageCount?: number;
|
|
55
|
-
/**
|
|
56
|
-
* Session should be used only a limited amount of times.
|
|
57
|
-
* This number indicates how many times the session is going to be used, before it is thrown away.
|
|
58
|
-
* @default 50
|
|
59
|
-
*/
|
|
60
|
-
maxUsageCount?: number;
|
|
61
|
-
/** SessionPool instance. Session will emit the `sessionRetired` event on this instance. */
|
|
62
|
-
sessionPool?: import('./session_pool.js').SessionPool;
|
|
63
|
-
log?: Log;
|
|
64
|
-
errorScore?: number;
|
|
65
|
-
cookieJar?: CookieJar;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Sessions are used to store information such as cookies and can be used for generating fingerprints and proxy sessions.
|
|
69
|
-
* You can imagine each session as a specific user, with its own cookies, IP (via proxy) and potentially a unique browser fingerprint.
|
|
70
|
-
* Session internal state can be enriched with custom user data for example some authorization tokens and specific headers in general.
|
|
71
|
-
* @category Scaling
|
|
72
|
-
*/
|
|
73
|
-
export declare class Session {
|
|
74
|
-
readonly id: string;
|
|
75
|
-
private maxAgeSecs;
|
|
76
|
-
userData: Dictionary;
|
|
77
|
-
private _maxErrorScore;
|
|
78
|
-
private _errorScoreDecrement;
|
|
79
|
-
private _createdAt;
|
|
80
|
-
private _expiresAt;
|
|
81
|
-
private _usageCount;
|
|
82
|
-
private _maxUsageCount;
|
|
83
|
-
private sessionPool;
|
|
84
|
-
private _errorScore;
|
|
85
|
-
private _cookieJar;
|
|
86
|
-
private log;
|
|
87
|
-
get errorScore(): number;
|
|
88
|
-
get usageCount(): number;
|
|
89
|
-
get maxErrorScore(): number;
|
|
90
|
-
get errorScoreDecrement(): number;
|
|
91
|
-
get expiresAt(): Date;
|
|
92
|
-
get createdAt(): Date;
|
|
93
|
-
get maxUsageCount(): number;
|
|
94
|
-
get cookieJar(): CookieJar;
|
|
95
|
-
/**
|
|
96
|
-
* Session configuration.
|
|
97
|
-
*/
|
|
98
|
-
constructor(options: SessionOptions);
|
|
99
|
-
/**
|
|
100
|
-
* Indicates whether the session is blocked.
|
|
101
|
-
* Session is blocked once it reaches the `maxErrorScore`.
|
|
102
|
-
*/
|
|
103
|
-
isBlocked(): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Indicates whether the session is expired.
|
|
106
|
-
* Session expiration is determined by the `maxAgeSecs`.
|
|
107
|
-
* Once the session is older than `createdAt + maxAgeSecs` the session is considered expired.
|
|
108
|
-
*/
|
|
109
|
-
isExpired(): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Indicates whether the session is used maximum number of times.
|
|
112
|
-
* Session maximum usage count can be changed by `maxUsageCount` parameter.
|
|
113
|
-
*/
|
|
114
|
-
isMaxUsageCountReached(): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Indicates whether the session can be used for next requests.
|
|
117
|
-
* Session is usable when it is not expired, not blocked and the maximum usage count has not be reached.
|
|
118
|
-
*/
|
|
119
|
-
isUsable(): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* This method should be called after a successful session usage.
|
|
122
|
-
* It increases `usageCount` and potentially lowers the `errorScore` by the `errorScoreDecrement`.
|
|
123
|
-
*/
|
|
124
|
-
markGood(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Gets session state for persistence in KeyValueStore.
|
|
127
|
-
* @returns Represents session internal state.
|
|
128
|
-
*/
|
|
129
|
-
getState(): SessionState;
|
|
130
|
-
/**
|
|
131
|
-
* Marks session as blocked and emits event on the `SessionPool`
|
|
132
|
-
* This method should be used if the session usage was unsuccessful
|
|
133
|
-
* and you are sure that it is because of the session configuration and not any external matters.
|
|
134
|
-
* For example when server returns 403 status code.
|
|
135
|
-
* If the session does not work due to some external factors as server error such as 5XX you probably want to use `markBad` method.
|
|
136
|
-
*/
|
|
137
|
-
retire(): void;
|
|
138
|
-
/**
|
|
139
|
-
* Increases usage and error count.
|
|
140
|
-
* Should be used when the session has been used unsuccessfully. For example because of timeouts.
|
|
141
|
-
*/
|
|
142
|
-
markBad(): void;
|
|
143
|
-
/**
|
|
144
|
-
* With certain status codes: `401`, `403` or `429` we can be certain
|
|
145
|
-
* that the target website is blocking us. This function helps to do this conveniently
|
|
146
|
-
* by retiring the session when such code is received. Optionally, the default status
|
|
147
|
-
* codes can be extended in the second parameter.
|
|
148
|
-
* @param statusCode HTTP status code.
|
|
149
|
-
* @returns Whether the session was retired.
|
|
150
|
-
*/
|
|
151
|
-
retireOnBlockedStatusCodes(statusCode: number): boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Saves cookies from an HTTP response to be used with the session.
|
|
154
|
-
* It expects an object with a `headers` property that's either an `Object`
|
|
155
|
-
* (typical Node.js responses) or a `Function` (Puppeteer Response).
|
|
156
|
-
*
|
|
157
|
-
* It then parses and saves the cookies from the `set-cookie` header, if available.
|
|
158
|
-
*/
|
|
159
|
-
setCookiesFromResponse(response: ResponseLike): void;
|
|
160
|
-
/**
|
|
161
|
-
* Saves an array with cookie objects to be used with the session.
|
|
162
|
-
* The objects should be in the format that
|
|
163
|
-
* [Puppeteer uses](https://pptr.dev/#?product=Puppeteer&version=v2.0.0&show=api-pagecookiesurls),
|
|
164
|
-
* but you can also use this function to set cookies manually:
|
|
165
|
-
*
|
|
166
|
-
* ```
|
|
167
|
-
* [
|
|
168
|
-
* { name: 'cookie1', value: 'my-cookie' },
|
|
169
|
-
* { name: 'cookie2', value: 'your-cookie' }
|
|
170
|
-
* ]
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
setCookies(cookies: CookieObject[], url: string): void;
|
|
174
|
-
/**
|
|
175
|
-
* Returns cookies in a format compatible with puppeteer/playwright and ready to be used with `page.setCookie`.
|
|
176
|
-
* @param url website url. Only cookies stored for this url will be returned
|
|
177
|
-
*/
|
|
178
|
-
getCookies(url: string): CookieObject[];
|
|
179
|
-
/**
|
|
180
|
-
* Returns cookies saved with the session in the typical
|
|
181
|
-
* key1=value1; key2=value2 format, ready to be used in
|
|
182
|
-
* a cookie header or elsewhere.
|
|
183
|
-
* @returns Represents `Cookie` header.
|
|
184
|
-
*/
|
|
185
|
-
getCookieString(url: string): string;
|
|
186
|
-
/**
|
|
187
|
-
* Sets a cookie within this session for the specific URL.
|
|
188
|
-
*/
|
|
189
|
-
setCookie(rawCookie: string, url: string): void;
|
|
190
|
-
/**
|
|
191
|
-
* Sets cookies.
|
|
192
|
-
*/
|
|
193
|
-
protected _setCookies(cookies: Cookie[], url: string): void;
|
|
194
|
-
/**
|
|
195
|
-
* Checks if session is not usable. if it is not retires the session.
|
|
196
|
-
*/
|
|
197
|
-
protected _maybeSelfRetire(): void;
|
|
198
|
-
}
|
|
199
|
-
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session_pool/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAUvD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,mBAAmB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EA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