@crawlee/core 4.0.0-beta.141 → 4.0.0-beta.143

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/core",
3
- "version": "4.0.0-beta.141",
3
+ "version": "4.0.0-beta.143",
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": ">=22.0.0"
@@ -52,10 +52,10 @@
52
52
  "@apify/log": "^2.5.18",
53
53
  "@apify/timeout": "^0.4.4",
54
54
  "@apify/utilities": "^2.15.5",
55
- "@crawlee/fs-storage": "4.0.0-beta.141",
56
- "@crawlee/http-client": "4.0.0-beta.141",
57
- "@crawlee/types": "4.0.0-beta.141",
58
- "@crawlee/utils": "4.0.0-beta.141",
55
+ "@crawlee/fs-storage": "4.0.0-beta.143",
56
+ "@crawlee/http-client": "4.0.0-beta.143",
57
+ "@crawlee/types": "4.0.0-beta.143",
58
+ "@crawlee/utils": "4.0.0-beta.143",
59
59
  "@sapphire/async-queue": "^1.5.5",
60
60
  "@standard-schema/spec": "^1.0.0",
61
61
  "@vladfrangu/async_event_emitter": "^2.4.6",
@@ -78,5 +78,5 @@
78
78
  }
79
79
  }
80
80
  },
81
- "gitHead": "6f97ccc5beda6b4ec0455b26323dba311a5799e4"
81
+ "gitHead": "d44b4c37b5acd824c2093542f878266feb6214ea"
82
82
  }
@@ -28,7 +28,10 @@ export interface SessionOptions {
28
28
  errorScoreDecrement?: number;
29
29
  /** Date of creation. */
30
30
  createdAt?: Date;
31
- /** Date of expiration. */
31
+ /**
32
+ * Date of expiration.
33
+ * @default createdAt + maxAgeSecs
34
+ */
32
35
  expiresAt?: Date;
33
36
  /**
34
37
  * Indicates how many times the session has been used.
@@ -1,7 +1,6 @@
1
1
  import { CookieJar } from 'tough-cookie';
2
2
  import { z } from 'zod';
3
3
  import { cryptoRandomObjectId } from '@apify/utilities';
4
- import { getDefaultCookieExpirationDate } from '../cookie_utils.js';
5
4
  import { serviceLocator } from '../service_locator.js';
6
5
  import { parseArgument, schemas, validators } from '../validators.js';
7
6
  // `schemas.anyObject` passes values through by reference (object schemas return a pruned plain
@@ -88,7 +87,9 @@ export class Session {
88
87
  * Session configuration.
89
88
  */
90
89
  constructor(options = {}) {
91
- const { id, cookieJar, proxyInfo, maxAgeSecs, userData, maxErrorScore, errorScoreDecrement, createdAt, usageCount, errorScore, maxUsageCount, retired, log, fingerprint, expiresAt = getDefaultCookieExpirationDate(maxAgeSecs), } = parseArgument(options, sessionOptionsSchema);
90
+ const { id, cookieJar, proxyInfo, maxAgeSecs, userData, maxErrorScore, errorScoreDecrement, createdAt, usageCount, errorScore, maxUsageCount, retired, log, fingerprint,
91
+ // Anchored to `createdAt` rather than to "now", so the documented `createdAt + maxAgeSecs` holds.
92
+ expiresAt = new Date(createdAt.getTime() + maxAgeSecs * 1000), } = parseArgument(options, sessionOptionsSchema);
92
93
  this.#log = log.child({ prefix: 'Session' });
93
94
  this.#cookieJar = cookieJar.setCookie ? cookieJar : CookieJar.fromJSON(JSON.stringify(cookieJar));
94
95
  this.#proxyInfo = proxyInfo;
@@ -3,7 +3,7 @@ import type { PersistenceOptions } from '../crawlers/statistics.js';
3
3
  import type { CrawleeLogger } from '../log.js';
4
4
  import type { SessionOptions } from './session.js';
5
5
  import { Session } from './session.js';
6
- declare const SESSION_REUSE_STRATEGIES: readonly ["random", "round-robin", "use-until-failure"];
6
+ declare const SESSION_REUSE_STRATEGIES: readonly ['random', 'round-robin', 'use-until-failure'];
7
7
  export type SessionReuseStrategy = (typeof SESSION_REUSE_STRATEGIES)[number];
8
8
  /**
9
9
  * Factory user-function which creates customized {@link Session} instances.