@crawlee/http 3.17.1-beta.22 → 3.17.1-beta.24

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.
@@ -2,7 +2,7 @@ import { Transform } from 'node:stream';
2
2
  import type { Dictionary } from '@crawlee/types';
3
3
  // @ts-ignore optional peer dependency or compatibility with es2022
4
4
  import type { Request } from 'got-scraping';
5
- import type { ErrorHandler, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterRoutes } from '../index';
5
+ import type { ErrorHandler, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterHandler, RouterRoutes } from '../index';
6
6
  import { HttpCrawler } from '../index';
7
7
  export type FileDownloadErrorHandler<UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
8
8
  JSONData extends Dictionary = any> = ErrorHandler<FileDownloadCrawlingContext<UserData, JSONData>>;
@@ -124,6 +124,6 @@ export declare class FileDownload extends HttpCrawler<FileDownloadCrawlingContex
124
124
  * await crawler.run();
125
125
  * ```
126
126
  */
127
- // @ts-ignore optional peer dependency or compatibility with es2022
128
- export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData>): import("../index").RouterHandler<Context>;
127
+ export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
128
+ export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
129
129
  export {};
@@ -209,30 +209,6 @@ class FileDownload extends index_1.HttpCrawler {
209
209
  }
210
210
  }
211
211
  exports.FileDownload = FileDownload;
212
- /**
213
- * Creates new {@link Router} instance that works based on request labels.
214
- * This instance can then serve as a `requestHandler` of your {@link FileDownload}.
215
- * Defaults to the {@link FileDownloadCrawlingContext}.
216
- *
217
- * > Serves as a shortcut for using `Router.create<FileDownloadCrawlingContext>()`.
218
- *
219
- * ```ts
220
- * import { FileDownload, createFileRouter } from 'crawlee';
221
- *
222
- * const router = createFileRouter();
223
- * router.addHandler('label-a', async (ctx) => {
224
- * ctx.log.info('...');
225
- * });
226
- * router.addDefaultHandler(async (ctx) => {
227
- * ctx.log.info('...');
228
- * });
229
- *
230
- * const crawler = new FileDownload({
231
- * requestHandler: router,
232
- * });
233
- * await crawler.run();
234
- * ```
235
- */
236
212
  function createFileRouter(routes) {
237
213
  return index_1.Router.create(routes);
238
214
  }
@@ -1,6 +1,6 @@
1
1
  import type { IncomingMessage } from 'node:http';
2
2
  import type { Readable } from 'node:stream';
3
- import type { BasicCrawlerOptions, CrawlingContext, ErrorHandler, GetUserDataFromRequest, ProxyConfiguration, Request, RequestHandler, RouterRoutes, Session } from '@crawlee/basic';
3
+ import type { BasicCrawlerOptions, CrawlingContext, ErrorHandler, GetUserDataFromRequest, ProxyConfiguration, Request, RequestHandler, RouterHandler, RouterRoutes, Session } from '@crawlee/basic';
4
4
  import { BasicCrawler, Configuration, CrawlerExtension } from '@crawlee/basic';
5
5
  import type { HttpResponse } from '@crawlee/core';
6
6
  import type { Awaitable, Dictionary } from '@crawlee/types';
@@ -525,6 +525,6 @@ interface RequestFunctionOptions {
525
525
  * await crawler.run();
526
526
  * ```
527
527
  */
528
- // @ts-ignore optional peer dependency or compatibility with es2022
529
- export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData>): import("@crawlee/basic").RouterHandler<Context>;
528
+ export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
529
+ export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
530
530
  export {};
@@ -709,30 +709,6 @@ function parseContentTypeFromResponse(response) {
709
709
  charset: parsedContentType.parameters.charset,
710
710
  };
711
711
  }
712
- /**
713
- * Creates new {@link Router} instance that works based on request labels.
714
- * This instance can then serve as a `requestHandler` of your {@link HttpCrawler}.
715
- * Defaults to the {@link HttpCrawlingContext}.
716
- *
717
- * > Serves as a shortcut for using `Router.create<HttpCrawlingContext>()`.
718
- *
719
- * ```ts
720
- * import { HttpCrawler, createHttpRouter } from 'crawlee';
721
- *
722
- * const router = createHttpRouter();
723
- * router.addHandler('label-a', async (ctx) => {
724
- * ctx.log.info('...');
725
- * });
726
- * router.addDefaultHandler(async (ctx) => {
727
- * ctx.log.info('...');
728
- * });
729
- *
730
- * const crawler = new HttpCrawler({
731
- * requestHandler: router,
732
- * });
733
- * await crawler.run();
734
- * ```
735
- */
736
712
  function createHttpRouter(routes) {
737
713
  return basic_1.Router.create(routes);
738
714
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/http",
3
- "version": "3.17.1-beta.22",
3
+ "version": "3.17.1-beta.24",
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"
@@ -55,9 +55,9 @@
55
55
  "dependencies": {
56
56
  "@apify/timeout": "^0.3.0",
57
57
  "@apify/utilities": "^2.7.10",
58
- "@crawlee/basic": "3.17.1-beta.22",
59
- "@crawlee/types": "3.17.1-beta.22",
60
- "@crawlee/utils": "3.17.1-beta.22",
58
+ "@crawlee/basic": "3.17.1-beta.24",
59
+ "@crawlee/types": "3.17.1-beta.24",
60
+ "@crawlee/utils": "3.17.1-beta.24",
61
61
  "@types/content-type": "^1.1.5",
62
62
  "cheerio": "1.0.0-rc.12",
63
63
  "content-type": "^1.0.4",
@@ -75,5 +75,5 @@
75
75
  }
76
76
  }
77
77
  },
78
- "gitHead": "913fa8ac27d9a04e8a8b87df05d1c6c9ab7f3a87"
78
+ "gitHead": "187d1180d326bac968c64807edf90aa590f8aceb"
79
79
  }