Skip to content

Commit eec0cde

Browse files
fix: fix types to match current api response (#26)
* fix: fix types to match current API out. fixes #25 * fix: match keyresponse and member types with expected API output * fix: make output backwards compatible with sdk versions * fix: possible deprecation notice for method output changing * Modifying KeyResponse object Co-authored-by: Michael Jolley <mike@sparcapp.io>
1 parent 43d8d03 commit eec0cde

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

src/keys.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,21 @@ export class Keys {
1111
* @param projectId Unique identifier of the project containing API keys
1212
*/
1313
async list(projectId: string): Promise<KeyResponse> {
14-
return _request<KeyResponse>(
14+
const response = await _request<KeyResponse>(
1515
"GET",
1616
this._credentials,
1717
this._apiUrl,
1818
`${this.apiPath}/${projectId}/keys`
1919
);
20+
21+
const output = response.api_keys.map((apiKey) => {
22+
return {
23+
...apiKey,
24+
...apiKey.api_key
25+
}
26+
});
27+
28+
return { api_keys: output };
2029
}
2130

2231
/**

src/types/keyResponse.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Key } from "./key";
2+
import { Member } from "./member";
23

34
/**
45
* Response from the Deepgram API to list keys
@@ -7,5 +8,46 @@ export type KeyResponse = {
78
/**
89
* Array of API keys associated with the project
910
*/
10-
api_keys: Array<Key>;
11+
api_keys: Array<{
12+
/**
13+
* Optional member associated with the API key
14+
*/
15+
member?: Member;
16+
17+
/**
18+
* API key
19+
*/
20+
api_key: Key;
21+
22+
/**
23+
* Unique identifier of the key to use in API requests
24+
* @deprecated This property has moved to api_key.api_key_id and will
25+
* be removed in future versions.
26+
*/
27+
api_key_id: string;
28+
/**
29+
* API key to send in API requests (Only displayed when first created)
30+
* @deprecated This property has moved to api_key.key and will
31+
* be removed in future versions.
32+
*/
33+
key?: string;
34+
/**
35+
* Comment for user reference
36+
* @deprecated This property has moved to api_key.comment and will
37+
* be removed in future versions.
38+
*/
39+
comment: string;
40+
/**
41+
* Timestamp of the date/time the key was created
42+
* @deprecated This property has moved to api_key.created and will
43+
* be removed in future versions.
44+
*/
45+
created: string;
46+
/**
47+
* Array of scopes assigned to the key
48+
* @deprecated This property has moved to api_key.scopes and will
49+
* be removed in future versions.
50+
*/
51+
scopes: Array<string>;
52+
}>;
1153
};

src/types/member.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type Member = {
2-
id: string;
3-
name: string;
4-
scopes: Array<string>;
2+
member_id: string;
3+
name?: string;
4+
scopes?: Array<string>;
55
email: string;
66
};

0 commit comments

Comments
 (0)