Skip to content
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

Refactor codec to TS generation for fine grained customization #889

Merged
merged 5 commits into from Mar 20, 2024

Conversation

CarsonF
Copy link
Contributor

@CarsonF CarsonF commented Mar 4, 2024

  • Moved $.parseQuery -> Client.parse. This feels better as it doesn't have to assume as much regarding client pool, options, or session.
    Perhaps a name like $parse or parse$ would be desired though?
  • Added $.util.parseCardinality as a standard way to convert from the protocol number cardinality to the string enum used by the query builder.
    Happy to move it where ever.
  • parse returns a string enum Cardinality now rather than the protocol one.
    This was the only spot the protocol cardinality leaked into type gen and it felt inconsistent in my (advanced) usage.
  • Along those lines I removed the hardcoded protocol cardinality constants the codecs were using in favor of the cardinality enum.

And then the big refactor of walkCodec, now generateTSTypeFromCodec.
I broke down the logic for how to generate each codec into their own functions.
Now generateTSTypeFromCodec just orchestrates calling these methods (optionally customized via input map).

@CarsonF CarsonF force-pushed the refactor-walk-codec branch 2 times, most recently from 85294df to d031fed Compare March 4, 2024 23:21
@CarsonF CarsonF force-pushed the refactor-walk-codec branch 3 times, most recently from c73e0fb to fdf4a5b Compare March 5, 2024 00:16
@CarsonF CarsonF changed the title Refactor analyzeQuery more Refactor codec to TS generation for fine grained customization Mar 5, 2024
@CarsonF CarsonF marked this pull request as ready for review March 5, 2024 01:11
Copy link
Collaborator

@scotttrinh scotttrinh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the refactor of walkCodec here, and moving the Cardinality parsing to the edge to avoid leaking the number constants is a nice touch, too. 💯

@scotttrinh scotttrinh merged commit cb3569f into edgedb:master Mar 20, 2024
7 of 8 checks passed
@CarsonF CarsonF deleted the refactor-walk-codec branch March 20, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants