-
Notifications
You must be signed in to change notification settings - Fork 669
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: change all websocket method parameters to lower camel case #941
Conversation
Codecov Report
@@ Coverage Diff @@
## release-candidate-v5 #941 +/- ##
========================================================
+ Coverage 54.38% 54.53% +0.15%
========================================================
Files 18 19 +1
Lines 4505 4487 -18
Branches 906 898 -8
========================================================
- Hits 2450 2447 -3
+ Misses 2053 2039 -14
+ Partials 2 1 -1
Continue to review full report at Codecov.
|
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.
Looks good. 👍
I just left one question about parameter descriptions.
lib/recognize-stream.ts
Outdated
* @param {Options} options | ||
* @param {string} [url] - Base url for service (default='wss://stream.watsonplatform.net/speech-to-text/api') | ||
* @param {OutgoingHttpHeaders} [headers] - Only works in Node.js, not in browsers. Allows for custom headers to be set, including an Authorization header (preventing the need for auth tokens) | ||
* @param {boolean} [readableObjectMode] - Emit `result` objects instead of string Buffers for the `data` events. Does not affect input (which must be binary) |
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.
It looks like you removed the "options." from all the parameters that are passed in the "options" object. Was that intentional? It seems like it would be more correct to keep that.
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.
It was not intentional actually, I'll go back and fix that. Thanks for pointing it out 👍
const processedOptions = {}; | ||
|
||
// look for the camelcase version of each parameter - that is what we expose to the user | ||
allowedParams.forEach(param => { |
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.
Can we do something like:
console.warn(`Unrecognized parameter `${param} in query string`);
I feel like it would really help users using the wrong key
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.
That's a good idea, I'll try to add something there
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.
The changes look good. Are you planning on mapping these changes to the speech-sdk?
Thanks for manually writing all the documentation for the query parameters. It takes a lot of time upfront but will help a lot of developers 👍 |
I hadn't thought about it yet, but yes I think I should. I'll open an issue for that |
* Also, add types for WebSocket Stream class constructor options BREAKING CHANGE: All parameters have been converted to their lower camel case version. BREAKING CHANGE: Support for the `token` parameter has been removed BREAKING CHANGE: Support for the `customization_id` parameter has been removed BREAKING CHANGE: Method `setAuthorizationHeaderToken` has been removed from the WebSocket Stream classes
91ccf1d
to
2c67530
Compare
…941) * add types for WebSocket Stream class constructor options * warn user when a parameter is passed in that matches the service option but not the user option BREAKING CHANGE: All parameters have been converted to their lower camel case version. BREAKING CHANGE: Support for the `token` parameter has been removed BREAKING CHANGE: Support for the `customization_id` parameter has been removed BREAKING CHANGE: Method `setAuthorizationHeaderToken` has been removed from the WebSocket Stream classes
…941) * add types for WebSocket Stream class constructor options * warn user when a parameter is passed in that matches the service option but not the user option BREAKING CHANGE: All parameters have been converted to their lower camel case version. BREAKING CHANGE: Support for the `token` parameter has been removed BREAKING CHANGE: Support for the `customization_id` parameter has been removed BREAKING CHANGE: Method `setAuthorizationHeaderToken` has been removed from the WebSocket Stream classes
# [5.0.0](v4.5.1...v5.0.0) (2019-10-04) ### Bug Fixes * make RecognizeStream.readableObjectMode always return Boolean ([#943](#943)) ([a276df4](a276df4)) ### Build System * drop support for Node versions 6 and 8 ([3ea1fd7](3ea1fd7)) ### Code Refactoring * change all websocket method parameters to lower camel case ([#941](#941)) ([cb6711f](cb6711f)) ### Features * add support for new authenticators in all sdks and add new service features for major release ([#946](#946)) ([3acffc5](3acffc5)) ### BREAKING CHANGES * Passing individual credentials to the service constructor will no longer work. An Authenticator must be initialized and passed in. For more information, see the migration guide. * All parameters have been converted to their lower camel case version. * Support for the `token` parameter has been removed * Support for the `customization_id` parameter has been removed * Method `setAuthorizationHeaderToken` has been removed from the WebSocket Stream classes * `RecognizeStream.readableObjectMode` will always be a Boolean value - before, it could have been `undefined`. * This SDK may no longer work with applications running on Node 6 or 8.
Making all the changes to the WebSocket classes that I wanted to make for v5. The big one here is exposing only lowerCamelCase parameters to the user to match our style guide. The generator is also changing to generate camecase params for the generated code, so the hand-written code needs to be consistent.
Other things I did:
token
parametercustomization_id
parametersetAuthorizationHeaderToken
method outside of the Stream classes so that they could share it - the exact same code was being used