@crawlee/http 4.0.0-beta.136 → 4.0.0-beta.137

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.
@@ -3,7 +3,7 @@ import type { BasicCrawlerOptions } from '@crawlee/basic';
3
3
  import { BasicCrawler } from '@crawlee/basic';
4
4
  import type { ContextPipeline, CrawlingContext, LoadedRequest, Request } from '@crawlee/core';
5
5
  import type { Dictionary } from '@crawlee/types';
6
- import type { ErrorHandler, GetUserDataFromRequest, InternalHttpHook, RequestHandler, RouterRoutes } from '../index.js';
6
+ import type { ErrorHandler, GetUserDataFromRequest, InternalHttpHook, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '../index.js';
7
7
  export type FileDownloadErrorHandler<UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
8
8
  ContextExtension = Dictionary<never>> = ErrorHandler<CrawlingContext, FileDownloadCrawlingContext<UserData> & ContextExtension>;
9
9
  export type FileDownloadHook<UserData extends Dictionary = any> = InternalHttpHook<FileDownloadCrawlingContext<UserData>>;
@@ -113,5 +113,6 @@ export declare class FileDownload extends BasicCrawler<FileDownloadCrawlingConte
113
113
  * await crawler.run();
114
114
  * ```
115
115
  */
116
- // @ts-ignore optional peer dependency or compatibility with es2022
117
- export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData>): import("@crawlee/basic").RouterHandler<Context, Record<string, GetUserDataFromRequest<Context["request"]>>>;
116
+ 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>;
117
+ 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>>;
118
+ export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
@@ -162,30 +162,6 @@ function trackBodyConsumption(response) {
162
162
  });
163
163
  return { response: trackedResponse, bodyDrained };
164
164
  }
165
- /**
166
- * Creates new {@link Router} instance that works based on request labels.
167
- * This instance can then serve as a `requestHandler` of your {@link FileDownload}.
168
- * Defaults to the {@link FileDownloadCrawlingContext}.
169
- *
170
- * > Serves as a shortcut for using `Router.create<FileDownloadCrawlingContext>()`.
171
- *
172
- * ```ts
173
- * import { FileDownload, createFileRouter } from 'crawlee';
174
- *
175
- * const router = createFileRouter();
176
- * router.addHandler('label-a', async (ctx) => {
177
- * ctx.log.info('...');
178
- * });
179
- * router.addDefaultHandler(async (ctx) => {
180
- * ctx.log.info('...');
181
- * });
182
- *
183
- * const crawler = new FileDownload({
184
- * requestHandler: router,
185
- * });
186
- * await crawler.run();
187
- * ```
188
- */
189
- export function createFileRouter(routes) {
190
- return Router.create(routes);
165
+ export function createFileRouter(routesOrSchemas) {
166
+ return Router.create(routesOrSchemas);
191
167
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/http",
3
- "version": "4.0.0-beta.136",
3
+ "version": "4.0.0-beta.137",
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"
@@ -49,11 +49,11 @@
49
49
  "dependencies": {
50
50
  "@apify/timeout": "^0.4.4",
51
51
  "@apify/utilities": "^2.15.5",
52
- "@crawlee/basic": "4.0.0-beta.136",
53
- "@crawlee/core": "4.0.0-beta.136",
54
- "@crawlee/http-client": "4.0.0-beta.136",
55
- "@crawlee/types": "4.0.0-beta.136",
56
- "@crawlee/utils": "4.0.0-beta.136",
52
+ "@crawlee/basic": "4.0.0-beta.137",
53
+ "@crawlee/core": "4.0.0-beta.137",
54
+ "@crawlee/http-client": "4.0.0-beta.137",
55
+ "@crawlee/types": "4.0.0-beta.137",
56
+ "@crawlee/utils": "4.0.0-beta.137",
57
57
  "@types/content-type": "^1.1.8",
58
58
  "cheerio": "^1.0.0",
59
59
  "content-type": "^1.0.5",
@@ -70,5 +70,5 @@
70
70
  }
71
71
  }
72
72
  },
73
- "gitHead": "d425bb9841885b4b71b84ae6fb0bafbdc4a7e978"
73
+ "gitHead": "18baf967666fbac0c3f52e6a2811f77ecbd59ffd"
74
74
  }