@crawlee/core 4.0.0-beta.28 → 4.0.0-beta.280

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/README.md +15 -15
  2. package/byte-utils.d.ts +17 -0
  3. package/byte-utils.js +42 -0
  4. package/configuration.d.ts +75 -167
  5. package/configuration.js +164 -140
  6. package/debug.d.ts +36 -0
  7. package/debug.js +70 -0
  8. package/errors.d.ts +40 -19
  9. package/errors.js +52 -30
  10. package/events/{event_manager.d.ts → event-manager.d.ts} +29 -6
  11. package/events/{event_manager.js → event-manager.js} +10 -9
  12. package/events/index.d.ts +3 -3
  13. package/events/index.js +2 -3
  14. package/events/{local_event_manager.d.ts → local-event-manager.d.ts} +3 -10
  15. package/events/local-event-manager.js +101 -0
  16. package/events/system-info.d.ts +38 -0
  17. package/events/system-info.js +1 -0
  18. package/index.d.ts +9 -13
  19. package/index.js +10 -12
  20. package/internal.d.ts +8 -0
  21. package/internal.js +9 -0
  22. package/iterables.d.ts +79 -0
  23. package/iterables.js +134 -0
  24. package/log.d.ts +77 -1
  25. package/log.js +134 -1
  26. package/memory-storage/consts.d.ts +4 -0
  27. package/memory-storage/consts.js +4 -0
  28. package/memory-storage/index.d.ts +1 -0
  29. package/memory-storage/index.js +1 -0
  30. package/memory-storage/memory-storage.d.ts +43 -0
  31. package/memory-storage/memory-storage.js +158 -0
  32. package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
  33. package/memory-storage/resource-clients/common/base-client.js +6 -0
  34. package/memory-storage/resource-clients/dataset.d.ts +35 -0
  35. package/memory-storage/resource-clients/dataset.js +108 -0
  36. package/memory-storage/resource-clients/key-value-store.d.ts +54 -0
  37. package/memory-storage/resource-clients/key-value-store.js +179 -0
  38. package/memory-storage/resource-clients/request-queue.d.ts +55 -0
  39. package/memory-storage/resource-clients/request-queue.js +413 -0
  40. package/memory-storage/utils.d.ts +16 -0
  41. package/memory-storage/utils.js +41 -0
  42. package/owned-or-injected.d.ts +58 -0
  43. package/owned-or-injected.js +98 -0
  44. package/package.json +23 -23
  45. package/proxy-configuration.d.ts +118 -0
  46. package/proxy-configuration.js +141 -0
  47. package/recoverable-state.d.ts +177 -0
  48. package/recoverable-state.js +268 -0
  49. package/request.d.ts +48 -101
  50. package/request.js +139 -249
  51. package/serialization.d.ts +0 -1
  52. package/serialization.js +18 -18
  53. package/{service_locator.d.ts → service-locator.d.ts} +66 -37
  54. package/service-locator.js +255 -0
  55. package/storages/batched-adds.d.ts +39 -0
  56. package/storages/batched-adds.js +81 -0
  57. package/storages/dataset.d.ts +105 -58
  58. package/storages/dataset.js +292 -151
  59. package/storages/index.d.ts +11 -12
  60. package/storages/index.js +7 -12
  61. package/storages/key-value-store-codec.d.ts +32 -0
  62. package/storages/key-value-store-codec.js +108 -0
  63. package/storages/{key_value_store.d.ts → key-value-store.d.ts} +169 -72
  64. package/storages/key-value-store.js +767 -0
  65. package/storages/request-dedup-cache.d.ts +20 -0
  66. package/storages/request-dedup-cache.js +48 -0
  67. package/storages/{request_list.d.ts → request-list.d.ts} +32 -171
  68. package/storages/{request_list.js → request-list.js} +276 -253
  69. package/storages/request-loader.d.ts +127 -0
  70. package/storages/request-loader.js +34 -0
  71. package/storages/request-manager-tandem.d.ts +82 -0
  72. package/storages/request-manager-tandem.js +200 -0
  73. package/storages/request-manager.d.ts +119 -0
  74. package/storages/request-manager.js +1 -0
  75. package/storages/{request_provider.d.ts → request-queue.d.ts} +127 -161
  76. package/storages/request-queue.js +871 -0
  77. package/storages/storage-instance-manager.d.ts +86 -0
  78. package/storages/storage-instance-manager.js +256 -0
  79. package/storages/storage-stats.d.ts +48 -0
  80. package/storages/storage-stats.js +29 -0
  81. package/storages/transaction.d.ts +270 -0
  82. package/storages/transaction.js +296 -0
  83. package/storages/utils.d.ts +59 -11
  84. package/storages/utils.js +76 -17
  85. package/system-info/cpu-info.d.ts +67 -0
  86. package/system-info/cpu-info.js +216 -0
  87. package/system-info/memory-info.d.ts +31 -0
  88. package/system-info/memory-info.js +115 -0
  89. package/system-info/ps-tree.d.ts +17 -0
  90. package/system-info/ps-tree.js +144 -0
  91. package/system-info/runtime.d.ts +14 -0
  92. package/system-info/runtime.js +80 -0
  93. package/typedefs.d.ts +0 -6
  94. package/typedefs.js +0 -1
  95. package/url.d.ts +9 -0
  96. package/url.js +11 -0
  97. package/validators.d.ts +23 -18
  98. package/validators.js +14 -18
  99. package/autoscaling/autoscaled_pool.d.ts +0 -298
  100. package/autoscaling/autoscaled_pool.d.ts.map +0 -1
  101. package/autoscaling/autoscaled_pool.js +0 -527
  102. package/autoscaling/autoscaled_pool.js.map +0 -1
  103. package/autoscaling/index.d.ts +0 -4
  104. package/autoscaling/index.d.ts.map +0 -1
  105. package/autoscaling/index.js +0 -4
  106. package/autoscaling/index.js.map +0 -1
  107. package/autoscaling/snapshotter.d.ts +0 -179
  108. package/autoscaling/snapshotter.d.ts.map +0 -1
  109. package/autoscaling/snapshotter.js +0 -279
  110. package/autoscaling/snapshotter.js.map +0 -1
  111. package/autoscaling/system_status.d.ts +0 -178
  112. package/autoscaling/system_status.d.ts.map +0 -1
  113. package/autoscaling/system_status.js +0 -168
  114. package/autoscaling/system_status.js.map +0 -1
  115. package/configuration.d.ts.map +0 -1
  116. package/configuration.js.map +0 -1
  117. package/cookie_utils.d.ts +0 -43
  118. package/cookie_utils.d.ts.map +0 -1
  119. package/cookie_utils.js +0 -111
  120. package/cookie_utils.js.map +0 -1
  121. package/crawlers/context_pipeline.d.ts +0 -61
  122. package/crawlers/context_pipeline.d.ts.map +0 -1
  123. package/crawlers/context_pipeline.js +0 -99
  124. package/crawlers/context_pipeline.js.map +0 -1
  125. package/crawlers/crawler_commons.d.ts +0 -191
  126. package/crawlers/crawler_commons.d.ts.map +0 -1
  127. package/crawlers/crawler_commons.js +0 -108
  128. package/crawlers/crawler_commons.js.map +0 -1
  129. package/crawlers/crawler_utils.d.ts +0 -10
  130. package/crawlers/crawler_utils.d.ts.map +0 -1
  131. package/crawlers/crawler_utils.js +0 -12
  132. package/crawlers/crawler_utils.js.map +0 -1
  133. package/crawlers/error_snapshotter.d.ts +0 -60
  134. package/crawlers/error_snapshotter.d.ts.map +0 -1
  135. package/crawlers/error_snapshotter.js +0 -118
  136. package/crawlers/error_snapshotter.js.map +0 -1
  137. package/crawlers/error_tracker.d.ts +0 -55
  138. package/crawlers/error_tracker.d.ts.map +0 -1
  139. package/crawlers/error_tracker.js +0 -309
  140. package/crawlers/error_tracker.js.map +0 -1
  141. package/crawlers/index.d.ts +0 -7
  142. package/crawlers/index.d.ts.map +0 -1
  143. package/crawlers/index.js +0 -7
  144. package/crawlers/index.js.map +0 -1
  145. package/crawlers/internals/types.d.ts +0 -8
  146. package/crawlers/internals/types.d.ts.map +0 -1
  147. package/crawlers/internals/types.js +0 -2
  148. package/crawlers/internals/types.js.map +0 -1
  149. package/crawlers/statistics.d.ts +0 -204
  150. package/crawlers/statistics.d.ts.map +0 -1
  151. package/crawlers/statistics.js +0 -350
  152. package/crawlers/statistics.js.map +0 -1
  153. package/enqueue_links/enqueue_links.d.ts +0 -254
  154. package/enqueue_links/enqueue_links.d.ts.map +0 -1
  155. package/enqueue_links/enqueue_links.js +0 -268
  156. package/enqueue_links/enqueue_links.js.map +0 -1
  157. package/enqueue_links/index.d.ts +0 -3
  158. package/enqueue_links/index.d.ts.map +0 -1
  159. package/enqueue_links/index.js +0 -3
  160. package/enqueue_links/index.js.map +0 -1
  161. package/enqueue_links/shared.d.ts +0 -84
  162. package/enqueue_links/shared.d.ts.map +0 -1
  163. package/enqueue_links/shared.js +0 -219
  164. package/enqueue_links/shared.js.map +0 -1
  165. package/errors.d.ts.map +0 -1
  166. package/errors.js.map +0 -1
  167. package/events/event_manager.d.ts.map +0 -1
  168. package/events/event_manager.js.map +0 -1
  169. package/events/index.d.ts.map +0 -1
  170. package/events/index.js.map +0 -1
  171. package/events/local_event_manager.d.ts.map +0 -1
  172. package/events/local_event_manager.js +0 -93
  173. package/events/local_event_manager.js.map +0 -1
  174. package/index.d.ts.map +0 -1
  175. package/index.js.map +0 -1
  176. package/log.d.ts.map +0 -1
  177. package/log.js.map +0 -1
  178. package/proxy_configuration.d.ts +0 -169
  179. package/proxy_configuration.d.ts.map +0 -1
  180. package/proxy_configuration.js +0 -247
  181. package/proxy_configuration.js.map +0 -1
  182. package/recoverable_state.d.ts +0 -122
  183. package/recoverable_state.d.ts.map +0 -1
  184. package/recoverable_state.js +0 -138
  185. package/recoverable_state.js.map +0 -1
  186. package/request.d.ts.map +0 -1
  187. package/request.js.map +0 -1
  188. package/router.d.ts +0 -134
  189. package/router.d.ts.map +0 -1
  190. package/router.js +0 -164
  191. package/router.js.map +0 -1
  192. package/serialization.d.ts.map +0 -1
  193. package/serialization.js.map +0 -1
  194. package/service_locator.d.ts.map +0 -1
  195. package/service_locator.js +0 -252
  196. package/service_locator.js.map +0 -1
  197. package/session_pool/consts.d.ts +0 -4
  198. package/session_pool/consts.d.ts.map +0 -1
  199. package/session_pool/consts.js +0 -4
  200. package/session_pool/consts.js.map +0 -1
  201. package/session_pool/errors.d.ts +0 -8
  202. package/session_pool/errors.d.ts.map +0 -1
  203. package/session_pool/errors.js +0 -12
  204. package/session_pool/errors.js.map +0 -1
  205. package/session_pool/events.d.ts +0 -3
  206. package/session_pool/events.d.ts.map +0 -1
  207. package/session_pool/events.js +0 -3
  208. package/session_pool/events.js.map +0 -1
  209. package/session_pool/index.d.ts +0 -6
  210. package/session_pool/index.d.ts.map +0 -1
  211. package/session_pool/index.js +0 -6
  212. package/session_pool/index.js.map +0 -1
  213. package/session_pool/session.d.ts +0 -186
  214. package/session_pool/session.d.ts.map +0 -1
  215. package/session_pool/session.js +0 -278
  216. package/session_pool/session.js.map +0 -1
  217. package/session_pool/session_pool.d.ts +0 -256
  218. package/session_pool/session_pool.d.ts.map +0 -1
  219. package/session_pool/session_pool.js +0 -386
  220. package/session_pool/session_pool.js.map +0 -1
  221. package/storages/access_checking.d.ts +0 -13
  222. package/storages/access_checking.d.ts.map +0 -1
  223. package/storages/access_checking.js +0 -14
  224. package/storages/access_checking.js.map +0 -1
  225. package/storages/dataset.d.ts.map +0 -1
  226. package/storages/dataset.js.map +0 -1
  227. package/storages/index.d.ts.map +0 -1
  228. package/storages/index.js.map +0 -1
  229. package/storages/key_value_store.d.ts.map +0 -1
  230. package/storages/key_value_store.js +0 -513
  231. package/storages/key_value_store.js.map +0 -1
  232. package/storages/request_list.d.ts.map +0 -1
  233. package/storages/request_list.js.map +0 -1
  234. package/storages/request_list_adapter.d.ts +0 -58
  235. package/storages/request_list_adapter.d.ts.map +0 -1
  236. package/storages/request_list_adapter.js +0 -81
  237. package/storages/request_list_adapter.js.map +0 -1
  238. package/storages/request_manager_tandem.d.ts +0 -68
  239. package/storages/request_manager_tandem.d.ts.map +0 -1
  240. package/storages/request_manager_tandem.js +0 -124
  241. package/storages/request_manager_tandem.js.map +0 -1
  242. package/storages/request_provider.d.ts.map +0 -1
  243. package/storages/request_provider.js +0 -592
  244. package/storages/request_provider.js.map +0 -1
  245. package/storages/request_queue.d.ts +0 -128
  246. package/storages/request_queue.d.ts.map +0 -1
  247. package/storages/request_queue.js +0 -320
  248. package/storages/request_queue.js.map +0 -1
  249. package/storages/request_queue_v2.d.ts +0 -87
  250. package/storages/request_queue_v2.d.ts.map +0 -1
  251. package/storages/request_queue_v2.js +0 -437
  252. package/storages/request_queue_v2.js.map +0 -1
  253. package/storages/sitemap_request_list.d.ts +0 -245
  254. package/storages/sitemap_request_list.d.ts.map +0 -1
  255. package/storages/sitemap_request_list.js +0 -431
  256. package/storages/sitemap_request_list.js.map +0 -1
  257. package/storages/storage_manager.d.ts +0 -60
  258. package/storages/storage_manager.d.ts.map +0 -1
  259. package/storages/storage_manager.js +0 -95
  260. package/storages/storage_manager.js.map +0 -1
  261. package/storages/utils.d.ts.map +0 -1
  262. package/storages/utils.js.map +0 -1
  263. package/typedefs.d.ts.map +0 -1
  264. package/typedefs.js.map +0 -1
  265. package/validators.d.ts.map +0 -1
  266. package/validators.js.map +0 -1
@@ -1,278 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import ow from 'ow';
3
- import { CookieJar } from 'tough-cookie';
4
- import { cryptoRandomObjectId } from '@apify/utilities';
5
- import { browserPoolCookieToToughCookie, getCookiesFromResponse, getDefaultCookieExpirationDate, toughCookieToBrowserPoolCookie, } from '../cookie_utils.js';
6
- import { log as defaultLog } from '../log.js';
7
- import { EVENT_SESSION_RETIRED } from './events.js';
8
- /**
9
- * Sessions are used to store information such as cookies and can be used for generating fingerprints and proxy sessions.
10
- * You can imagine each session as a specific user, with its own cookies, IP (via proxy) and potentially a unique browser fingerprint.
11
- * Session internal state can be enriched with custom user data for example some authorization tokens and specific headers in general.
12
- * @category Scaling
13
- */
14
- export class Session {
15
- id;
16
- maxAgeSecs;
17
- userData;
18
- _maxErrorScore;
19
- _errorScoreDecrement;
20
- _createdAt;
21
- _expiresAt;
22
- _usageCount;
23
- _maxUsageCount;
24
- sessionPool;
25
- _errorScore;
26
- _proxyInfo;
27
- _cookieJar;
28
- log;
29
- get errorScore() {
30
- return this._errorScore;
31
- }
32
- get usageCount() {
33
- return this._usageCount;
34
- }
35
- get maxErrorScore() {
36
- return this._maxErrorScore;
37
- }
38
- get errorScoreDecrement() {
39
- return this._errorScoreDecrement;
40
- }
41
- get expiresAt() {
42
- return this._expiresAt;
43
- }
44
- get createdAt() {
45
- return this._createdAt;
46
- }
47
- get maxUsageCount() {
48
- return this._maxUsageCount;
49
- }
50
- get cookieJar() {
51
- return this._cookieJar;
52
- }
53
- get proxyInfo() {
54
- return this._proxyInfo;
55
- }
56
- /**
57
- * Session configuration.
58
- */
59
- constructor(options) {
60
- ow(options, ow.object.exactShape({
61
- sessionPool: ow.object.instanceOf(EventEmitter),
62
- id: ow.optional.string,
63
- cookieJar: ow.optional.object,
64
- proxyInfo: ow.optional.object,
65
- maxAgeSecs: ow.optional.number,
66
- userData: ow.optional.object,
67
- maxErrorScore: ow.optional.number,
68
- errorScoreDecrement: ow.optional.number,
69
- createdAt: ow.optional.date,
70
- expiresAt: ow.optional.date,
71
- usageCount: ow.optional.number,
72
- errorScore: ow.optional.number,
73
- maxUsageCount: ow.optional.number,
74
- log: ow.optional.object,
75
- }));
76
- const { sessionPool, id = `session_${cryptoRandomObjectId(10)}`, cookieJar = new CookieJar(), proxyInfo = undefined, maxAgeSecs = 3000, userData = {}, maxErrorScore = 3, errorScoreDecrement = 0.5, createdAt = new Date(), usageCount = 0, errorScore = 0, maxUsageCount = 50, log = defaultLog, } = options;
77
- const { expiresAt = getDefaultCookieExpirationDate(maxAgeSecs) } = options;
78
- this.log = log.child({ prefix: 'Session' });
79
- this._cookieJar = cookieJar.setCookie ? cookieJar : CookieJar.fromJSON(JSON.stringify(cookieJar));
80
- this._proxyInfo = proxyInfo;
81
- this.id = id;
82
- this.maxAgeSecs = maxAgeSecs;
83
- this.userData = userData;
84
- this._maxErrorScore = maxErrorScore;
85
- this._errorScoreDecrement = errorScoreDecrement;
86
- // Internal
87
- this._expiresAt = expiresAt;
88
- this._createdAt = createdAt;
89
- this._usageCount = usageCount; // indicates how many times the session has been used
90
- this._errorScore = errorScore; // indicates number of markBaded request with the session
91
- this._maxUsageCount = maxUsageCount;
92
- this.sessionPool = sessionPool;
93
- }
94
- /**
95
- * Indicates whether the session is blocked.
96
- * Session is blocked once it reaches the `maxErrorScore`.
97
- */
98
- isBlocked() {
99
- return this.errorScore >= this.maxErrorScore;
100
- }
101
- /**
102
- * Indicates whether the session is expired.
103
- * Session expiration is determined by the `maxAgeSecs`.
104
- * Once the session is older than `createdAt + maxAgeSecs` the session is considered expired.
105
- */
106
- isExpired() {
107
- return this.expiresAt <= new Date();
108
- }
109
- /**
110
- * Indicates whether the session is used maximum number of times.
111
- * Session maximum usage count can be changed by `maxUsageCount` parameter.
112
- */
113
- isMaxUsageCountReached() {
114
- return this.usageCount >= this.maxUsageCount;
115
- }
116
- /**
117
- * Indicates whether the session can be used for next requests.
118
- * Session is usable when it is not expired, not blocked and the maximum usage count has not be reached.
119
- */
120
- isUsable() {
121
- return !this.isBlocked() && !this.isExpired() && !this.isMaxUsageCountReached();
122
- }
123
- /**
124
- * This method should be called after a successful session usage.
125
- * It increases `usageCount` and potentially lowers the `errorScore` by the `errorScoreDecrement`.
126
- */
127
- markGood() {
128
- this._usageCount += 1;
129
- if (this._errorScore > 0) {
130
- this._errorScore -= this._errorScoreDecrement;
131
- }
132
- this._maybeSelfRetire();
133
- }
134
- /**
135
- * Gets session state for persistence in KeyValueStore.
136
- * @returns Represents session internal state.
137
- */
138
- getState() {
139
- return {
140
- id: this.id,
141
- cookieJar: this.cookieJar.toJSON(),
142
- proxyInfo: this._proxyInfo,
143
- userData: this.userData,
144
- maxErrorScore: this.maxErrorScore,
145
- errorScoreDecrement: this.errorScoreDecrement,
146
- expiresAt: this.expiresAt.toISOString(),
147
- createdAt: this.createdAt.toISOString(),
148
- usageCount: this.usageCount,
149
- maxUsageCount: this.maxUsageCount,
150
- errorScore: this.errorScore,
151
- };
152
- }
153
- /**
154
- * Marks session as blocked and emits event on the `SessionPool`
155
- * This method should be used if the session usage was unsuccessful
156
- * and you are sure that it is because of the session configuration and not any external matters.
157
- * For example when server returns 403 status code.
158
- * If the session does not work due to some external factors as server error such as 5XX you probably want to use `markBad` method.
159
- */
160
- retire() {
161
- // mark it as an invalid by increasing the error score count.
162
- this._errorScore += this._maxErrorScore;
163
- this._usageCount += 1;
164
- // emit event so we can retire browser in puppeteer pool
165
- this.sessionPool.emit(EVENT_SESSION_RETIRED, this);
166
- }
167
- /**
168
- * Increases usage and error count.
169
- * Should be used when the session has been used unsuccessfully. For example because of timeouts.
170
- */
171
- markBad() {
172
- this._errorScore += 1;
173
- this._usageCount += 1;
174
- this._maybeSelfRetire();
175
- }
176
- /**
177
- * With certain status codes: `401`, `403` or `429` we can be certain
178
- * that the target website is blocking us. This function helps to do this conveniently
179
- * by retiring the session when such code is received. Optionally, the default status
180
- * codes can be extended in the second parameter.
181
- * @param statusCode HTTP status code.
182
- * @returns Whether the session was retired.
183
- */
184
- retireOnBlockedStatusCodes(statusCode) {
185
- // eslint-disable-next-line dot-notation -- accessing private property
186
- const isBlocked = this.sessionPool['blockedStatusCodes'].includes(statusCode);
187
- if (isBlocked) {
188
- this.retire();
189
- }
190
- return isBlocked;
191
- }
192
- /**
193
- * Saves cookies from an HTTP response to be used with the session.
194
- * It expects an object with a `headers` property that's either an `Object`
195
- * (typical Node.js responses) or a `Function` (Puppeteer Response).
196
- *
197
- * It then parses and saves the cookies from the `set-cookie` header, if available.
198
- */
199
- setCookiesFromResponse(response) {
200
- try {
201
- const cookies = getCookiesFromResponse(response).filter((c) => c);
202
- this._setCookies(cookies, response.url);
203
- }
204
- catch (e) {
205
- const err = e;
206
- // if invalid Cookie header is provided just log the exception.
207
- this.log.exception(err, 'Could not get cookies from response');
208
- }
209
- }
210
- /**
211
- * Saves an array with cookie objects to be used with the session.
212
- * The objects should be in the format that
213
- * [Puppeteer uses](https://pptr.dev/#?product=Puppeteer&version=v2.0.0&show=api-pagecookiesurls),
214
- * but you can also use this function to set cookies manually:
215
- *
216
- * ```
217
- * [
218
- * { name: 'cookie1', value: 'my-cookie' },
219
- * { name: 'cookie2', value: 'your-cookie' }
220
- * ]
221
- * ```
222
- */
223
- setCookies(cookies, url) {
224
- const normalizedCookies = cookies.map((c) => browserPoolCookieToToughCookie(c, this.maxAgeSecs));
225
- this._setCookies(normalizedCookies, url);
226
- }
227
- /**
228
- * Returns cookies in a format compatible with puppeteer/playwright and ready to be used with `page.setCookie`.
229
- * @param url website url. Only cookies stored for this url will be returned
230
- */
231
- getCookies(url) {
232
- const cookies = this.cookieJar.getCookiesSync(url);
233
- return cookies.map((c) => toughCookieToBrowserPoolCookie(c));
234
- }
235
- /**
236
- * Returns cookies saved with the session in the typical
237
- * key1=value1; key2=value2 format, ready to be used in
238
- * a cookie header or elsewhere.
239
- * @returns Represents `Cookie` header.
240
- */
241
- getCookieString(url) {
242
- return this.cookieJar.getCookieStringSync(url, {});
243
- }
244
- /**
245
- * Sets a cookie within this session for the specific URL.
246
- */
247
- setCookie(rawCookie, url) {
248
- this.cookieJar.setCookieSync(rawCookie, url);
249
- }
250
- /**
251
- * Sets cookies.
252
- */
253
- _setCookies(cookies, url) {
254
- const errorMessages = [];
255
- for (const cookie of cookies) {
256
- try {
257
- this.cookieJar.setCookieSync(cookie, url, { ignoreError: false });
258
- }
259
- catch (e) {
260
- const err = e;
261
- errorMessages.push(err.message);
262
- }
263
- }
264
- // if invalid cookies are provided just log the exception. No need to retry the request automatically.
265
- if (errorMessages.length) {
266
- this.log.debug('Could not set cookies.', { errorMessages });
267
- }
268
- }
269
- /**
270
- * Checks if session is not usable. if it is not retires the session.
271
- */
272
- _maybeSelfRetire() {
273
- if (!this.isUsable()) {
274
- this.retire();
275
- }
276
- }
277
- }
278
- //# sourceMappingURL=session.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session_pool/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EACH,8BAA8B,EAC9B,sBAAsB,EACtB,8BAA8B,EAC9B,8BAA8B,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA4DpD;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IACP,EAAE,CAAS;IACZ,UAAU,CAAS;IAC3B,QAAQ,CAAa;IACb,cAAc,CAAS;IACvB,oBAAoB,CAAS;IAC7B,UAAU,CAAO;IACjB,UAAU,CAAO;IACjB,WAAW,CAAS;IACpB,c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,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,MAAM,GAAG,GAAG,CAAU,CAAC;gBACvB,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;QAED,sGAAsG;QACtG,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;IAED;;OAEG;IACO,gBAAgB;QACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;IACL,CAAC;CACJ"}
@@ -1,256 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import type { Log } from '@apify/log';
3
- import type { PersistenceOptions } from '../crawlers/statistics.js';
4
- import type { EventManager } from '../events/event_manager.js';
5
- import { KeyValueStore } from '../storages/key_value_store.js';
6
- import type { SessionOptions } from './session.js';
7
- import { Session } from './session.js';
8
- /**
9
- * Factory user-function which creates customized {@link Session} instances.
10
- */
11
- export interface CreateSession {
12
- /**
13
- * @param sessionPool Pool requesting the new session.
14
- * @param options
15
- */
16
- (sessionPool: SessionPool, options?: {
17
- sessionOptions?: SessionOptions;
18
- }): Session | Promise<Session>;
19
- }
20
- export interface SessionPoolOptions {
21
- /**
22
- * Maximum size of the pool. Indicates how many sessions are rotated.
23
- * @default 1000
24
- */
25
- maxPoolSize?: number;
26
- /** The configuration options for {@link Session} instances. */
27
- sessionOptions?: SessionOptions;
28
- /** Name or Id of `KeyValueStore` where is the `SessionPool` state stored. */
29
- persistStateKeyValueStoreId?: string;
30
- /**
31
- * Session pool persists it's state under this key in Key value store.
32
- * @default SESSION_POOL_STATE
33
- */
34
- persistStateKey?: string;
35
- /**
36
- * Custom function that should return a `Session` instance, or a promise resolving to such instance.
37
- * Any error thrown from this function will terminate the process.
38
- * Function receives `SessionPool` instance as a parameter
39
- */
40
- createSessionFunction?: CreateSession;
41
- /**
42
- * Specifies which response status codes are considered as blocked.
43
- * Session connected to such request will be marked as retired.
44
- * @default [401, 403, 429]
45
- */
46
- blockedStatusCodes?: number[];
47
- /** @internal */
48
- log?: Log;
49
- /**
50
- * Control how and when to persist the state of the session pool.
51
- */
52
- persistenceOptions?: PersistenceOptions;
53
- }
54
- /**
55
- * Handles the rotation, creation and persistence of user-like sessions.
56
- * Creates a pool of {@link Session} instances, that are randomly rotated.
57
- * When some session is marked as blocked, it is removed and new one is created instead (the pool never returns an unusable session).
58
- * Learn more in the {@doclink guides/session-management | Session management guide}.
59
- *
60
- * You can create one by calling the {@link SessionPool.open} function.
61
- *
62
- * Session pool is already integrated into crawlers, and it can significantly improve your scraper
63
- * performance with just 2 lines of code.
64
- *
65
- * **Example usage:**
66
- *
67
- * ```javascript
68
- * const crawler = new CheerioCrawler({
69
- * useSessionPool: true,
70
- * persistCookiesPerSession: true,
71
- * // ...
72
- * })
73
- * ```
74
- *
75
- * You can configure the pool with many options. See the {@link SessionPoolOptions}.
76
- * Session pool is by default persisted in default {@link KeyValueStore}.
77
- * If you want to have one pool for all runs you have to specify
78
- * {@link SessionPoolOptions.persistStateKeyValueStoreId}.
79
- *
80
- * **Advanced usage:**
81
- *
82
- * ```javascript
83
- * const sessionPool = await SessionPool.open({
84
- * maxPoolSize: 25,
85
- * sessionOptions:{
86
- * maxAgeSecs: 10,
87
- * maxUsageCount: 150, // for example when you know that the site blocks after 150 requests.
88
- * },
89
- * persistStateKeyValueStoreId: 'my-key-value-store-for-sessions',
90
- * persistStateKey: 'my-session-pool',
91
- * });
92
- *
93
- * // Get random session from the pool
94
- * const session1 = await sessionPool.getSession();
95
- * const session2 = await sessionPool.getSession();
96
- * const session3 = await sessionPool.getSession();
97
- *
98
- * // Now you can mark the session either failed or successful
99
- *
100
- * // Marks session as bad after unsuccessful usage -> it increases error count (soft retire)
101
- * session1.markBad()
102
- *
103
- * // Marks as successful.
104
- * session2.markGood()
105
- *
106
- * // Retires session -> session is removed from the pool
107
- * session3.retire()
108
- *
109
- * ```
110
- *
111
- * **Default session allocation flow:*
112
- * 1. Until the `SessionPool` reaches `maxPoolSize`, new sessions are created, provided to the user and added to the pool
113
- * 2. Blocked/retired sessions stay in the pool but are never provided to the user
114
- * 3. Once the pool is full (live plus blocked session count reaches `maxPoolSize`), a random session from the pool is provided.
115
- * 4. If a blocked session would be picked, instead all blocked sessions are evicted from the pool and a new session is created and provided
116
- *
117
- * @category Scaling
118
- */
119
- export declare class SessionPool extends EventEmitter {
120
- protected log: Log;
121
- protected maxPoolSize: number;
122
- protected createSessionFunction: CreateSession;
123
- protected keyValueStore: KeyValueStore;
124
- protected sessions: Session[];
125
- protected sessionMap: Map<string, Session>;
126
- protected sessionOptions: SessionOptions;
127
- protected persistStateKeyValueStoreId?: string;
128
- protected persistStateKey: string;
129
- protected _listener: () => Promise<void>;
130
- protected events: EventManager;
131
- protected readonly blockedStatusCodes: number[];
132
- protected persistenceOptions: PersistenceOptions;
133
- protected isInitialized: boolean;
134
- private queue;
135
- /**
136
- * @internal
137
- */
138
- constructor(options?: SessionPoolOptions);
139
- /**
140
- * Gets count of usable sessions in the pool.
141
- */
142
- get usableSessionsCount(): number;
143
- /**
144
- * Gets count of retired sessions in the pool.
145
- */
146
- get retiredSessionsCount(): number;
147
- /**
148
- * Starts periodic state persistence and potentially loads SessionPool state from {@link KeyValueStore}.
149
- * It is called automatically by the {@link SessionPool.open} function.
150
- */
151
- initialize(): Promise<void>;
152
- /**
153
- * Adds a new session to the session pool. The pool automatically creates sessions up to the maximum size of the pool,
154
- * but this allows you to add more sessions once the max pool size is reached.
155
- * This also allows you to add session with overridden session options (e.g. with specific session id).
156
- * @param [options] The configuration options for the session being added to the session pool.
157
- */
158
- addSession(options?: Session | SessionOptions): Promise<void>;
159
- /**
160
- * Adds a new session to the session pool. The pool automatically creates sessions up to the maximum size of the pool,
161
- * but this allows you to add more sessions once the max pool size is reached.
162
- * This also allows you to add session with overridden session options (e.g. with specific session id).
163
- * @param [options] The configuration options for the session being added to the session pool.
164
- */
165
- newSession(sessionOptions?: SessionOptions): Promise<Session>;
166
- /**
167
- * Gets session.
168
- * If there is space for new session, it creates and returns new session.
169
- * If the session pool is full, it picks a session from the pool,
170
- * If the picked session is usable it is returned, otherwise it creates and returns a new one.
171
- */
172
- getSession(): Promise<Session>;
173
- /**
174
- * Gets session based on the provided session id or `undefined.
175
- */
176
- getSession(sessionId: string): Promise<Session>;
177
- /**
178
- * @param options - Override the persistence options provided in the constructor
179
- */
180
- resetStore(options?: PersistenceOptions): Promise<void>;
181
- /**
182
- * Returns an object representing the internal state of the `SessionPool` instance.
183
- * Note that the object's fields can change in future releases.
184
- */
185
- getState(): {
186
- usableSessionsCount: number;
187
- retiredSessionsCount: number;
188
- // @ts-ignore optional peer dependency or compatibility with es2022
189
- sessions: import("@crawlee/types").SessionState[];
190
- };
191
- /**
192
- * Persists the current state of the `SessionPool` into the default {@link KeyValueStore}.
193
- * The state is persisted automatically in regular intervals.
194
- * @param options - Override the persistence options provided in the constructor
195
- */
196
- persistState(options?: PersistenceOptions): Promise<void>;
197
- /**
198
- * Removes listener from `persistState` event.
199
- * This function should be called after you are done with using the `SessionPool` instance.
200
- */
201
- teardown(): Promise<void>;
202
- /**
203
- * SessionPool should not work before initialization.
204
- */
205
- protected _throwIfNotInitialized(): void;
206
- /**
207
- * Removes retired `Session` instances from `SessionPool`.
208
- */
209
- protected _removeRetiredSessions(): void;
210
- /**
211
- * Adds `Session` instance to `SessionPool`.
212
- * @param newSession `Session` instance to be added.
213
- */
214
- protected _addSession(newSession: Session): void;
215
- /**
216
- * Gets random index.
217
- */
218
- protected _getRandomIndex(): number;
219
- /**
220
- * Creates new session without any extra behavior.
221
- * @param sessionPool
222
- * @param [options]
223
- * @param [options.sessionOptions] The configuration options for the session being created.
224
- * @returns New session.
225
- */
226
- protected _defaultCreateSessionFunction(sessionPool: SessionPool, options?: {
227
- sessionOptions?: SessionOptions;
228
- }): Promise<Session>;
229
- /**
230
- * Creates new session and adds it to the pool.
231
- * @returns Newly created `Session` instance.
232
- */
233
- protected _createSession(): Promise<Session>;
234
- /**
235
- * Decides whether there is enough space for creating new session.
236
- */
237
- protected _hasSpaceForSession(): boolean;
238
- /**
239
- * Picks random session from the `SessionPool`.
240
- * @returns Picked `Session`.
241
- */
242
- protected _pickSession(): Session;
243
- /**
244
- * Potentially loads `SessionPool`.
245
- * If the state was persisted it loads the `SessionPool` from the persisted state.
246
- */
247
- protected _maybeLoadSessionPool(): Promise<void>;
248
- /**
249
- * Opens a SessionPool and returns a promise resolving to an instance
250
- * of the {@link SessionPool} class that is already initialized.
251
- *
252
- * For more details and code examples, see the {@link SessionPool} class.
253
- */
254
- static open(options?: SessionPoolOptions): Promise<SessionPool>;
255
- }
256
- //# sourceMappingURL=session_pool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session_pool.d.ts","sourceRoot":"","sources":["../../src/session_pool/session_pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,cAAc,CAAA;KAAE,GAA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