@deepgram/sdk 3.3.5 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -9
- package/dist/main/DeepgramClient.d.ts +65 -12
- package/dist/main/DeepgramClient.d.ts.map +1 -1
- package/dist/main/DeepgramClient.js +73 -18
- package/dist/main/DeepgramClient.js.map +1 -1
- package/dist/main/index.d.ts +13 -4
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +18 -8
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts +16 -7
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +26 -9
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/enums/LiveConnectionState.d.ts +5 -0
- package/dist/main/lib/enums/LiveConnectionState.d.ts.map +1 -1
- package/dist/main/lib/enums/LiveConnectionState.js +5 -0
- package/dist/main/lib/enums/LiveConnectionState.js.map +1 -1
- package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts +24 -3
- package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
- package/dist/main/lib/enums/LiveTranscriptionEvents.js +23 -2
- package/dist/main/lib/enums/LiveTranscriptionEvents.js.map +1 -1
- package/dist/main/lib/enums/index.d.ts +2 -2
- package/dist/main/lib/enums/index.d.ts.map +1 -1
- package/dist/main/lib/enums/index.js +16 -5
- package/dist/main/lib/enums/index.js.map +1 -1
- package/dist/main/lib/fetch.d.ts +19 -1
- package/dist/main/lib/fetch.d.ts.map +1 -1
- package/dist/main/lib/fetch.js +19 -1
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +9 -5
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +82 -7
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types/CreateProjectKeySchema.d.ts +0 -1
- package/dist/main/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
- package/dist/main/lib/types/DeepgramClientOptions.d.ts +75 -8
- package/dist/main/lib/types/DeepgramClientOptions.d.ts.map +1 -1
- package/dist/main/lib/types/Fetch.d.ts +3 -13
- package/dist/main/lib/types/Fetch.d.ts.map +1 -1
- package/dist/main/lib/types/LiveConfigOptions.d.ts +6 -3
- package/dist/main/lib/types/LiveConfigOptions.d.ts.map +1 -1
- package/dist/main/lib/types/TranscriptionSchema.d.ts +0 -1
- package/dist/main/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/main/lib/types/UpdateProjectMemberScopeSchema.d.ts +1 -1
- package/dist/main/lib/types/UpdateProjectMemberScopeSchema.d.ts.map +1 -1
- package/dist/main/lib/types/UpdateProjectSchema.d.ts +0 -1
- package/dist/main/lib/types/UpdateProjectSchema.d.ts.map +1 -1
- package/dist/main/lib/types/index.d.ts +39 -39
- package/dist/main/lib/types/index.d.ts.map +1 -1
- package/dist/main/lib/types/index.js +53 -0
- package/dist/main/lib/types/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/AbstractClient.d.ts +63 -10
- package/dist/main/packages/AbstractClient.d.ts.map +1 -1
- package/dist/main/packages/AbstractClient.js +103 -50
- package/dist/main/packages/AbstractClient.js.map +1 -1
- package/dist/main/packages/AbstractLiveClient.d.ts +114 -0
- package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -0
- package/dist/main/packages/AbstractLiveClient.js +238 -0
- package/dist/main/packages/AbstractLiveClient.js.map +1 -0
- package/dist/main/packages/AbstractRestClient.d.ts +105 -0
- package/dist/main/packages/AbstractRestClient.d.ts.map +1 -0
- package/dist/main/packages/AbstractRestClient.js +185 -0
- package/dist/main/packages/AbstractRestClient.js.map +1 -0
- package/dist/main/packages/ListenClient.d.ts +21 -4
- package/dist/main/packages/ListenClient.d.ts.map +1 -1
- package/dist/main/packages/ListenClient.js +25 -5
- package/dist/main/packages/ListenClient.js.map +1 -1
- package/dist/main/packages/ListenLiveClient.d.ts +58 -0
- package/dist/main/packages/ListenLiveClient.d.ts.map +1 -0
- package/dist/main/packages/ListenLiveClient.js +119 -0
- package/dist/main/packages/ListenLiveClient.js.map +1 -0
- package/dist/main/packages/ListenRestClient.d.ts +57 -0
- package/dist/main/packages/ListenRestClient.d.ts.map +1 -0
- package/dist/main/packages/ListenRestClient.js +167 -0
- package/dist/main/packages/ListenRestClient.js.map +1 -0
- package/dist/main/packages/ManageRestClient.d.ts +286 -0
- package/dist/main/packages/ManageRestClient.d.ts.map +1 -0
- package/dist/main/packages/ManageRestClient.js +628 -0
- package/dist/main/packages/ManageRestClient.js.map +1 -0
- package/dist/main/packages/ReadRestClient.d.ts +57 -0
- package/dist/main/packages/ReadRestClient.d.ts.map +1 -0
- package/dist/main/packages/ReadRestClient.js +165 -0
- package/dist/main/packages/ReadRestClient.js.map +1 -0
- package/dist/main/packages/SelfHostedRestClient.d.ts +47 -0
- package/dist/main/packages/SelfHostedRestClient.d.ts.map +1 -0
- package/dist/main/packages/SelfHostedRestClient.js +120 -0
- package/dist/main/packages/SelfHostedRestClient.js.map +1 -0
- package/dist/main/packages/SpeakRestClient.d.ts +36 -0
- package/dist/main/packages/SpeakRestClient.d.ts.map +1 -0
- package/dist/main/packages/SpeakRestClient.js +84 -0
- package/dist/main/packages/SpeakRestClient.js.map +1 -0
- package/dist/main/packages/index.d.ts +10 -8
- package/dist/main/packages/index.d.ts.map +1 -1
- package/dist/main/packages/index.js +24 -17
- package/dist/main/packages/index.js.map +1 -1
- package/dist/module/DeepgramClient.d.ts +65 -12
- package/dist/module/DeepgramClient.d.ts.map +1 -1
- package/dist/module/DeepgramClient.js +72 -17
- package/dist/module/DeepgramClient.js.map +1 -1
- package/dist/module/index.d.ts +13 -4
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +18 -8
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts +16 -7
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +26 -9
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/enums/LiveConnectionState.d.ts +5 -0
- package/dist/module/lib/enums/LiveConnectionState.d.ts.map +1 -1
- package/dist/module/lib/enums/LiveConnectionState.js +5 -0
- package/dist/module/lib/enums/LiveConnectionState.js.map +1 -1
- package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts +24 -3
- package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
- package/dist/module/lib/enums/LiveTranscriptionEvents.js +23 -2
- package/dist/module/lib/enums/LiveTranscriptionEvents.js.map +1 -1
- package/dist/module/lib/enums/index.d.ts +2 -2
- package/dist/module/lib/enums/index.d.ts.map +1 -1
- package/dist/module/lib/enums/index.js +2 -2
- package/dist/module/lib/enums/index.js.map +1 -1
- package/dist/module/lib/fetch.d.ts +19 -1
- package/dist/module/lib/fetch.d.ts.map +1 -1
- package/dist/module/lib/fetch.js +19 -1
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +9 -5
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +75 -4
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types/CreateProjectKeySchema.d.ts +0 -1
- package/dist/module/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
- package/dist/module/lib/types/DeepgramClientOptions.d.ts +75 -8
- package/dist/module/lib/types/DeepgramClientOptions.d.ts.map +1 -1
- package/dist/module/lib/types/Fetch.d.ts +3 -13
- package/dist/module/lib/types/Fetch.d.ts.map +1 -1
- package/dist/module/lib/types/LiveConfigOptions.d.ts +6 -3
- package/dist/module/lib/types/LiveConfigOptions.d.ts.map +1 -1
- package/dist/module/lib/types/TranscriptionSchema.d.ts +0 -1
- package/dist/module/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/module/lib/types/UpdateProjectMemberScopeSchema.d.ts +1 -1
- package/dist/module/lib/types/UpdateProjectMemberScopeSchema.d.ts.map +1 -1
- package/dist/module/lib/types/UpdateProjectSchema.d.ts +0 -1
- package/dist/module/lib/types/UpdateProjectSchema.d.ts.map +1 -1
- package/dist/module/lib/types/index.d.ts +39 -39
- package/dist/module/lib/types/index.d.ts.map +1 -1
- package/dist/module/lib/types/index.js +39 -1
- package/dist/module/lib/types/index.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/AbstractClient.d.ts +63 -10
- package/dist/module/packages/AbstractClient.d.ts.map +1 -1
- package/dist/module/packages/AbstractClient.js +99 -50
- package/dist/module/packages/AbstractClient.js.map +1 -1
- package/dist/module/packages/AbstractLiveClient.d.ts +114 -0
- package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -0
- package/dist/module/packages/AbstractLiveClient.js +211 -0
- package/dist/module/packages/AbstractLiveClient.js.map +1 -0
- package/dist/module/packages/AbstractRestClient.d.ts +105 -0
- package/dist/module/packages/AbstractRestClient.d.ts.map +1 -0
- package/dist/module/packages/AbstractRestClient.js +178 -0
- package/dist/module/packages/AbstractRestClient.js.map +1 -0
- package/dist/module/packages/ListenClient.d.ts +21 -4
- package/dist/module/packages/ListenClient.d.ts.map +1 -1
- package/dist/module/packages/ListenClient.js +25 -5
- package/dist/module/packages/ListenClient.js.map +1 -1
- package/dist/module/packages/ListenLiveClient.d.ts +58 -0
- package/dist/module/packages/ListenLiveClient.d.ts.map +1 -0
- package/dist/module/packages/ListenLiveClient.js +115 -0
- package/dist/module/packages/ListenLiveClient.js.map +1 -0
- package/dist/module/packages/ListenRestClient.d.ts +57 -0
- package/dist/module/packages/ListenRestClient.d.ts.map +1 -0
- package/dist/module/packages/ListenRestClient.js +163 -0
- package/dist/module/packages/ListenRestClient.js.map +1 -0
- package/dist/module/packages/ManageRestClient.d.ts +286 -0
- package/dist/module/packages/ManageRestClient.d.ts.map +1 -0
- package/dist/module/packages/ManageRestClient.js +624 -0
- package/dist/module/packages/ManageRestClient.js.map +1 -0
- package/dist/module/packages/ReadRestClient.d.ts +57 -0
- package/dist/module/packages/ReadRestClient.d.ts.map +1 -0
- package/dist/module/packages/ReadRestClient.js +161 -0
- package/dist/module/packages/ReadRestClient.js.map +1 -0
- package/dist/module/packages/SelfHostedRestClient.d.ts +47 -0
- package/dist/module/packages/SelfHostedRestClient.d.ts.map +1 -0
- package/dist/module/packages/SelfHostedRestClient.js +116 -0
- package/dist/module/packages/SelfHostedRestClient.js.map +1 -0
- package/dist/module/packages/SpeakRestClient.d.ts +36 -0
- package/dist/module/packages/SpeakRestClient.d.ts.map +1 -0
- package/dist/module/packages/SpeakRestClient.js +80 -0
- package/dist/module/packages/SpeakRestClient.js.map +1 -0
- package/dist/module/packages/index.d.ts +10 -8
- package/dist/module/packages/index.d.ts.map +1 -1
- package/dist/module/packages/index.js +10 -8
- package/dist/module/packages/index.js.map +1 -1
- package/dist/umd/deepgram.js +1 -1
- package/package.json +8 -6
- package/src/DeepgramClient.ts +81 -17
- package/src/index.ts +32 -7
- package/src/lib/constants.ts +33 -13
- package/src/lib/enums/LiveConnectionState.ts +11 -4
- package/src/lib/enums/LiveTranscriptionEvents.ts +27 -4
- package/src/lib/enums/index.ts +2 -2
- package/src/lib/fetch.ts +22 -2
- package/src/lib/helpers.ts +98 -9
- package/src/lib/types/CreateProjectKeySchema.ts +0 -1
- package/src/lib/types/DeepgramClientOptions.ts +75 -11
- package/src/lib/types/Fetch.ts +2 -24
- package/src/lib/types/LiveConfigOptions.ts +7 -3
- package/src/lib/types/TranscriptionSchema.ts +0 -2
- package/src/lib/types/UpdateProjectMemberScopeSchema.ts +1 -1
- package/src/lib/types/UpdateProjectSchema.ts +0 -1
- package/src/lib/types/index.ts +39 -54
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractClient.ts +129 -61
- package/src/packages/AbstractLiveClient.ts +280 -0
- package/src/packages/AbstractRestClient.ts +221 -0
- package/src/packages/ListenClient.ts +26 -5
- package/src/packages/ListenLiveClient.ts +133 -0
- package/src/packages/ListenRestClient.ts +201 -0
- package/src/packages/ManageRestClient.ts +760 -0
- package/src/packages/ReadRestClient.ts +200 -0
- package/src/packages/SelfHostedRestClient.ts +134 -0
- package/src/packages/SpeakRestClient.ts +79 -0
- package/src/packages/index.ts +10 -8
- package/dist/main/packages/AbstractRestfulClient.d.ts +0 -26
- package/dist/main/packages/AbstractRestfulClient.d.ts.map +0 -1
- package/dist/main/packages/AbstractRestfulClient.js +0 -118
- package/dist/main/packages/AbstractRestfulClient.js.map +0 -1
- package/dist/main/packages/AbstractWsClient.d.ts +0 -10
- package/dist/main/packages/AbstractWsClient.d.ts.map +0 -1
- package/dist/main/packages/AbstractWsClient.js +0 -33
- package/dist/main/packages/AbstractWsClient.js.map +0 -1
- package/dist/main/packages/LiveClient.d.ts +0 -28
- package/dist/main/packages/LiveClient.d.ts.map +0 -1
- package/dist/main/packages/LiveClient.js +0 -110
- package/dist/main/packages/LiveClient.js.map +0 -1
- package/dist/main/packages/ManageClient.d.ts +0 -97
- package/dist/main/packages/ManageClient.d.ts.map +0 -1
- package/dist/main/packages/ManageClient.js +0 -463
- package/dist/main/packages/ManageClient.js.map +0 -1
- package/dist/main/packages/OnPremClient.d.ts +0 -21
- package/dist/main/packages/OnPremClient.d.ts.map +0 -1
- package/dist/main/packages/OnPremClient.js +0 -99
- package/dist/main/packages/OnPremClient.js.map +0 -1
- package/dist/main/packages/PrerecordedClient.d.ts +0 -10
- package/dist/main/packages/PrerecordedClient.d.ts.map +0 -1
- package/dist/main/packages/PrerecordedClient.js +0 -125
- package/dist/main/packages/PrerecordedClient.js.map +0 -1
- package/dist/main/packages/ReadClient.d.ts +0 -10
- package/dist/main/packages/ReadClient.d.ts.map +0 -1
- package/dist/main/packages/ReadClient.js +0 -123
- package/dist/main/packages/ReadClient.js.map +0 -1
- package/dist/main/packages/SpeakClient.d.ts +0 -12
- package/dist/main/packages/SpeakClient.d.ts.map +0 -1
- package/dist/main/packages/SpeakClient.js +0 -57
- package/dist/main/packages/SpeakClient.js.map +0 -1
- package/dist/module/packages/AbstractRestfulClient.d.ts +0 -26
- package/dist/module/packages/AbstractRestfulClient.d.ts.map +0 -1
- package/dist/module/packages/AbstractRestfulClient.js +0 -114
- package/dist/module/packages/AbstractRestfulClient.js.map +0 -1
- package/dist/module/packages/AbstractWsClient.d.ts +0 -10
- package/dist/module/packages/AbstractWsClient.d.ts.map +0 -1
- package/dist/module/packages/AbstractWsClient.js +0 -29
- package/dist/module/packages/AbstractWsClient.js.map +0 -1
- package/dist/module/packages/LiveClient.d.ts +0 -28
- package/dist/module/packages/LiveClient.d.ts.map +0 -1
- package/dist/module/packages/LiveClient.js +0 -106
- package/dist/module/packages/LiveClient.js.map +0 -1
- package/dist/module/packages/ManageClient.d.ts +0 -97
- package/dist/module/packages/ManageClient.d.ts.map +0 -1
- package/dist/module/packages/ManageClient.js +0 -459
- package/dist/module/packages/ManageClient.js.map +0 -1
- package/dist/module/packages/OnPremClient.d.ts +0 -21
- package/dist/module/packages/OnPremClient.d.ts.map +0 -1
- package/dist/module/packages/OnPremClient.js +0 -95
- package/dist/module/packages/OnPremClient.js.map +0 -1
- package/dist/module/packages/PrerecordedClient.d.ts +0 -10
- package/dist/module/packages/PrerecordedClient.d.ts.map +0 -1
- package/dist/module/packages/PrerecordedClient.js +0 -121
- package/dist/module/packages/PrerecordedClient.js.map +0 -1
- package/dist/module/packages/ReadClient.d.ts +0 -10
- package/dist/module/packages/ReadClient.d.ts.map +0 -1
- package/dist/module/packages/ReadClient.js +0 -119
- package/dist/module/packages/ReadClient.js.map +0 -1
- package/dist/module/packages/SpeakClient.d.ts +0 -12
- package/dist/module/packages/SpeakClient.d.ts.map +0 -1
- package/dist/module/packages/SpeakClient.js +0 -53
- package/dist/module/packages/SpeakClient.js.map +0 -1
- package/src/packages/AbstractRestfulClient.ts +0 -160
- package/src/packages/AbstractWsClient.ts +0 -42
- package/src/packages/LiveClient.ts +0 -140
- package/src/packages/ManageClient.ts +0 -584
- package/src/packages/OnPremClient.ts +0 -113
- package/src/packages/PrerecordedClient.ts +0 -162
- package/src/packages/ReadClient.ts +0 -161
- package/src/packages/SpeakClient.ts +0 -50
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
import { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
2
|
-
import { isDeepgramError } from "../lib/errors";
|
|
3
|
-
import { appendSearchParams } from "../lib/helpers";
|
|
4
|
-
import type {
|
|
5
|
-
CreateProjectKeySchema,
|
|
6
|
-
CreateProjectKeyResponse,
|
|
7
|
-
DeepgramResponse,
|
|
8
|
-
Fetch,
|
|
9
|
-
GetProjectBalanceResponse,
|
|
10
|
-
GetProjectBalancesResponse,
|
|
11
|
-
GetProjectInvitesResponse,
|
|
12
|
-
GetProjectKeyResponse,
|
|
13
|
-
GetProjectKeysResponse,
|
|
14
|
-
GetProjectMemberScopesResponse,
|
|
15
|
-
GetProjectMembersResponse,
|
|
16
|
-
GetProjectResponse,
|
|
17
|
-
GetProjectsResponse,
|
|
18
|
-
GetProjectUsageFieldsSchema,
|
|
19
|
-
GetProjectUsageFieldsResponse,
|
|
20
|
-
GetProjectUsageRequestResponse,
|
|
21
|
-
GetProjectUsageRequestsSchema,
|
|
22
|
-
GetProjectUsageRequestsResponse,
|
|
23
|
-
GetProjectUsageSummarySchema,
|
|
24
|
-
GetProjectUsageSummaryResponse,
|
|
25
|
-
MessageResponse,
|
|
26
|
-
SendProjectInviteSchema,
|
|
27
|
-
UpdateProjectMemberScopeSchema,
|
|
28
|
-
UpdateProjectSchema,
|
|
29
|
-
VoidResponse,
|
|
30
|
-
GetTokenDetailsResponse,
|
|
31
|
-
} from "../lib/types";
|
|
32
|
-
|
|
33
|
-
export class ManageClient extends AbstractRestfulClient {
|
|
34
|
-
/**
|
|
35
|
-
* @see https://developers.deepgram.com/docs/authenticating#test-request
|
|
36
|
-
*/
|
|
37
|
-
async getTokenDetails(
|
|
38
|
-
endpoint = "v1/auth/token"
|
|
39
|
-
): Promise<DeepgramResponse<GetTokenDetailsResponse>> {
|
|
40
|
-
try {
|
|
41
|
-
const url = new URL(this.baseUrl);
|
|
42
|
-
url.pathname = endpoint;
|
|
43
|
-
|
|
44
|
-
const result: GetTokenDetailsResponse = await this.get(this.fetch as Fetch, url);
|
|
45
|
-
|
|
46
|
-
return { result, error: null };
|
|
47
|
-
} catch (error) {
|
|
48
|
-
if (isDeepgramError(error)) {
|
|
49
|
-
return { result: null, error };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @see https://developers.deepgram.com/reference/get-projects
|
|
58
|
-
*/
|
|
59
|
-
async getProjects(endpoint = "v1/projects"): Promise<DeepgramResponse<GetProjectsResponse>> {
|
|
60
|
-
try {
|
|
61
|
-
const url = new URL(this.baseUrl);
|
|
62
|
-
url.pathname = endpoint;
|
|
63
|
-
|
|
64
|
-
const result: GetProjectsResponse = await this.get(this.fetch as Fetch, url);
|
|
65
|
-
|
|
66
|
-
return { result, error: null };
|
|
67
|
-
} catch (error) {
|
|
68
|
-
if (isDeepgramError(error)) {
|
|
69
|
-
return { result: null, error };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @see https://developers.deepgram.com/reference/get-project
|
|
78
|
-
*/
|
|
79
|
-
async getProject(
|
|
80
|
-
projectId: string,
|
|
81
|
-
endpoint = "v1/projects/:projectId"
|
|
82
|
-
): Promise<DeepgramResponse<GetProjectResponse>> {
|
|
83
|
-
try {
|
|
84
|
-
const url = new URL(this.baseUrl);
|
|
85
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
86
|
-
|
|
87
|
-
const result: GetProjectResponse = await this.get(this.fetch as Fetch, url);
|
|
88
|
-
|
|
89
|
-
return { result, error: null };
|
|
90
|
-
} catch (error) {
|
|
91
|
-
if (isDeepgramError(error)) {
|
|
92
|
-
return { result: null, error };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @see https://developers.deepgram.com/reference/update-project
|
|
101
|
-
*/
|
|
102
|
-
async updateProject(
|
|
103
|
-
projectId: string,
|
|
104
|
-
options: UpdateProjectSchema,
|
|
105
|
-
endpoint = "v1/projects/:projectId"
|
|
106
|
-
): Promise<DeepgramResponse<MessageResponse>> {
|
|
107
|
-
try {
|
|
108
|
-
const url = new URL(this.baseUrl);
|
|
109
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
110
|
-
|
|
111
|
-
const body = JSON.stringify(options);
|
|
112
|
-
|
|
113
|
-
const result: MessageResponse = await this.patch(this.fetch as Fetch, url, body);
|
|
114
|
-
|
|
115
|
-
return { result, error: null };
|
|
116
|
-
} catch (error) {
|
|
117
|
-
if (isDeepgramError(error)) {
|
|
118
|
-
return { result: null, error };
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @see https://developers.deepgram.com/reference/delete-project
|
|
127
|
-
*/
|
|
128
|
-
async deleteProject(
|
|
129
|
-
projectId: string,
|
|
130
|
-
endpoint = "v1/projects/:projectId"
|
|
131
|
-
): Promise<VoidResponse> {
|
|
132
|
-
try {
|
|
133
|
-
const url = new URL(this.baseUrl);
|
|
134
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
135
|
-
|
|
136
|
-
await this.delete(this.fetch as Fetch, url);
|
|
137
|
-
|
|
138
|
-
return { error: null };
|
|
139
|
-
} catch (error) {
|
|
140
|
-
if (isDeepgramError(error)) {
|
|
141
|
-
return { error };
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @see https://developers.deepgram.com/reference/list-keys
|
|
150
|
-
*/
|
|
151
|
-
async getProjectKeys(
|
|
152
|
-
projectId: string,
|
|
153
|
-
endpoint = "v1/projects/:projectId/keys"
|
|
154
|
-
): Promise<DeepgramResponse<GetProjectKeysResponse>> {
|
|
155
|
-
try {
|
|
156
|
-
const url = new URL(this.baseUrl);
|
|
157
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
158
|
-
|
|
159
|
-
const result: GetProjectKeysResponse = await this.get(this.fetch as Fetch, url);
|
|
160
|
-
|
|
161
|
-
return { result, error: null };
|
|
162
|
-
} catch (error) {
|
|
163
|
-
if (isDeepgramError(error)) {
|
|
164
|
-
return { result: null, error };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
throw error;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @see https://developers.deepgram.com/reference/get-key
|
|
173
|
-
*/
|
|
174
|
-
async getProjectKey(
|
|
175
|
-
projectId: string,
|
|
176
|
-
keyId: string,
|
|
177
|
-
endpoint = "v1/projects/:projectId/keys/:keyId"
|
|
178
|
-
): Promise<DeepgramResponse<GetProjectKeyResponse>> {
|
|
179
|
-
try {
|
|
180
|
-
const url = new URL(this.baseUrl);
|
|
181
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
182
|
-
|
|
183
|
-
const result: GetProjectKeyResponse = await this.get(this.fetch as Fetch, url);
|
|
184
|
-
|
|
185
|
-
return { result, error: null };
|
|
186
|
-
} catch (error) {
|
|
187
|
-
if (isDeepgramError(error)) {
|
|
188
|
-
return { result: null, error };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
throw error;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @see https://developers.deepgram.com/reference/create-key
|
|
197
|
-
*/
|
|
198
|
-
async createProjectKey(
|
|
199
|
-
projectId: string,
|
|
200
|
-
options: CreateProjectKeySchema,
|
|
201
|
-
endpoint = "v1/projects/:projectId/keys"
|
|
202
|
-
): Promise<DeepgramResponse<CreateProjectKeyResponse>> {
|
|
203
|
-
try {
|
|
204
|
-
const url = new URL(this.baseUrl);
|
|
205
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
206
|
-
|
|
207
|
-
const body = JSON.stringify(options);
|
|
208
|
-
|
|
209
|
-
const result: CreateProjectKeyResponse = await this.post(this.fetch as Fetch, url, body);
|
|
210
|
-
|
|
211
|
-
return { result, error: null };
|
|
212
|
-
} catch (error) {
|
|
213
|
-
if (isDeepgramError(error)) {
|
|
214
|
-
return { result: null, error };
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
throw error;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @see https://developers.deepgram.com/reference/delete-key
|
|
223
|
-
*/
|
|
224
|
-
async deleteProjectKey(
|
|
225
|
-
projectId: string,
|
|
226
|
-
keyId: string,
|
|
227
|
-
endpoint = "v1/projects/:projectId/keys/:keyId"
|
|
228
|
-
): Promise<VoidResponse> {
|
|
229
|
-
try {
|
|
230
|
-
const url = new URL(this.baseUrl);
|
|
231
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
232
|
-
|
|
233
|
-
await this.delete(this.fetch as Fetch, url);
|
|
234
|
-
|
|
235
|
-
return { error: null };
|
|
236
|
-
} catch (error) {
|
|
237
|
-
if (isDeepgramError(error)) {
|
|
238
|
-
return { error };
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* @see https://developers.deepgram.com/reference/get-members
|
|
247
|
-
*/
|
|
248
|
-
async getProjectMembers(
|
|
249
|
-
projectId: string,
|
|
250
|
-
endpoint = "v1/projects/:projectId/members"
|
|
251
|
-
): Promise<DeepgramResponse<GetProjectMembersResponse>> {
|
|
252
|
-
try {
|
|
253
|
-
const url = new URL(this.baseUrl);
|
|
254
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
255
|
-
|
|
256
|
-
const result: GetProjectMembersResponse = await this.get(this.fetch as Fetch, url);
|
|
257
|
-
|
|
258
|
-
return { result, error: null };
|
|
259
|
-
} catch (error) {
|
|
260
|
-
if (isDeepgramError(error)) {
|
|
261
|
-
return { result: null, error };
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
throw error;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* @see https://developers.deepgram.com/reference/remove-member
|
|
270
|
-
*/
|
|
271
|
-
async removeProjectMember(
|
|
272
|
-
projectId: string,
|
|
273
|
-
memberId: string,
|
|
274
|
-
endpoint = "v1/projects/:projectId/members/:memberId"
|
|
275
|
-
): Promise<VoidResponse> {
|
|
276
|
-
try {
|
|
277
|
-
const url = new URL(this.baseUrl);
|
|
278
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
279
|
-
|
|
280
|
-
await this.delete(this.fetch as Fetch, url);
|
|
281
|
-
|
|
282
|
-
return { error: null };
|
|
283
|
-
} catch (error) {
|
|
284
|
-
if (isDeepgramError(error)) {
|
|
285
|
-
return { error };
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
throw error;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* @see https://developers.deepgram.com/reference/get-member-scopes
|
|
294
|
-
*/
|
|
295
|
-
async getProjectMemberScopes(
|
|
296
|
-
projectId: string,
|
|
297
|
-
memberId: string,
|
|
298
|
-
endpoint = "v1/projects/:projectId/members/:memberId/scopes"
|
|
299
|
-
): Promise<DeepgramResponse<GetProjectMemberScopesResponse>> {
|
|
300
|
-
try {
|
|
301
|
-
const url = new URL(this.baseUrl);
|
|
302
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
303
|
-
|
|
304
|
-
const result: GetProjectMemberScopesResponse = await this.get(this.fetch as Fetch, url);
|
|
305
|
-
|
|
306
|
-
return { result, error: null };
|
|
307
|
-
} catch (error) {
|
|
308
|
-
if (isDeepgramError(error)) {
|
|
309
|
-
return { result: null, error };
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
throw error;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* @see https://developers.deepgram.com/reference/update-scope
|
|
318
|
-
*/
|
|
319
|
-
async updateProjectMemberScope(
|
|
320
|
-
projectId: string,
|
|
321
|
-
memberId: string,
|
|
322
|
-
options: UpdateProjectMemberScopeSchema,
|
|
323
|
-
endpoint = "v1/projects/:projectId/members/:memberId/scopes"
|
|
324
|
-
): Promise<DeepgramResponse<MessageResponse>> {
|
|
325
|
-
try {
|
|
326
|
-
const url = new URL(this.baseUrl);
|
|
327
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
328
|
-
|
|
329
|
-
const body = JSON.stringify(options);
|
|
330
|
-
|
|
331
|
-
const result: MessageResponse = await this.put(this.fetch as Fetch, url, body);
|
|
332
|
-
|
|
333
|
-
return { result, error: null };
|
|
334
|
-
} catch (error) {
|
|
335
|
-
if (isDeepgramError(error)) {
|
|
336
|
-
return { result: null, error };
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
throw error;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @see https://developers.deepgram.com/reference/list-invites
|
|
345
|
-
*/
|
|
346
|
-
async getProjectInvites(
|
|
347
|
-
projectId: string,
|
|
348
|
-
endpoint = "v1/projects/:projectId/invites"
|
|
349
|
-
): Promise<DeepgramResponse<GetProjectInvitesResponse>> {
|
|
350
|
-
try {
|
|
351
|
-
const url = new URL(this.baseUrl);
|
|
352
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
353
|
-
|
|
354
|
-
const result: GetProjectInvitesResponse = await this.get(this.fetch as Fetch, url);
|
|
355
|
-
|
|
356
|
-
return { result, error: null };
|
|
357
|
-
} catch (error) {
|
|
358
|
-
if (isDeepgramError(error)) {
|
|
359
|
-
return { result: null, error };
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
throw error;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* @see https://developers.deepgram.com/reference/send-invites
|
|
368
|
-
*/
|
|
369
|
-
async sendProjectInvite(
|
|
370
|
-
projectId: string,
|
|
371
|
-
options: SendProjectInviteSchema,
|
|
372
|
-
endpoint = "v1/projects/:projectId/invites"
|
|
373
|
-
): Promise<DeepgramResponse<MessageResponse>> {
|
|
374
|
-
try {
|
|
375
|
-
const url = new URL(this.baseUrl);
|
|
376
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
377
|
-
|
|
378
|
-
const body = JSON.stringify(options);
|
|
379
|
-
|
|
380
|
-
const result: MessageResponse = await this.post(this.fetch as Fetch, url, body);
|
|
381
|
-
|
|
382
|
-
return { result, error: null };
|
|
383
|
-
} catch (error) {
|
|
384
|
-
if (isDeepgramError(error)) {
|
|
385
|
-
return { result: null, error };
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
throw error;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* @see https://developers.deepgram.com/reference/delete-invite
|
|
394
|
-
*/
|
|
395
|
-
async deleteProjectInvite(
|
|
396
|
-
projectId: string,
|
|
397
|
-
email: string,
|
|
398
|
-
endpoint = "v1/projects/:projectId/invites/:email"
|
|
399
|
-
): Promise<VoidResponse> {
|
|
400
|
-
try {
|
|
401
|
-
const url = new URL(this.baseUrl);
|
|
402
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:email/, email);
|
|
403
|
-
|
|
404
|
-
await this.delete(this.fetch as Fetch, url);
|
|
405
|
-
|
|
406
|
-
return { error: null };
|
|
407
|
-
} catch (error) {
|
|
408
|
-
if (isDeepgramError(error)) {
|
|
409
|
-
return { error };
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
throw error;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* @see https://developers.deepgram.com/reference/leave-project
|
|
418
|
-
*/
|
|
419
|
-
async leaveProject(
|
|
420
|
-
projectId: string,
|
|
421
|
-
endpoint = "v1/projects/:projectId/leave"
|
|
422
|
-
): Promise<DeepgramResponse<MessageResponse>> {
|
|
423
|
-
try {
|
|
424
|
-
const url = new URL(this.baseUrl);
|
|
425
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
426
|
-
|
|
427
|
-
const result: MessageResponse = await this.delete(this.fetch as Fetch, url);
|
|
428
|
-
|
|
429
|
-
return { result, error: null };
|
|
430
|
-
} catch (error) {
|
|
431
|
-
if (isDeepgramError(error)) {
|
|
432
|
-
return { result: null, error };
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
throw error;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* @see https://developers.deepgram.com/reference/get-all-requests
|
|
441
|
-
*/
|
|
442
|
-
async getProjectUsageRequests(
|
|
443
|
-
projectId: string,
|
|
444
|
-
options: GetProjectUsageRequestsSchema,
|
|
445
|
-
endpoint = "v1/projects/:projectId/requests"
|
|
446
|
-
): Promise<DeepgramResponse<GetProjectUsageRequestsResponse>> {
|
|
447
|
-
try {
|
|
448
|
-
const url = new URL(this.baseUrl);
|
|
449
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
450
|
-
appendSearchParams(url.searchParams, options);
|
|
451
|
-
|
|
452
|
-
const result: GetProjectUsageRequestsResponse = await this.get(this.fetch as Fetch, url);
|
|
453
|
-
|
|
454
|
-
return { result, error: null };
|
|
455
|
-
} catch (error) {
|
|
456
|
-
if (isDeepgramError(error)) {
|
|
457
|
-
return { result: null, error };
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
throw error;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* @see https://developers.deepgram.com/reference/get-request
|
|
466
|
-
*/
|
|
467
|
-
async getProjectUsageRequest(
|
|
468
|
-
projectId: string,
|
|
469
|
-
requestId: string,
|
|
470
|
-
endpoint = "v1/projects/:projectId/requests/:requestId"
|
|
471
|
-
): Promise<DeepgramResponse<GetProjectUsageRequestResponse>> {
|
|
472
|
-
try {
|
|
473
|
-
const url = new URL(this.baseUrl);
|
|
474
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:requestId/, requestId);
|
|
475
|
-
|
|
476
|
-
const result: GetProjectUsageRequestResponse = await this.get(this.fetch as Fetch, url);
|
|
477
|
-
|
|
478
|
-
return { result, error: null };
|
|
479
|
-
} catch (error) {
|
|
480
|
-
if (isDeepgramError(error)) {
|
|
481
|
-
return { result: null, error };
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
throw error;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* @see https://developers.deepgram.com/reference/summarize-usage
|
|
490
|
-
*/
|
|
491
|
-
async getProjectUsageSummary(
|
|
492
|
-
projectId: string,
|
|
493
|
-
options: GetProjectUsageSummarySchema,
|
|
494
|
-
endpoint = "v1/projects/:projectId/usage"
|
|
495
|
-
): Promise<DeepgramResponse<GetProjectUsageSummaryResponse>> {
|
|
496
|
-
try {
|
|
497
|
-
const url = new URL(this.baseUrl);
|
|
498
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
499
|
-
appendSearchParams(url.searchParams, options);
|
|
500
|
-
|
|
501
|
-
const result: GetProjectUsageSummaryResponse = await this.get(this.fetch as Fetch, url);
|
|
502
|
-
|
|
503
|
-
return { result, error: null };
|
|
504
|
-
} catch (error) {
|
|
505
|
-
if (isDeepgramError(error)) {
|
|
506
|
-
return { result: null, error };
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
throw error;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* @see https://developers.deepgram.com/reference/get-fields
|
|
515
|
-
*/
|
|
516
|
-
async getProjectUsageFields(
|
|
517
|
-
projectId: string,
|
|
518
|
-
options: GetProjectUsageFieldsSchema,
|
|
519
|
-
endpoint = "v1/projects/:projectId/usage/fields"
|
|
520
|
-
): Promise<DeepgramResponse<GetProjectUsageFieldsResponse>> {
|
|
521
|
-
try {
|
|
522
|
-
const url = new URL(this.baseUrl);
|
|
523
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
524
|
-
appendSearchParams(url.searchParams, options);
|
|
525
|
-
|
|
526
|
-
const result: GetProjectUsageFieldsResponse = await this.get(this.fetch as Fetch, url);
|
|
527
|
-
|
|
528
|
-
return { result, error: null };
|
|
529
|
-
} catch (error) {
|
|
530
|
-
if (isDeepgramError(error)) {
|
|
531
|
-
return { result: null, error };
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
throw error;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* @see https://developers.deepgram.com/reference/get-all-balances
|
|
540
|
-
*/
|
|
541
|
-
async getProjectBalances(
|
|
542
|
-
projectId: string,
|
|
543
|
-
endpoint = "v1/projects/:projectId/balances"
|
|
544
|
-
): Promise<DeepgramResponse<GetProjectBalancesResponse>> {
|
|
545
|
-
try {
|
|
546
|
-
const url = new URL(this.baseUrl);
|
|
547
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
548
|
-
|
|
549
|
-
const result: GetProjectBalancesResponse = await this.get(this.fetch as Fetch, url);
|
|
550
|
-
|
|
551
|
-
return { result, error: null };
|
|
552
|
-
} catch (error) {
|
|
553
|
-
if (isDeepgramError(error)) {
|
|
554
|
-
return { result: null, error };
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
throw error;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* @see https://developers.deepgram.com/reference/get-balance
|
|
563
|
-
*/
|
|
564
|
-
async getProjectBalance(
|
|
565
|
-
projectId: string,
|
|
566
|
-
balanceId: string,
|
|
567
|
-
endpoint = "v1/projects/:projectId/balances/:balanceId"
|
|
568
|
-
): Promise<DeepgramResponse<GetProjectBalanceResponse>> {
|
|
569
|
-
try {
|
|
570
|
-
const url = new URL(this.baseUrl);
|
|
571
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:balanceId/, balanceId);
|
|
572
|
-
|
|
573
|
-
const result: GetProjectBalanceResponse = await this.get(this.fetch as Fetch, url);
|
|
574
|
-
|
|
575
|
-
return { result, error: null };
|
|
576
|
-
} catch (error) {
|
|
577
|
-
if (isDeepgramError(error)) {
|
|
578
|
-
return { result: null, error };
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
throw error;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
2
|
-
import { isDeepgramError } from "../lib/errors";
|
|
3
|
-
import type {
|
|
4
|
-
CreateOnPremCredentialsSchema,
|
|
5
|
-
DeepgramResponse,
|
|
6
|
-
Fetch,
|
|
7
|
-
ListOnPremCredentialsResponse,
|
|
8
|
-
MessageResponse,
|
|
9
|
-
OnPremCredentialResponse,
|
|
10
|
-
} from "../lib/types";
|
|
11
|
-
|
|
12
|
-
export class OnPremClient extends AbstractRestfulClient {
|
|
13
|
-
/**
|
|
14
|
-
* @see https://developers.deepgram.com/reference/list-credentials
|
|
15
|
-
*/
|
|
16
|
-
async listCredentials(
|
|
17
|
-
projectId: string,
|
|
18
|
-
endpoint = "v1/projects/:projectId/onprem/distribution/credentials"
|
|
19
|
-
): Promise<DeepgramResponse<ListOnPremCredentialsResponse>> {
|
|
20
|
-
try {
|
|
21
|
-
const url = new URL(this.baseUrl);
|
|
22
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
23
|
-
|
|
24
|
-
const result: ListOnPremCredentialsResponse = await this.get(this.fetch as Fetch, url);
|
|
25
|
-
|
|
26
|
-
return { result, error: null };
|
|
27
|
-
} catch (error) {
|
|
28
|
-
if (isDeepgramError(error)) {
|
|
29
|
-
return { result: null, error };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @see https://developers.deepgram.com/reference/get-credentials
|
|
38
|
-
*/
|
|
39
|
-
async getCredentials(
|
|
40
|
-
projectId: string,
|
|
41
|
-
credentialsId: string,
|
|
42
|
-
endpoint = "v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"
|
|
43
|
-
): Promise<DeepgramResponse<OnPremCredentialResponse>> {
|
|
44
|
-
try {
|
|
45
|
-
const url = new URL(this.baseUrl);
|
|
46
|
-
url.pathname = endpoint
|
|
47
|
-
.replace(/:projectId/, projectId)
|
|
48
|
-
.replace(/:credentialsId/, credentialsId);
|
|
49
|
-
|
|
50
|
-
const result: OnPremCredentialResponse = await this.get(this.fetch as Fetch, url);
|
|
51
|
-
|
|
52
|
-
return { result, error: null };
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if (isDeepgramError(error)) {
|
|
55
|
-
return { result: null, error };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @see https://developers.deepgram.com/reference/create-credentials
|
|
64
|
-
*/
|
|
65
|
-
async createCredentials(
|
|
66
|
-
projectId: string,
|
|
67
|
-
options: CreateOnPremCredentialsSchema,
|
|
68
|
-
endpoint = "v1/projects/:projectId/onprem/distribution/credentials"
|
|
69
|
-
): Promise<DeepgramResponse<OnPremCredentialResponse>> {
|
|
70
|
-
try {
|
|
71
|
-
const url = new URL(this.baseUrl);
|
|
72
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
73
|
-
|
|
74
|
-
const body = JSON.stringify(options);
|
|
75
|
-
|
|
76
|
-
const result: OnPremCredentialResponse = await this.post(this.fetch as Fetch, url, body);
|
|
77
|
-
|
|
78
|
-
return { result, error: null };
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (isDeepgramError(error)) {
|
|
81
|
-
return { result: null, error };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @see https://developers.deepgram.com/reference/delete-credentials
|
|
90
|
-
*/
|
|
91
|
-
async deleteCredentials(
|
|
92
|
-
projectId: string,
|
|
93
|
-
credentialsId: string,
|
|
94
|
-
endpoint = "v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"
|
|
95
|
-
): Promise<DeepgramResponse<MessageResponse>> {
|
|
96
|
-
try {
|
|
97
|
-
const url = new URL(this.baseUrl);
|
|
98
|
-
url.pathname = endpoint
|
|
99
|
-
.replace(/:projectId/, projectId)
|
|
100
|
-
.replace(/:credentialsId/, credentialsId);
|
|
101
|
-
|
|
102
|
-
const result: MessageResponse = await this.delete(this.fetch as Fetch, url);
|
|
103
|
-
|
|
104
|
-
return { result, error: null };
|
|
105
|
-
} catch (error) {
|
|
106
|
-
if (isDeepgramError(error)) {
|
|
107
|
-
return { result: null, error };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|