-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor: Simplify input handling #66
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
Conversation
jirispilka
left a comment
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.
Thank you!
Looks great.
As Lukas suggested, can you also remove table with query params from README.md?
Since the inputs for normal mode and standby are 1:1. It will greatly shorten the README.
Otherwise, LGTM.
src/utils.ts
Outdated
| type SchemaKey = keyof typeof inputSchema.properties; | ||
|
|
||
| const typedKey = key as SchemaKey; | ||
| // const inputKey = key as keyof typeof parsedInput; |
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 would remove this commented out code
|
@jirispilka I have removed the dead code and remove the table from README.md. |
MQ37
left a comment
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.
LGTM 👍
Based on this comment by @metalwarrior665 I've decided to have a look at simplifying input handling.
To simplify things I have decided to remove the
defaultsobject and rewrite thevalidateAndFillInputfunction to use the input schema directly.How it works
Normal mode
In normal mode the input is received via
Actor.getInput()which is then processed using theprocessInputfunction where its validated and completed. This function then returns the necessary crawler options to complete the query.Standby mode
When standby mode is initiated it will receive its initial input via
Actor.getInput(). This input is processed using theprocessStandbyInputwhich returns crawler options for all possible crawlers which is then used to start them. Then it waits for request.When a request arrives its parameters are parsed using the
parseParametersfunction which returnsPartial<Input>object. This object is then directly fed into theparseInputfunction where its validated and completed like standby input.Here are example runs: