-
Notifications
You must be signed in to change notification settings - Fork 744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: createAdaptivePlaywrightRouter
utility
#2415
Conversation
packages/core/src/router.ts
Outdated
import { MissingRouteError } from './errors'; | ||
import type { Request } from './request'; | ||
import type { Awaitable } from './typedefs'; | ||
|
||
const defaultRoute = Symbol('default-route'); | ||
|
||
export interface RouterHandler<Context extends CrawlingContext = CrawlingContext> extends Router<Context> { | ||
export interface RouterHandler<Context extends Omit<RestrictedCrawlingContext, 'enqueueLinks'> = RestrictedCrawlingContext> extends Router<Context> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very happy about this. Maybe the type bound should be something else entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this breaking? I guess for people who use Router.create()
it could be (as you no longer have the enqueueLinks
helper in the context I think?), although they should be using create*Router
factories instead.
I would maybe remove those changes and only handle the fact that enqueueLinks
are not there for basic crawler only in createBasicRouter()
, that's the only place where the change is actually doing something.
But it's fine to keep it this way too I guess, polishing those things could end up breaking and its better to keep that for v4 (where we also want to get rid of the Record
type extension).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the default value should not change, astute observation! If we get that out of the way, relaxing the bound on the type parameter should not break anything, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah makes sense
create*Router
helper for AdaptivePlaywrightCrawler #2407structured adaptive crawling
AdaptivePlaywrightCrawlerContext
typeand relax the type parameter constraint on
Router
toRestrictedCrawlingContext