Skip to content

feat(autocomplete): add type generator from the php yaml definitions MONGOSH-2030 #521

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

Merged
merged 28 commits into from
Jun 12, 2025

Conversation

nirinchev
Copy link
Collaborator

@nirinchev nirinchev commented Mar 20, 2025

Description

Adds generators for the aggregation stages using the yaml definitions from https://github.com/mongodb-js/mongo-php-library/tree/v1.x/generator/config.

Three generators are added to process the yaml definitions:

  1. schema-generator.ts generates a typescript schema from the yaml definitions which can be used to autocomplete aggregation stages. Notable limitations of the current schema include:
    • Unable to autocomplete nested fields e.g. $unset: [ 'foo.bar' ]
    • Stages following $addFields, $project, etc. will not reflect the new collection schema
    • Certain stages add variables which are not visible in the autocompletion (e.g. $lookup.let)
    • Some types don't have static schema defined (e.g. SearchScore, GeoPoint, etc.)
  2. driver-schema-generator.ts generates the schema for the tests in the php yaml library. It does this by infering the schema from the documentation.
  3. test-generator.ts generates tests from the yaml definitions. Those are not functional tests, but rather verify that the code compiles - that is, the schema definition does not generate false negatives. They don't attempt to verify that the autocompletion always suggests precise results though - i.e. a schema definition where everything is any would pass all the tests in this PR. Validating autocomplete results are helpful is a follow-up task that will be done when we integrate all the autocomplete tickets together.

Open Questions

We probably want to get mongodb/mongo-php-library#1659 eventually merged to ensure we don't diverge too far from upstream.

@lerouxb lerouxb mentioned this pull request May 2, 2025
3 tasks
@nirinchev nirinchev marked this pull request as ready for review June 10, 2025 11:59
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Amazing work @nirinchev! ✨

Copy link
Collaborator

@lerouxb lerouxb left a comment

Choose a reason for hiding this comment

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

Great work! Like I explained I think we probably don't need 7fc9890 anymore. Up to you if you want to remove it again.

@nirinchev nirinchev merged commit 8c0293a into main Jun 12, 2025
6 checks passed
@nirinchev nirinchev deleted the ni/mql-typescript branch June 12, 2025 14:46
@nirinchev nirinchev changed the title feat(autocomplete): add type generator from the php yaml definitions feat(autocomplete): add type generator from the php yaml definitions MONGOSH-2030 Jun 12, 2025
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.

3 participants