@deepgram/sdk 3.0.0-alpha.9 → 3.0.0-beta.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 +240 -99
- package/dist/main/DeepgramClient.d.ts +2 -7
- package/dist/main/DeepgramClient.d.ts.map +1 -1
- package/dist/main/DeepgramClient.js +5 -28
- package/dist/main/DeepgramClient.js.map +1 -1
- package/dist/main/index.d.ts +5 -0
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +9 -2
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.d.ts +4 -8
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +5 -1
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +5 -5
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types/DeepgramClientOptions.d.ts +6 -1
- package/dist/main/lib/types/DeepgramClientOptions.d.ts.map +1 -1
- package/dist/main/lib/types/Fetch.d.ts +6 -4
- package/dist/main/lib/types/Fetch.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectBalancesResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectBalancesResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectInvitesResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectInvitesResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectKeysResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectKeysResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectMembersResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectMembersResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectUsageFieldsResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectUsageFieldsResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectUsageRequestsResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectUsageRequestsResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectUsageSummaryResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectUsageSummaryResponse.d.ts.map +1 -1
- package/dist/main/lib/types/GetProjectsResponse.d.ts +1 -1
- package/dist/main/lib/types/GetProjectsResponse.d.ts.map +1 -1
- package/dist/main/lib/types/ListOnPremCredentialsResponse.d.ts +1 -1
- package/dist/main/lib/types/ListOnPremCredentialsResponse.d.ts.map +1 -1
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +11 -15
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts +16 -16
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/main/lib/types/TranscriptionSchema.d.ts +2 -2
- package/dist/main/lib/types/TranscriptionSchema.d.ts.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 +16 -0
- package/dist/main/packages/AbstractClient.d.ts.map +1 -0
- package/dist/main/packages/AbstractClient.js +51 -0
- package/dist/main/packages/AbstractClient.js.map +1 -0
- package/dist/main/packages/AbstractRestfulClient.d.ts +14 -12
- package/dist/main/packages/AbstractRestfulClient.d.ts.map +1 -1
- package/dist/main/packages/AbstractRestfulClient.js +28 -23
- package/dist/main/packages/AbstractRestfulClient.js.map +1 -1
- package/dist/main/packages/AbstractWsClient.d.ts +10 -0
- package/dist/main/packages/AbstractWsClient.d.ts.map +1 -0
- package/dist/main/packages/AbstractWsClient.js +33 -0
- package/dist/main/packages/AbstractWsClient.js.map +1 -0
- package/dist/main/packages/ListenClient.d.ts +4 -7
- package/dist/main/packages/ListenClient.d.ts.map +1 -1
- package/dist/main/packages/ListenClient.js +6 -10
- package/dist/main/packages/ListenClient.js.map +1 -1
- package/dist/main/packages/LiveClient.d.ts +10 -7
- package/dist/main/packages/LiveClient.d.ts.map +1 -1
- package/dist/main/packages/LiveClient.js +24 -15
- package/dist/main/packages/LiveClient.js.map +1 -1
- package/dist/main/packages/ManageClient.d.ts.map +1 -1
- package/dist/main/packages/ManageClient.js +22 -66
- package/dist/main/packages/ManageClient.js.map +1 -1
- package/dist/main/packages/OnPremClient.d.ts.map +1 -1
- package/dist/main/packages/OnPremClient.js +4 -12
- package/dist/main/packages/OnPremClient.js.map +1 -1
- package/dist/main/packages/PrerecordedClient.d.ts.map +1 -1
- package/dist/main/packages/PrerecordedClient.js +4 -12
- package/dist/main/packages/PrerecordedClient.js.map +1 -1
- package/dist/main/packages/index.d.ts +9 -0
- package/dist/main/packages/index.d.ts.map +1 -0
- package/dist/main/packages/index.js +20 -0
- package/dist/main/packages/index.js.map +1 -0
- package/dist/module/DeepgramClient.d.ts +2 -7
- package/dist/module/DeepgramClient.d.ts.map +1 -1
- package/dist/module/DeepgramClient.js +5 -28
- package/dist/module/DeepgramClient.js.map +1 -1
- package/dist/module/index.d.ts +5 -0
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +6 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.d.ts +4 -8
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +4 -0
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +2 -5
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types/DeepgramClientOptions.d.ts +6 -1
- package/dist/module/lib/types/DeepgramClientOptions.d.ts.map +1 -1
- package/dist/module/lib/types/Fetch.d.ts +6 -4
- package/dist/module/lib/types/Fetch.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectBalancesResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectBalancesResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectInvitesResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectInvitesResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectKeysResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectKeysResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectMembersResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectMembersResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectUsageFieldsResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectUsageFieldsResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectUsageRequestsResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectUsageRequestsResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectUsageSummaryResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectUsageSummaryResponse.d.ts.map +1 -1
- package/dist/module/lib/types/GetProjectsResponse.d.ts +1 -1
- package/dist/module/lib/types/GetProjectsResponse.d.ts.map +1 -1
- package/dist/module/lib/types/ListOnPremCredentialsResponse.d.ts +1 -1
- package/dist/module/lib/types/ListOnPremCredentialsResponse.d.ts.map +1 -1
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +11 -15
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts +16 -16
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/module/lib/types/TranscriptionSchema.d.ts +2 -2
- package/dist/module/lib/types/TranscriptionSchema.d.ts.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 +16 -0
- package/dist/module/packages/AbstractClient.d.ts.map +1 -0
- package/dist/module/packages/AbstractClient.js +47 -0
- package/dist/module/packages/AbstractClient.js.map +1 -0
- package/dist/module/packages/AbstractRestfulClient.d.ts +14 -12
- package/dist/module/packages/AbstractRestfulClient.d.ts.map +1 -1
- package/dist/module/packages/AbstractRestfulClient.js +29 -24
- package/dist/module/packages/AbstractRestfulClient.js.map +1 -1
- package/dist/module/packages/AbstractWsClient.d.ts +10 -0
- package/dist/module/packages/AbstractWsClient.d.ts.map +1 -0
- package/dist/module/packages/AbstractWsClient.js +29 -0
- package/dist/module/packages/AbstractWsClient.js.map +1 -0
- package/dist/module/packages/ListenClient.d.ts +4 -7
- package/dist/module/packages/ListenClient.d.ts.map +1 -1
- package/dist/module/packages/ListenClient.js +6 -10
- package/dist/module/packages/ListenClient.js.map +1 -1
- package/dist/module/packages/LiveClient.d.ts +10 -7
- package/dist/module/packages/LiveClient.d.ts.map +1 -1
- package/dist/module/packages/LiveClient.js +24 -15
- package/dist/module/packages/LiveClient.js.map +1 -1
- package/dist/module/packages/ManageClient.d.ts.map +1 -1
- package/dist/module/packages/ManageClient.js +22 -66
- package/dist/module/packages/ManageClient.js.map +1 -1
- package/dist/module/packages/OnPremClient.d.ts.map +1 -1
- package/dist/module/packages/OnPremClient.js +4 -12
- package/dist/module/packages/OnPremClient.js.map +1 -1
- package/dist/module/packages/PrerecordedClient.d.ts.map +1 -1
- package/dist/module/packages/PrerecordedClient.js +4 -12
- package/dist/module/packages/PrerecordedClient.js.map +1 -1
- package/dist/module/packages/index.d.ts +9 -0
- package/dist/module/packages/index.d.ts.map +1 -0
- package/dist/module/packages/index.js +9 -0
- package/dist/module/packages/index.js.map +1 -0
- package/dist/umd/deepgram.js +1 -1
- package/package.json +7 -1
- package/src/DeepgramClient.ts +5 -43
- package/src/index.ts +7 -1
- package/src/lib/constants.ts +6 -0
- package/src/lib/helpers.ts +2 -10
- package/src/lib/types/DeepgramClientOptions.ts +7 -1
- package/src/lib/types/Fetch.ts +15 -5
- package/src/lib/types/GetProjectBalancesResponse.ts +1 -1
- package/src/lib/types/GetProjectInvitesResponse.ts +1 -1
- package/src/lib/types/GetProjectKeysResponse.ts +1 -1
- package/src/lib/types/GetProjectMembersResponse.ts +1 -1
- package/src/lib/types/GetProjectUsageFieldsResponse.ts +1 -1
- package/src/lib/types/GetProjectUsageRequestsResponse.ts +1 -1
- package/src/lib/types/GetProjectUsageSummaryResponse.ts +1 -1
- package/src/lib/types/GetProjectsResponse.ts +1 -1
- package/src/lib/types/ListOnPremCredentialsResponse.ts +1 -1
- package/src/lib/types/LiveTranscriptionEvent.ts +11 -15
- package/src/lib/types/SyncPrerecordedResponse.ts +16 -16
- package/src/lib/types/TranscriptionSchema.ts +2 -2
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractClient.ts +57 -0
- package/src/packages/AbstractRestfulClient.ts +35 -26
- package/src/packages/AbstractWsClient.ts +42 -0
- package/src/packages/ListenClient.ts +6 -15
- package/src/packages/LiveClient.ts +29 -17
- package/src/packages/ManageClient.ts +22 -66
- package/src/packages/OnPremClient.ts +4 -12
- package/src/packages/PrerecordedClient.ts +4 -14
- package/src/packages/index.ts +8 -0
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractWsClient } from "./AbstractWsClient";
|
|
2
2
|
import { appendSearchParams, isBrowser } from "../lib/helpers";
|
|
3
|
-
import
|
|
3
|
+
import { DeepgramError } from "../lib/errors";
|
|
4
|
+
import { DEFAULT_OPTIONS } from "../lib/constants";
|
|
4
5
|
import { LiveConnectionState, LiveTranscriptionEvents } from "../lib/enums";
|
|
6
|
+
import WebSocket from "modern-isomorphic-ws";
|
|
7
|
+
|
|
5
8
|
import type {
|
|
6
9
|
LiveSchema,
|
|
7
10
|
LiveConfigOptions,
|
|
8
11
|
LiveMetadataEvent,
|
|
9
12
|
LiveTranscriptionEvent,
|
|
13
|
+
DeepgramClientOptions,
|
|
10
14
|
} from "../lib/types";
|
|
11
|
-
import { DEFAULT_HEADERS } from "../lib/constants";
|
|
12
15
|
|
|
13
|
-
export class LiveClient extends
|
|
16
|
+
export class LiveClient extends AbstractWsClient {
|
|
14
17
|
private _socket: WebSocket;
|
|
15
18
|
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
19
|
+
constructor(
|
|
20
|
+
protected key: string,
|
|
21
|
+
protected options: DeepgramClientOptions | undefined = DEFAULT_OPTIONS,
|
|
22
|
+
private transcriptionOptions: LiveSchema = {},
|
|
23
|
+
endpoint = "v1/listen"
|
|
24
|
+
) {
|
|
25
|
+
super(key, options);
|
|
18
26
|
|
|
19
|
-
const
|
|
20
|
-
const url = new URL(endpoint, baseUrl);
|
|
27
|
+
const url = new URL(endpoint, this.baseUrl);
|
|
21
28
|
url.protocol = url.protocol.toLowerCase().replace(/(http)(s)?/gi, "ws$2");
|
|
22
|
-
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
29
|
+
appendSearchParams(url.searchParams, this.transcriptionOptions);
|
|
23
30
|
|
|
24
31
|
if (isBrowser()) {
|
|
25
|
-
this._socket = new WebSocket(url.toString(), ["token",
|
|
32
|
+
this._socket = new WebSocket(url.toString(), ["token", this.key]);
|
|
26
33
|
} else {
|
|
27
34
|
this._socket = new WebSocket(url.toString(), {
|
|
28
35
|
headers: {
|
|
29
|
-
Authorization: `token ${
|
|
30
|
-
...
|
|
36
|
+
Authorization: `token ${this.key}`,
|
|
37
|
+
...this.options?.global?.headers,
|
|
31
38
|
},
|
|
32
39
|
});
|
|
33
40
|
}
|
|
@@ -101,16 +108,21 @@ export class LiveClient extends EventEmitter {
|
|
|
101
108
|
* Sends data to the Deepgram API via websocket connection
|
|
102
109
|
* @param data Audio data to send to Deepgram
|
|
103
110
|
*
|
|
104
|
-
* Conforms to RFC #146 - does not send an empty byte.
|
|
111
|
+
* Conforms to RFC #146 for Node.js - does not send an empty byte.
|
|
112
|
+
* In the browser, a Blob will contain length with no audio.
|
|
105
113
|
* @see https://github.com/deepgram/deepgram-python-sdk/issues/146
|
|
106
114
|
*/
|
|
107
|
-
public send(data: string | ArrayBufferLike |
|
|
115
|
+
public send(data: string | ArrayBufferLike | Blob): void {
|
|
108
116
|
if (this._socket.readyState === LiveConnectionState.OPEN) {
|
|
109
117
|
if (typeof data === "string") {
|
|
110
118
|
this._socket.send(data); // send text data
|
|
119
|
+
} else if ((data as any) instanceof Blob) {
|
|
120
|
+
this._socket.send(data as unknown as ArrayBufferLike); // send blob data
|
|
111
121
|
} else {
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
const buffer = data as ArrayBufferLike;
|
|
123
|
+
|
|
124
|
+
if (buffer.byteLength > 0) {
|
|
125
|
+
this._socket.send(buffer); // send buffer when not zero-byte (or browser)
|
|
114
126
|
} else {
|
|
115
127
|
this.emit(
|
|
116
128
|
LiveTranscriptionEvents.Warning,
|
|
@@ -119,7 +131,7 @@ export class LiveClient extends EventEmitter {
|
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
133
|
} else {
|
|
122
|
-
|
|
134
|
+
throw new DeepgramError("Could not send. Connection not open.");
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
137
|
|
|
@@ -38,9 +38,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
38
38
|
const url = new URL(this.baseUrl);
|
|
39
39
|
url.pathname = endpoint;
|
|
40
40
|
|
|
41
|
-
const result: GetProjectsResponse = await this.get(this.fetch as Fetch, url
|
|
42
|
-
headers: this.headers,
|
|
43
|
-
});
|
|
41
|
+
const result: GetProjectsResponse = await this.get(this.fetch as Fetch, url);
|
|
44
42
|
|
|
45
43
|
return { result, error: null };
|
|
46
44
|
} catch (error) {
|
|
@@ -63,9 +61,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
63
61
|
const url = new URL(this.baseUrl);
|
|
64
62
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
65
63
|
|
|
66
|
-
const result: GetProjectResponse = await this.get(this.fetch as Fetch, url
|
|
67
|
-
headers: this.headers,
|
|
68
|
-
});
|
|
64
|
+
const result: GetProjectResponse = await this.get(this.fetch as Fetch, url);
|
|
69
65
|
|
|
70
66
|
return { result, error: null };
|
|
71
67
|
} catch (error) {
|
|
@@ -91,9 +87,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
91
87
|
|
|
92
88
|
const body = JSON.stringify(options);
|
|
93
89
|
|
|
94
|
-
const result: MessageResponse = await this.patch(this.fetch as Fetch, url, body
|
|
95
|
-
headers: this.headers,
|
|
96
|
-
});
|
|
90
|
+
const result: MessageResponse = await this.patch(this.fetch as Fetch, url, body);
|
|
97
91
|
|
|
98
92
|
return { result, error: null };
|
|
99
93
|
} catch (error) {
|
|
@@ -116,9 +110,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
116
110
|
const url = new URL(this.baseUrl);
|
|
117
111
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
118
112
|
|
|
119
|
-
await this.delete(this.fetch as Fetch, url
|
|
120
|
-
headers: this.headers,
|
|
121
|
-
});
|
|
113
|
+
await this.delete(this.fetch as Fetch, url);
|
|
122
114
|
|
|
123
115
|
return { error: null };
|
|
124
116
|
} catch (error) {
|
|
@@ -141,9 +133,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
141
133
|
const url = new URL(this.baseUrl);
|
|
142
134
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
143
135
|
|
|
144
|
-
const result: GetProjectKeysResponse = await this.get(this.fetch as Fetch, url
|
|
145
|
-
headers: this.headers,
|
|
146
|
-
});
|
|
136
|
+
const result: GetProjectKeysResponse = await this.get(this.fetch as Fetch, url);
|
|
147
137
|
|
|
148
138
|
return { result, error: null };
|
|
149
139
|
} catch (error) {
|
|
@@ -167,9 +157,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
167
157
|
const url = new URL(this.baseUrl);
|
|
168
158
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
169
159
|
|
|
170
|
-
const result: GetProjectKeyResponse = await this.get(this.fetch as Fetch, url
|
|
171
|
-
headers: this.headers,
|
|
172
|
-
});
|
|
160
|
+
const result: GetProjectKeyResponse = await this.get(this.fetch as Fetch, url);
|
|
173
161
|
|
|
174
162
|
return { result, error: null };
|
|
175
163
|
} catch (error) {
|
|
@@ -195,9 +183,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
195
183
|
|
|
196
184
|
const body = JSON.stringify(options);
|
|
197
185
|
|
|
198
|
-
const result: CreateProjectKeyResponse = await this.post(this.fetch as Fetch, url, body
|
|
199
|
-
headers: this.headers,
|
|
200
|
-
});
|
|
186
|
+
const result: CreateProjectKeyResponse = await this.post(this.fetch as Fetch, url, body);
|
|
201
187
|
|
|
202
188
|
return { result, error: null };
|
|
203
189
|
} catch (error) {
|
|
@@ -221,9 +207,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
221
207
|
const url = new URL(this.baseUrl);
|
|
222
208
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
223
209
|
|
|
224
|
-
await this.delete(this.fetch as Fetch, url
|
|
225
|
-
headers: this.headers,
|
|
226
|
-
});
|
|
210
|
+
await this.delete(this.fetch as Fetch, url);
|
|
227
211
|
|
|
228
212
|
return { error: null };
|
|
229
213
|
} catch (error) {
|
|
@@ -246,9 +230,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
246
230
|
const url = new URL(this.baseUrl);
|
|
247
231
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
248
232
|
|
|
249
|
-
const result: GetProjectMembersResponse = await this.get(this.fetch as Fetch, url
|
|
250
|
-
headers: this.headers,
|
|
251
|
-
});
|
|
233
|
+
const result: GetProjectMembersResponse = await this.get(this.fetch as Fetch, url);
|
|
252
234
|
|
|
253
235
|
return { result, error: null };
|
|
254
236
|
} catch (error) {
|
|
@@ -272,9 +254,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
272
254
|
const url = new URL(this.baseUrl);
|
|
273
255
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
274
256
|
|
|
275
|
-
await this.delete(this.fetch as Fetch, url
|
|
276
|
-
headers: this.headers,
|
|
277
|
-
});
|
|
257
|
+
await this.delete(this.fetch as Fetch, url);
|
|
278
258
|
|
|
279
259
|
return { error: null };
|
|
280
260
|
} catch (error) {
|
|
@@ -298,9 +278,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
298
278
|
const url = new URL(this.baseUrl);
|
|
299
279
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
300
280
|
|
|
301
|
-
const result: GetProjectMemberScopesResponse = await this.get(this.fetch as Fetch, url
|
|
302
|
-
headers: this.headers,
|
|
303
|
-
});
|
|
281
|
+
const result: GetProjectMemberScopesResponse = await this.get(this.fetch as Fetch, url);
|
|
304
282
|
|
|
305
283
|
return { result, error: null };
|
|
306
284
|
} catch (error) {
|
|
@@ -327,9 +305,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
327
305
|
|
|
328
306
|
const body = JSON.stringify(options);
|
|
329
307
|
|
|
330
|
-
const result: MessageResponse = await this.put(this.fetch as Fetch, url, body
|
|
331
|
-
headers: this.headers,
|
|
332
|
-
});
|
|
308
|
+
const result: MessageResponse = await this.put(this.fetch as Fetch, url, body);
|
|
333
309
|
|
|
334
310
|
return { result, error: null };
|
|
335
311
|
} catch (error) {
|
|
@@ -352,9 +328,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
352
328
|
const url = new URL(this.baseUrl);
|
|
353
329
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
354
330
|
|
|
355
|
-
const result: GetProjectInvitesResponse = await this.get(this.fetch as Fetch, url
|
|
356
|
-
headers: this.headers,
|
|
357
|
-
});
|
|
331
|
+
const result: GetProjectInvitesResponse = await this.get(this.fetch as Fetch, url);
|
|
358
332
|
|
|
359
333
|
return { result, error: null };
|
|
360
334
|
} catch (error) {
|
|
@@ -380,9 +354,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
380
354
|
|
|
381
355
|
const body = JSON.stringify(options);
|
|
382
356
|
|
|
383
|
-
const result: MessageResponse = await this.post(this.fetch as Fetch, url, body
|
|
384
|
-
headers: this.headers,
|
|
385
|
-
});
|
|
357
|
+
const result: MessageResponse = await this.post(this.fetch as Fetch, url, body);
|
|
386
358
|
|
|
387
359
|
return { result, error: null };
|
|
388
360
|
} catch (error) {
|
|
@@ -406,9 +378,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
406
378
|
const url = new URL(this.baseUrl);
|
|
407
379
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:email/, email);
|
|
408
380
|
|
|
409
|
-
await this.delete(this.fetch as Fetch, url
|
|
410
|
-
headers: this.headers,
|
|
411
|
-
});
|
|
381
|
+
await this.delete(this.fetch as Fetch, url);
|
|
412
382
|
|
|
413
383
|
return { error: null };
|
|
414
384
|
} catch (error) {
|
|
@@ -431,9 +401,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
431
401
|
const url = new URL(this.baseUrl);
|
|
432
402
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
433
403
|
|
|
434
|
-
const result: MessageResponse = await this.delete(this.fetch as Fetch, url
|
|
435
|
-
headers: this.headers,
|
|
436
|
-
});
|
|
404
|
+
const result: MessageResponse = await this.delete(this.fetch as Fetch, url);
|
|
437
405
|
|
|
438
406
|
return { result, error: null };
|
|
439
407
|
} catch (error) {
|
|
@@ -458,9 +426,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
458
426
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
459
427
|
appendSearchParams(url.searchParams, options);
|
|
460
428
|
|
|
461
|
-
const result: GetProjectUsageRequestsResponse = await this.get(this.fetch as Fetch, url
|
|
462
|
-
headers: this.headers,
|
|
463
|
-
});
|
|
429
|
+
const result: GetProjectUsageRequestsResponse = await this.get(this.fetch as Fetch, url);
|
|
464
430
|
|
|
465
431
|
return { result, error: null };
|
|
466
432
|
} catch (error) {
|
|
@@ -484,9 +450,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
484
450
|
const url = new URL(this.baseUrl);
|
|
485
451
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:requestId/, requestId);
|
|
486
452
|
|
|
487
|
-
const result: GetProjectUsageRequestResponse = await this.get(this.fetch as Fetch, url
|
|
488
|
-
headers: this.headers,
|
|
489
|
-
});
|
|
453
|
+
const result: GetProjectUsageRequestResponse = await this.get(this.fetch as Fetch, url);
|
|
490
454
|
|
|
491
455
|
return { result, error: null };
|
|
492
456
|
} catch (error) {
|
|
@@ -511,9 +475,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
511
475
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
512
476
|
appendSearchParams(url.searchParams, options);
|
|
513
477
|
|
|
514
|
-
const result: GetProjectUsageSummaryResponse = await this.get(this.fetch as Fetch, url
|
|
515
|
-
headers: this.headers,
|
|
516
|
-
});
|
|
478
|
+
const result: GetProjectUsageSummaryResponse = await this.get(this.fetch as Fetch, url);
|
|
517
479
|
|
|
518
480
|
return { result, error: null };
|
|
519
481
|
} catch (error) {
|
|
@@ -538,9 +500,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
538
500
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
539
501
|
appendSearchParams(url.searchParams, options);
|
|
540
502
|
|
|
541
|
-
const result: GetProjectUsageFieldsResponse = await this.get(this.fetch as Fetch, url
|
|
542
|
-
headers: this.headers,
|
|
543
|
-
});
|
|
503
|
+
const result: GetProjectUsageFieldsResponse = await this.get(this.fetch as Fetch, url);
|
|
544
504
|
|
|
545
505
|
return { result, error: null };
|
|
546
506
|
} catch (error) {
|
|
@@ -563,9 +523,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
563
523
|
const url = new URL(this.baseUrl);
|
|
564
524
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
565
525
|
|
|
566
|
-
const result: GetProjectBalancesResponse = await this.get(this.fetch as Fetch, url
|
|
567
|
-
headers: this.headers,
|
|
568
|
-
});
|
|
526
|
+
const result: GetProjectBalancesResponse = await this.get(this.fetch as Fetch, url);
|
|
569
527
|
|
|
570
528
|
return { result, error: null };
|
|
571
529
|
} catch (error) {
|
|
@@ -589,9 +547,7 @@ export class ManageClient extends AbstractRestfulClient {
|
|
|
589
547
|
const url = new URL(this.baseUrl);
|
|
590
548
|
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:balanceId/, balanceId);
|
|
591
549
|
|
|
592
|
-
const result: GetProjectBalanceResponse = await this.get(this.fetch as Fetch, url
|
|
593
|
-
headers: this.headers,
|
|
594
|
-
});
|
|
550
|
+
const result: GetProjectBalanceResponse = await this.get(this.fetch as Fetch, url);
|
|
595
551
|
|
|
596
552
|
return { result, error: null };
|
|
597
553
|
} catch (error) {
|
|
@@ -21,9 +21,7 @@ export class OnPremClient extends AbstractRestfulClient {
|
|
|
21
21
|
const url = new URL(this.baseUrl);
|
|
22
22
|
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
23
23
|
|
|
24
|
-
const result: ListOnPremCredentialsResponse = await this.get(this.fetch as Fetch, url
|
|
25
|
-
headers: this.headers,
|
|
26
|
-
});
|
|
24
|
+
const result: ListOnPremCredentialsResponse = await this.get(this.fetch as Fetch, url);
|
|
27
25
|
|
|
28
26
|
return { result, error: null };
|
|
29
27
|
} catch (error) {
|
|
@@ -49,9 +47,7 @@ export class OnPremClient extends AbstractRestfulClient {
|
|
|
49
47
|
.replace(/:projectId/, projectId)
|
|
50
48
|
.replace(/:credentialsId/, credentialsId);
|
|
51
49
|
|
|
52
|
-
const result: OnPremCredentialResponse = await this.get(this.fetch as Fetch, url
|
|
53
|
-
headers: this.headers,
|
|
54
|
-
});
|
|
50
|
+
const result: OnPremCredentialResponse = await this.get(this.fetch as Fetch, url);
|
|
55
51
|
|
|
56
52
|
return { result, error: null };
|
|
57
53
|
} catch (error) {
|
|
@@ -77,9 +73,7 @@ export class OnPremClient extends AbstractRestfulClient {
|
|
|
77
73
|
|
|
78
74
|
const body = JSON.stringify(options);
|
|
79
75
|
|
|
80
|
-
const result: OnPremCredentialResponse = await this.post(this.fetch as Fetch, url, body
|
|
81
|
-
headers: this.headers,
|
|
82
|
-
});
|
|
76
|
+
const result: OnPremCredentialResponse = await this.post(this.fetch as Fetch, url, body);
|
|
83
77
|
|
|
84
78
|
return { result, error: null };
|
|
85
79
|
} catch (error) {
|
|
@@ -105,9 +99,7 @@ export class OnPremClient extends AbstractRestfulClient {
|
|
|
105
99
|
.replace(/:projectId/, projectId)
|
|
106
100
|
.replace(/:credentialsId/, credentialsId);
|
|
107
101
|
|
|
108
|
-
const result: MessageResponse = await this.delete(this.fetch as Fetch, url
|
|
109
|
-
headers: this.headers,
|
|
110
|
-
});
|
|
102
|
+
const result: MessageResponse = await this.delete(this.fetch as Fetch, url);
|
|
111
103
|
|
|
112
104
|
return { result, error: null };
|
|
113
105
|
} catch (error) {
|
|
@@ -37,9 +37,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
37
37
|
const url = new URL(endpoint, this.baseUrl);
|
|
38
38
|
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
39
39
|
|
|
40
|
-
const result: SyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body
|
|
41
|
-
headers: this.headers,
|
|
42
|
-
});
|
|
40
|
+
const result: SyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body);
|
|
43
41
|
|
|
44
42
|
return { result, error: null };
|
|
45
43
|
} catch (error) {
|
|
@@ -57,9 +55,6 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
57
55
|
endpoint = "v1/listen"
|
|
58
56
|
): Promise<DeepgramResponse<SyncPrerecordedResponse>> {
|
|
59
57
|
try {
|
|
60
|
-
// deepgram ignores the mimetype if it's not `application/json`
|
|
61
|
-
this.headers["Content-Type"] = "deepgram/audio+video";
|
|
62
|
-
|
|
63
58
|
let body;
|
|
64
59
|
|
|
65
60
|
if (isFileSource(source)) {
|
|
@@ -80,7 +75,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
80
75
|
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
81
76
|
|
|
82
77
|
const result: SyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body, {
|
|
83
|
-
|
|
78
|
+
"Content-Type": "deepgram/audio+video",
|
|
84
79
|
});
|
|
85
80
|
|
|
86
81
|
return { result, error: null };
|
|
@@ -116,9 +111,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
116
111
|
const url = new URL(endpoint, this.baseUrl);
|
|
117
112
|
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
118
113
|
|
|
119
|
-
const result: AsyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body
|
|
120
|
-
headers: this.headers,
|
|
121
|
-
});
|
|
114
|
+
const result: AsyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body);
|
|
122
115
|
|
|
123
116
|
return { result, error: null };
|
|
124
117
|
} catch (error) {
|
|
@@ -137,9 +130,6 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
137
130
|
endpoint = "v1/listen"
|
|
138
131
|
): Promise<DeepgramResponse<AsyncPrerecordedResponse>> {
|
|
139
132
|
try {
|
|
140
|
-
// deepgram ignores the mimetype if it's not `application/json`
|
|
141
|
-
this.headers["Content-Type"] = "deepgram/audio+video";
|
|
142
|
-
|
|
143
133
|
let body;
|
|
144
134
|
|
|
145
135
|
if (isFileSource(source)) {
|
|
@@ -157,7 +147,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
157
147
|
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
158
148
|
|
|
159
149
|
const result: AsyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body, {
|
|
160
|
-
|
|
150
|
+
"Content-Type": "deepgram/audio+video",
|
|
161
151
|
});
|
|
162
152
|
|
|
163
153
|
return { result, error: null };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AbstractClient } from "./AbstractClient";
|
|
2
|
+
export { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
3
|
+
export { AbstractWsClient } from "./AbstractWsClient";
|
|
4
|
+
export { ListenClient } from "./ListenClient";
|
|
5
|
+
export { LiveClient } from "./LiveClient";
|
|
6
|
+
export { ManageClient } from "./ManageClient";
|
|
7
|
+
export { OnPremClient } from "./OnPremClient";
|
|
8
|
+
export { PrerecordedClient } from "./PrerecordedClient";
|