fix: fix types to match current api response#26
Conversation
|
@michaeljolley the question is if this should be a major version bump or whether we should parse the response and output the original format for compatibility. What do you think? |
michaeljolley
left a comment
There was a problem hiding this comment.
I added comments, then realized this is the wrong way to fix this issue. In this PR, we're modifying the Key type. That type is currently used by the KeyResponse type and the Keys static class as the return type of the create & get functions. Modifying the Key type would provide the incorrect return type for those methods.
Instead, we should create a new Member type and add it as an optional property to the KeyResponse type, like:
import { Key } from "./key";
import { Member } from "./member";
/**
* Response from the Deepgram API to list keys
*/
export type KeyResponse = {
/**
* Array of API keys associated with the project
*/
api_keys: Array<{
/**
* Optional member associated with the API key
*/
member?: Member;
/**
* API key
*/
api_key: Key;
}>;
};| }; | ||
| /** | ||
| * API key to send in API requests (Only displayed when first created) | ||
| * Api key object |
There was a problem hiding this comment.
API (capitalized since it's an abbreviation)
|
@lukeocodes answering the other question around SemVer: ideally we would retain the old typing and provide the previous output as well (if possible) and flag the properties we know are wrong/outdated as deprecated to be removed at a future date. |
|
Ahh, yeh I see it now. |
I'm not sure I know how to achieve this without introducing a promise to wrap around _request in order to modify the output, with some property to switch to the new output? |
|
Types for Key and Member now match the API response.
|
updated the API key type to match the current API response
fixes #25