-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(NODE-3275): Fix enum type export naming and serverApi validation #2809
Conversation
src/mongo_client.ts
Outdated
|
||
/** @public */ | ||
export interface ServerApi { | ||
version: string | ServerApiVersionId; | ||
version: string | ServerApiVersion; |
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.
@emadum Do you happen to know why this is typed as string | ServerApiVersion
? The api version is also a string, so this typing is equivalent to just string
- do we actually want to allow arbitrary strings here?
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 don't recall a reason, we don't want to allow arbitrary strings so I think string
can be removed.
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.
Actually, it looks like it's currently assigned when we parse the connection options on the condition that it is a string... do we want to restrict the option validation so that only the api versions known to the driver are supported? or do we want users to be able to specify any version regardless of whether it's known to the driver?
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.
Cross referencing the spec:
it looks like the string | ServerApiVersion
given in the spec for the class is intended to accommodate languages that can't provide an enum; since we can provide an enum via typescript, it's fine for us to just have the enum, however in light of:
the driver MUST validate (e.g. when the application provides a version string to the ServerApi class) that the version string is valid and trigger a client-side error if an unknown API version was used
I'm going to add the check and error in the connection parser since typescript doesn't provide run time validation
b6f2fb8
to
f420e36
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.
A suggestion, we can discuss:
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
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.
Nice error message change! 👍
Description
NODE-3275
Make type exports for enums use the same name as the enums themselves