Skip to content

Commit 8fbbee7

Browse files
authored
feat: remove specific error typing from the method definitions (#142)
* moved error properties to preRecordedTranscriptionResponse * removed error response union types. * removed ErrorResponse from LiveTranscription
1 parent c3cfc28 commit 8fbbee7

24 files changed

+72
-50
lines changed

src/billing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BalanceList, Balance, RequestFunction, ErrorResponse } from "./types";
1+
import { BalanceList, Balance, RequestFunction } from "./types";
22

33
export class Billing {
44
constructor(
@@ -13,12 +13,12 @@ export class Billing {
1313
* @param {string} projectId Unique identifier of the project
1414
* @param {string} endpoint Custom API endpoint
1515
*
16-
* @returns {Promise<BalanceList | ErrorResponse>}
16+
* @returns {Promise<BalanceList>}
1717
*/
1818
async listBalances(
1919
projectId: string,
2020
endpoint = "v1/projects"
21-
): Promise<BalanceList | ErrorResponse> {
21+
): Promise<BalanceList> {
2222
return this._request(
2323
"GET",
2424
this._credentials,
@@ -40,7 +40,7 @@ export class Billing {
4040
projectId: string,
4141
balanceId: string,
4242
endpoint = "v1/projects"
43-
): Promise<Balance | ErrorResponse> {
43+
): Promise<Balance> {
4444
return this._request(
4545
"GET",
4646
this._credentials,

src/invitation.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
InvitationOptions,
44
InvitationList,
55
RequestFunction,
6-
ErrorResponse
76
} from "./types";
87

98
export class Invitation {
@@ -24,7 +23,7 @@ export class Invitation {
2423
async list(
2524
projectId: string,
2625
endpoint = "v1/projects"
27-
): Promise<InvitationList | ErrorResponse> {
26+
): Promise<InvitationList> {
2827
return this._request(
2928
"GET",
3029
this._credentials,
@@ -46,7 +45,7 @@ export class Invitation {
4645
projectId: string,
4746
options: InvitationOptions,
4847
endpoint = "v1/projects"
49-
): Promise<Message | ErrorResponse> {
48+
): Promise<Message> {
5049
return this._request(
5150
"POST",
5251
this._credentials,
@@ -67,10 +66,7 @@ export class Invitation {
6766
*
6867
* @returns {Promise<Message>}
6968
*/
70-
async leave(
71-
projectId: string,
72-
endpoint = "v1/projects"
73-
): Promise<Message | ErrorResponse> {
69+
async leave(projectId: string, endpoint = "v1/projects"): Promise<Message> {
7470
return this._request(
7571
"DELETE",
7672
this._credentials,
@@ -93,7 +89,7 @@ export class Invitation {
9389
projectId: string,
9490
email: string,
9591
endpoint = "v1/projects"
96-
): Promise<Message | ErrorResponse> {
92+
): Promise<Message> {
9793
return this._request(
9894
"DELETE",
9995
this._credentials,

src/keys.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Key,
55
KeyResponseObj,
66
RequestFunction,
7-
ErrorResponse
7+
ErrorResponse,
88
} from "./types";
99

1010
export class Keys {
@@ -25,7 +25,7 @@ export class Keys {
2525
async list(
2626
projectId: string,
2727
endpoint = "v1/projects"
28-
): Promise<KeyResponse | ErrorResponse> {
28+
): Promise<KeyResponse> {
2929
const response = await this._request(
3030
"GET",
3131
this._credentials,
@@ -56,7 +56,7 @@ export class Keys {
5656
projectId: string,
5757
keyId: string,
5858
endpoint = "v1/projects"
59-
): Promise<Key | ErrorResponse> {
59+
): Promise<Key> {
6060
return this._request(
6161
"GET",
6262
this._credentials,
@@ -82,7 +82,7 @@ export class Keys {
8282
scopes: Array<string>,
8383
options?: CreateKeyOptions,
8484
endpoint = "v1/projects"
85-
): Promise<Key | ErrorResponse> {
85+
): Promise<Key> {
8686
/** Throw an error if the user provided both expirationDate and timeToLive */
8787
if (
8888
options &&

src/members.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MemberList, Message, RequestFunction, ErrorResponse } from "./types";
1+
import { MemberList, Message, RequestFunction } from "./types";
22

33
export class Members {
44
constructor(
@@ -13,12 +13,12 @@ export class Members {
1313
* @param {string} projectId Unique identifier of the project
1414
* @param {string} endpoint Custom API endpoint
1515
*
16-
* @returns {Promise<MemberList | ErrorResponse>}
16+
* @returns {Promise<MemberList>}
1717
*/
1818
async listMembers(
1919
projectId: string,
2020
endpoint = "v1/projects"
21-
): Promise<MemberList | ErrorResponse> {
21+
): Promise<MemberList> {
2222
return this._request(
2323
"GET",
2424
this._credentials,
@@ -34,13 +34,13 @@ export class Members {
3434
* @param {string} memberId Unique identifier of the member
3535
* @param {string} endpoint Custom API endpoint
3636
*
37-
* @returns {Promise<Message | ErrorResponse>}
37+
* @returns {Promise<Message>}
3838
*/
3939
async removeMember(
4040
projectId: string,
4141
memberId: string,
4242
endpoint = "v1/projects"
43-
): Promise<Message | ErrorResponse> {
43+
): Promise<Message> {
4444
return this._request(
4545
"DELETE",
4646
this._credentials,

src/projects.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ export class Projects {
1919
* Returns all projects accessible by the API key.
2020
* @param {string} endpoint Custom API endpoint
2121
*
22-
* @returns {Promise<ProjectResponse | ErrorResponse>}
22+
* @returns {Promise<ProjectResponse>}
2323
*/
2424

25-
async list(
26-
endpoint = "v1/projects"
27-
): Promise<ProjectResponse | ErrorResponse> {
25+
async list(endpoint = "v1/projects"): Promise<ProjectResponse> {
2826
return this._request(
2927
"GET",
3028
this._credentials,
@@ -39,12 +37,9 @@ export class Projects {
3937
* @param {string} projectId Unique identifier of the project
4038
* @param {string} endpoint Custom API endpoint
4139
*
42-
* @returns {Promise<Project | ErrorResponse>}
40+
* @returns {Promise<Project>}
4341
*/
44-
async get(
45-
projectId: string,
46-
endpoint = "v1/projects"
47-
): Promise<Project | ErrorResponse> {
42+
async get(projectId: string, endpoint = "v1/projects"): Promise<Project> {
4843
return this._request(
4944
"GET",
5045
this._credentials,
@@ -60,13 +55,13 @@ export class Projects {
6055
* @param {ProjectPatchRequest} payload Details to change as an object
6156
* @param {string} endpoint Custom API endpoint
6257
*
63-
* @returns {Promise<ProjectPatchResponse | ErrorResponse>}
58+
* @returns {Promise<ProjectPatchResponse>}
6459
*/
6560
async update(
6661
project: string | Project,
6762
payload: ProjectPatchRequest,
6863
endpoint = "v1/projects"
69-
): Promise<ProjectPatchResponse | ErrorResponse> {
64+
): Promise<ProjectPatchResponse> {
7065
const projectObj = project as Project;
7166
let projectId = project as string;
7267

@@ -89,7 +84,7 @@ export class Projects {
8984
* @param {string} projectId Unique identifier of the project
9085
* @param {string} endpoint Custom API endpoint
9186
*
92-
* @returns {Promise<Message | ErrorResponse>}
87+
* @returns {Promise<void | ErrorResponse>}
9388
*/
9489
async delete(
9590
projectId: string,

src/scopes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ScopeList, Message, RequestFunction, ErrorResponse } from "./types";
1+
import { ScopeList, Message, RequestFunction } from "./types";
22

33
export class Scopes {
44
constructor(
@@ -14,13 +14,13 @@ export class Scopes {
1414
* @param {string} memberId Unique identifier of the member
1515
* @param {string} endpoint Custom API endpoint
1616
*
17-
* @returns {Promise<ScopeList | ErrorResponse>}
17+
* @returns {Promise<ScopeList>}
1818
*/
1919
async get(
2020
projectId: string,
2121
memberId: string,
2222
endpoint = "v1/projects"
23-
): Promise<ScopeList | ErrorResponse> {
23+
): Promise<ScopeList> {
2424
return this._request(
2525
"GET",
2626
this._credentials,
@@ -37,14 +37,14 @@ export class Scopes {
3737
* @param {string} scope Scope to update the member to
3838
* @param {string} endpoint Custom API endpoint
3939
*
40-
* @returns {Promise<Message | ErrorResponse>}
40+
* @returns {Promise<Message>}
4141
*/
4242
async update(
4343
projectID: string,
4444
memberId: string,
4545
scope: string,
4646
endpoint = "v1/projects"
47-
): Promise<Message | ErrorResponse> {
47+
): Promise<Message> {
4848
return this._request(
4949
"PUT",
5050
this._credentials,

src/transcription/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
PrerecordedTranscriptionOptions,
44
PrerecordedTranscriptionResponse,
55
TranscriptionSource,
6-
ErrorResponse
6+
ErrorResponse,
77
} from "../types";
88
import { LiveTranscription } from "./liveTranscription";
99
import { preRecordedTranscription } from "./preRecordedTranscription";
@@ -21,13 +21,13 @@ export class Transcriber {
2121
* @param {PrerecordedTranscriptionOptions} options Options used to toggle transcription features
2222
* @param {string} endpoint Custom API endpoint
2323
*
24-
* @returns {Promise<PrerecordedTranscriptionResponse | ErrorResponse>}
24+
* @returns {Promise<PrerecordedTranscriptionResponse>}
2525
*/
2626
async preRecorded(
2727
source: TranscriptionSource,
2828
options?: PrerecordedTranscriptionOptions,
2929
endpoint?: string
30-
): Promise<PrerecordedTranscriptionResponse | ErrorResponse> {
30+
): Promise<PrerecordedTranscriptionResponse> {
3131
return await preRecordedTranscription(
3232
this._credentials,
3333
this._apiUrl || "",
@@ -43,12 +43,12 @@ export class Transcriber {
4343
* @param {LiveTranscriptionOptions} options Options used to toggle transcription features
4444
* @param {string} endpoint Custom API endpoint
4545
*
46-
* @returns {LiveTranscription | ErrorResponse}
46+
* @returns {LiveTranscription}
4747
*/
4848
live(
4949
options?: LiveTranscriptionOptions,
5050
endpoint?: string
51-
): LiveTranscription | ErrorResponse {
51+
): LiveTranscription {
5252
return new LiveTranscription(
5353
this._credentials,
5454
this._apiUrl || "",

src/types/balance.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ export type Balance = {
33
amount: number;
44
units: string;
55
purchase: string;
6+
err_code?: string;
7+
err_msg?: string;
68
};

src/types/balanceList.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ import { Balance } from "./balance";
22

33
export type BalanceList = {
44
balances?: Array<Balance>;
5+
err_code?: string;
6+
err_msg?: string;
57
};

src/types/invitationList.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ import { InvitationOptions } from "./invitationOptions";
22

33
export type InvitationList = {
44
invites?: Array<InvitationOptions>;
5+
err_code?: string;
6+
err_msg?: string;
57
};

0 commit comments

Comments
 (0)