-
Notifications
You must be signed in to change notification settings - Fork 15
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: add analyzeDocuments + SchemaAccessor COMPASS-8799 #216
base: main
Are you sure you want to change the base?
Conversation
c6196fc
to
1249f8b
Compare
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.
Looking good, left a couple comments/suggestions
options: { | ||
signal?: AbortSignal | ||
}): ExtendedJSONSchema { | ||
// TODO: COMPASS-8702 |
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 a bit apprehensive about merging this to main - if we find out we want to do a release of some other fix in the meantime before this TODO is completed then we'd effectively be releasing something that doesn't work.
I don't think we chatted about this in the technical design. How would you feel about having a separate branch that we merge this branch and all of these various accessors to before we merge them into main to avoid that?
Again it's mostly only us using this package, but it can be a good practice to follow. We did a similar thing with the copilot agent in VSCode: mongodb-js/vscode#839
|
||
export type StandardJSONSchema = JSONSchema4; | ||
|
||
export type MongodbJSONSchema = Pick<StandardJSONSchema, 'title' | 'required' | 'description'> & { |
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.
A total nit question, how do you feel about MongoDBJSONSchema
? I suppose it is a lot of uppercase letters in a row though lol. I think we typically write MongoDB with the uppercase DB in our code in Compass, and it looks like the driver does too at least with MongoDBNamespace
. Same question with the related functions.
private signal?: AbortSignal; | ||
|
||
constructor(internalSchema: InternalSchema, signal?: AbortSignal) { | ||
this.signal = signal; |
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.
Is there a benefit for us saving the signal here and using it in the accessors verses having the accessors receive the signal as one of their arguments?
I'm thinking it may be more flexible to have the various accessors receive a signal in their function arguments in case the consumer of this wants to say start a schema retrieval, then abort it because the user clicked cancel or something, and then start a different one.
return source; | ||
} | ||
|
||
export async function getCompletedSchemaAnalyzer( |
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.
nit: I like to avoid adding functions to util
files when possible as I feel they can sometimes absorb a lot of the code and overtime that can make discovery more difficult. Would it make sense to move these functions to the schema-analyzer.ts
file? No changes needed, mostly a thought/suggestion. Also I should mention I like not having much code in index.ts
files so I'm happy these are at least not there anymore!
Adding
analyzeDocuments() -> SchemaAccessor
as prep for having multiple formats. The interface has been chosen so that:see the tech design for more details.