[WIP] feat: generate TypeScript from MongoDBJSONSchema or JSON Schemas MONGOSH-2058 #236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Still very WIP - at a minimum needs lots more tests and there are some open questions.
Loosely inspired by the type generation from @kmruiz PoC https://github.com/mongodb-js/poc-mongodb-autocomplete/blob/main/src/type-export/index.ts#L191-L197
This takes a MongoDBJSONShema which is our superset of JSON Schema or just a JSON Schema and it turns it into TypeScript code for a Collection described by the schema.
Not sure what we'd call the BSON types. I have them as bson.Blah, but they might just be globals? Or will that clash with the BSON expressions? Obviously this now also depends on those types existing which is still TODO in other tickets.