@crawlee/basic 4.0.0-beta.85 → 4.0.0-beta.86

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.
@@ -1,4 +1,4 @@
1
- import type { AddRequestsBatchedOptions, AddRequestsBatchedResult, AutoscaledPoolOptions, Configuration, CrawleeLogger, CrawlingContext, DatasetExportOptions, EnqueueLinksOptions, EventManager, FinalStatistics, GetUserDataFromRequest, IProxyConfiguration, IRequestLoader, IRequestManager, Request, RequestsLike, RouterHandler, RouterRoutes, SkippedRequestCallback, Source, StatisticsOptions, StatisticState, StorageIdentifier } from '@crawlee/core';
1
+ import type { AddRequestsBatchedOptions, AddRequestsBatchedResult, AutoscaledPoolOptions, Configuration, CrawleeLogger, CrawlingContext, DatasetExportOptions, EnqueueLinksOptions, EventManager, FinalStatistics, GetUserDataFromRequest, IProxyConfiguration, IRequestLoader, IRequestManager, Request, RequestsLike, RouterHandler, RouterRoutes, SkippedRequestCallback, Source, StatisticsOptions, StatisticState, StorageIdentifier, TypedRequestsLike } from '@crawlee/core';
2
2
  import { AutoscaledPool, ContextPipeline, Dataset, RequestQueue, Statistics } from '@crawlee/core';
3
3
  import type { Awaitable, BaseHttpClient, BatchAddRequestsResult, Dictionary, ISession, ISessionPool, ProxyInfo, SetStatusMessageOptions, StorageBackend } from '@crawlee/types';
4
4
  import { RobotsTxtFile } from '@crawlee/utils';
@@ -16,17 +16,17 @@ export type RequestHandler<Context extends CrawlingContext = CrawlingContext> =
16
16
  * difference between `BaseContext` and `ExtendedContext`) are only available as a `Partial`.
17
17
  */
18
18
  export type ErrorHandler<BaseContext extends CrawlingContext = CrawlingContext, ExtendedContext extends BaseContext = BaseContext> = (inputs: BaseContext & Partial<ExtendedContext>, error: Error) => Awaitable<void>;
19
- export interface StatusMessageCallbackParams<Context extends CrawlingContext = BasicCrawlingContext, Crawler extends BasicCrawler<any> = BasicCrawler<Context>> {
19
+ export interface StatusMessageCallbackParams<Context extends CrawlingContext = BasicCrawlingContext, Crawler extends BasicCrawler<any, any, any, any> = BasicCrawler<Context>> {
20
20
  state: StatisticState;
21
21
  crawler: Crawler;
22
22
  previousState: StatisticState;
23
23
  message: string;
24
24
  }
25
- export type StatusMessageCallback<Context extends CrawlingContext = BasicCrawlingContext, Crawler extends BasicCrawler<any> = BasicCrawler<Context>> = (params: StatusMessageCallbackParams<Context, Crawler>) => Awaitable<void>;
25
+ export type StatusMessageCallback<Context extends CrawlingContext = BasicCrawlingContext, Crawler extends BasicCrawler<any, any, any, any> = BasicCrawler<Context>> = (params: StatusMessageCallbackParams<Context, Crawler>) => Awaitable<void>;
26
26
  export type RequireContextPipeline<DefaultContextType extends CrawlingContext, FinalContextType extends DefaultContextType> = DefaultContextType extends FinalContextType ? {} : {
27
27
  contextPipelineBuilder: () => ContextPipeline<CrawlingContext, FinalContextType>;
28
28
  };
29
- export interface BasicCrawlerOptions<Context extends CrawlingContext = CrawlingContext, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension> {
29
+ export interface BasicCrawlerOptions<Context extends CrawlingContext = CrawlingContext, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>> {
30
30
  /**
31
31
  * User-provided function that performs the logic of the crawler. It is called for each URL to crawl.
32
32
  *
@@ -44,7 +44,7 @@ export interface BasicCrawlerOptions<Context extends CrawlingContext = CrawlingC
44
44
  * The exceptions are logged to the request using the
45
45
  * {@link Request.pushErrorMessage|`Request.pushErrorMessage()`} function.
46
46
  */
47
- requestHandler?: RequestHandler<ExtendedContext>;
47
+ requestHandler?: RouterHandler<ExtendedContext, Routes> | RequestHandler<ExtendedContext>;
48
48
  /**
49
49
  * Allows the user to extend the crawling context with custom functionality (helpers, references, etc.).
50
50
  *
@@ -387,7 +387,7 @@ interface CrawlerIdentity {
387
387
  /** Whether `id` came from the user (as opposed to being derived from `instanceIndex`). */
388
388
  readonly hasExplicitId: boolean;
389
389
  }
390
- export declare class BasicCrawler<Context extends CrawlingContext = CrawlingContext, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension> {
390
+ export declare class BasicCrawler<Context extends CrawlingContext = CrawlingContext, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>> {
391
391
  #private;
392
392
  protected static readonly CRAWLEE_STATE_KEY = "CRAWLEE_STATE";
393
393
  /**
@@ -447,7 +447,7 @@ export declare class BasicCrawler<Context extends CrawlingContext = CrawlingCont
447
447
  * Default {@link Router} instance that will be used if we don't specify any {@link BasicCrawlerOptions.requestHandler|`requestHandler`}.
448
448
  * See {@link Router.addHandler|`router.addHandler()`} and {@link Router.addDefaultHandler|`router.addDefaultHandler()`}.
449
449
  */
450
- readonly router: RouterHandler<Context>;
450
+ readonly router: RouterHandler<Context, Routes>;
451
451
  private _basicContextPipeline?;
452
452
  /**
453
453
  * The basic part of the context pipeline. Unlike the subclass pipeline, this
@@ -565,7 +565,7 @@ export declare class BasicCrawler<Context extends CrawlingContext = CrawlingCont
565
565
  /**
566
566
  * All `BasicCrawler` parameters are passed via an options object.
567
567
  */
568
- constructor(options?: BasicCrawlerOptions<Context, ContextExtension, ExtendedContext> & RequireContextPipeline<CrawlingContext, Context>);
568
+ constructor(options?: BasicCrawlerOptions<Context, ContextExtension, ExtendedContext, Routes> & RequireContextPipeline<CrawlingContext, Context>);
569
569
  /**
570
570
  * Determines if the given HTTP status code is an error status code given
571
571
  * the default behaviour and user-set preferences.
@@ -617,7 +617,7 @@ export declare class BasicCrawler<Context extends CrawlingContext = CrawlingCont
617
617
  * @param [requests] The requests to add.
618
618
  * @param [options] Options for the request queue.
619
619
  */
620
- run(requests?: RequestsLike, options?: CrawlerRunOptions): Promise<FinalStatistics>;
620
+ run(requests?: TypedRequestsLike<Routes>, options?: CrawlerRunOptions): Promise<FinalStatistics>;
621
621
  /**
622
622
  * Gracefully stops the current run of the crawler.
623
623
  *
@@ -674,7 +674,7 @@ export declare class BasicCrawler<Context extends CrawlingContext = CrawlingCont
674
674
  * @param requests The requests to add
675
675
  * @param options Options for the request queue
676
676
  */
677
- addRequests(requests: ReadonlyDeep<RequestsLike>, options?: CrawlerAddRequestsOptions): Promise<CrawlerAddRequestsResult>;
677
+ addRequests(requests: ReadonlyDeep<TypedRequestsLike<Routes>>, options?: CrawlerAddRequestsOptions): Promise<CrawlerAddRequestsResult>;
678
678
  /**
679
679
  * Pushes data to the specified {@link Dataset}, or the default crawler {@link Dataset} by calling {@link Dataset.pushData}.
680
680
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/basic",
3
- "version": "4.0.0-beta.85",
3
+ "version": "4.0.0-beta.86",
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"
@@ -42,10 +42,10 @@
42
42
  "@apify/datastructures": "^2.0.0",
43
43
  "@apify/timeout": "^0.3.2",
44
44
  "@apify/utilities": "^2.15.5",
45
- "@crawlee/core": "4.0.0-beta.85",
46
- "@crawlee/http-client": "4.0.0-beta.85",
47
- "@crawlee/types": "4.0.0-beta.85",
48
- "@crawlee/utils": "4.0.0-beta.85",
45
+ "@crawlee/core": "4.0.0-beta.86",
46
+ "@crawlee/http-client": "4.0.0-beta.86",
47
+ "@crawlee/types": "4.0.0-beta.86",
48
+ "@crawlee/utils": "4.0.0-beta.86",
49
49
  "csv-stringify": "^6.5.2",
50
50
  "fs-extra": "^11.3.0",
51
51
  "ow": "^2.0.0",
@@ -54,7 +54,7 @@
54
54
  "type-fest": "^4.41.0"
55
55
  },
56
56
  "optionalDependencies": {
57
- "@crawlee/impit-client": "^4.0.0-beta.85"
57
+ "@crawlee/impit-client": "^4.0.0-beta.86"
58
58
  },
59
59
  "lerna": {
60
60
  "command": {
@@ -63,5 +63,5 @@
63
63
  }
64
64
  }
65
65
  },
66
- "gitHead": "8d6d3cd9da3dc9cb0b7822b28eb317019b6806bc"
66
+ "gitHead": "c2f251426f3ccfcc6efc920e6d492be57beac43b"
67
67
  }