@deepgram/sdk 3.3.4 → 3.4.0
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/SyncPrerecordedResponse.d.ts +1 -0
- package/dist/main/lib/types/SyncPrerecordedResponse.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/SyncPrerecordedResponse.d.ts +1 -0
- package/dist/module/lib/types/SyncPrerecordedResponse.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/SyncPrerecordedResponse.ts +1 -0
- 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,106 +0,0 @@
|
|
|
1
|
-
import { AbstractWsClient } from "./AbstractWsClient";
|
|
2
|
-
import { appendSearchParams } from "../lib/helpers";
|
|
3
|
-
import { DeepgramError } from "../lib/errors";
|
|
4
|
-
import { DEFAULT_OPTIONS } from "../lib/constants";
|
|
5
|
-
import { LiveConnectionState, LiveTranscriptionEvents } from "../lib/enums";
|
|
6
|
-
import { w3cwebsocket } from "websocket";
|
|
7
|
-
export class LiveClient extends AbstractWsClient {
|
|
8
|
-
constructor(key, options = DEFAULT_OPTIONS, transcriptionOptions = {}, endpoint = "v1/listen") {
|
|
9
|
-
super(key, options);
|
|
10
|
-
this.key = key;
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.transcriptionOptions = transcriptionOptions;
|
|
13
|
-
const url = new URL(endpoint, this.baseUrl);
|
|
14
|
-
url.protocol = url.protocol.toLowerCase().replace(/(http)(s)?/gi, "ws$2");
|
|
15
|
-
appendSearchParams(url.searchParams, this.transcriptionOptions);
|
|
16
|
-
this._socket = new w3cwebsocket(url.toString(), ["token", this.key]);
|
|
17
|
-
this._socket.onopen = () => {
|
|
18
|
-
this.emit(LiveTranscriptionEvents.Open, this);
|
|
19
|
-
};
|
|
20
|
-
this._socket.onclose = (event) => {
|
|
21
|
-
this.emit(LiveTranscriptionEvents.Close, event);
|
|
22
|
-
};
|
|
23
|
-
this._socket.onerror = (event) => {
|
|
24
|
-
this.emit(LiveTranscriptionEvents.Error, event);
|
|
25
|
-
};
|
|
26
|
-
this._socket.onmessage = (event) => {
|
|
27
|
-
try {
|
|
28
|
-
const data = JSON.parse(event.data.toString());
|
|
29
|
-
if (data.type === LiveTranscriptionEvents.Metadata) {
|
|
30
|
-
this.emit(LiveTranscriptionEvents.Metadata, data);
|
|
31
|
-
}
|
|
32
|
-
if (data.type === LiveTranscriptionEvents.Transcript) {
|
|
33
|
-
this.emit(LiveTranscriptionEvents.Transcript, data);
|
|
34
|
-
}
|
|
35
|
-
if (data.type === LiveTranscriptionEvents.UtteranceEnd) {
|
|
36
|
-
this.emit(LiveTranscriptionEvents.UtteranceEnd, data);
|
|
37
|
-
}
|
|
38
|
-
if (data.type === LiveTranscriptionEvents.SpeechStarted) {
|
|
39
|
-
this.emit(LiveTranscriptionEvents.SpeechStarted, data);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
this.emit(LiveTranscriptionEvents.Error, {
|
|
44
|
-
event,
|
|
45
|
-
message: "Unable to parse `data` as JSON.",
|
|
46
|
-
error,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
configure(config) {
|
|
52
|
-
this._socket.send(JSON.stringify({
|
|
53
|
-
type: "Configure",
|
|
54
|
-
processors: config,
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
keepAlive() {
|
|
58
|
-
this._socket.send(JSON.stringify({
|
|
59
|
-
type: "KeepAlive",
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
62
|
-
getReadyState() {
|
|
63
|
-
return this._socket.readyState;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Sends data to the Deepgram API via websocket connection
|
|
67
|
-
* @param data Audio data to send to Deepgram
|
|
68
|
-
*
|
|
69
|
-
* Conforms to RFC #146 for Node.js - does not send an empty byte.
|
|
70
|
-
* In the browser, a Blob will contain length with no audio.
|
|
71
|
-
* @see https://github.com/deepgram/deepgram-python-sdk/issues/146
|
|
72
|
-
*/
|
|
73
|
-
send(data) {
|
|
74
|
-
if (this._socket.readyState === LiveConnectionState.OPEN) {
|
|
75
|
-
if (typeof data === "string") {
|
|
76
|
-
this._socket.send(data); // send text data
|
|
77
|
-
}
|
|
78
|
-
else if (data instanceof Blob) {
|
|
79
|
-
this._socket.send(data); // send blob data
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
const buffer = data;
|
|
83
|
-
if (buffer.byteLength > 0) {
|
|
84
|
-
this._socket.send(buffer); // send buffer when not zero-byte (or browser)
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this.emit(LiveTranscriptionEvents.Warning, "Zero-byte detected, skipping. Send `CloseStream` if trying to close the connection.");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
throw new DeepgramError("Could not send. Connection not open.");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Denote that you are finished sending audio and close
|
|
97
|
-
* the websocket connection when transcription is finished
|
|
98
|
-
*/
|
|
99
|
-
finish() {
|
|
100
|
-
// tell the server to close the socket
|
|
101
|
-
this._socket.send(JSON.stringify({
|
|
102
|
-
type: "CloseStream",
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=LiveClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LiveClient.js","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MA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,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACI,IAAI,CAAC,IAAqC;QAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,mBAAmB,CAAC,IAAI,EAAE;YACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB;aAC3C;iBAAM,IAAK,IAAY,YAAY,IAAI,EAAE;gBACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAkC,CAAC,CAAC,CAAC,iBAAiB;aACzE;iBAAM;gBACL,MAAM,MAAM,GAAG,IAAuB,CAAC;gBAEvC,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE;oBACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,8CAA8C;iBAC1E;qBAAM;oBACL,IAAI,CAAC,IAAI,CACP,uBAAuB,CAAC,OAAO,EAC/B,qFAAqF,CACtF,CAAC;iBACH;aACF;SACF;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,sCAAsC,CAAC,CAAC;SACjE;IACH,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,sCAAsC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CACf,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,aAAa;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
2
|
-
import type { CreateProjectKeySchema, CreateProjectKeyResponse, DeepgramResponse, GetProjectBalanceResponse, GetProjectBalancesResponse, GetProjectInvitesResponse, GetProjectKeyResponse, GetProjectKeysResponse, GetProjectMemberScopesResponse, GetProjectMembersResponse, GetProjectResponse, GetProjectsResponse, GetProjectUsageFieldsSchema, GetProjectUsageFieldsResponse, GetProjectUsageRequestResponse, GetProjectUsageRequestsSchema, GetProjectUsageRequestsResponse, GetProjectUsageSummarySchema, GetProjectUsageSummaryResponse, MessageResponse, SendProjectInviteSchema, UpdateProjectMemberScopeSchema, UpdateProjectSchema, VoidResponse, GetTokenDetailsResponse } from "../lib/types";
|
|
3
|
-
export declare class ManageClient extends AbstractRestfulClient {
|
|
4
|
-
/**
|
|
5
|
-
* @see https://developers.deepgram.com/docs/authenticating#test-request
|
|
6
|
-
*/
|
|
7
|
-
getTokenDetails(endpoint?: string): Promise<DeepgramResponse<GetTokenDetailsResponse>>;
|
|
8
|
-
/**
|
|
9
|
-
* @see https://developers.deepgram.com/reference/get-projects
|
|
10
|
-
*/
|
|
11
|
-
getProjects(endpoint?: string): Promise<DeepgramResponse<GetProjectsResponse>>;
|
|
12
|
-
/**
|
|
13
|
-
* @see https://developers.deepgram.com/reference/get-project
|
|
14
|
-
*/
|
|
15
|
-
getProject(projectId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectResponse>>;
|
|
16
|
-
/**
|
|
17
|
-
* @see https://developers.deepgram.com/reference/update-project
|
|
18
|
-
*/
|
|
19
|
-
updateProject(projectId: string, options: UpdateProjectSchema, endpoint?: string): Promise<DeepgramResponse<MessageResponse>>;
|
|
20
|
-
/**
|
|
21
|
-
* @see https://developers.deepgram.com/reference/delete-project
|
|
22
|
-
*/
|
|
23
|
-
deleteProject(projectId: string, endpoint?: string): Promise<VoidResponse>;
|
|
24
|
-
/**
|
|
25
|
-
* @see https://developers.deepgram.com/reference/list-keys
|
|
26
|
-
*/
|
|
27
|
-
getProjectKeys(projectId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectKeysResponse>>;
|
|
28
|
-
/**
|
|
29
|
-
* @see https://developers.deepgram.com/reference/get-key
|
|
30
|
-
*/
|
|
31
|
-
getProjectKey(projectId: string, keyId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectKeyResponse>>;
|
|
32
|
-
/**
|
|
33
|
-
* @see https://developers.deepgram.com/reference/create-key
|
|
34
|
-
*/
|
|
35
|
-
createProjectKey(projectId: string, options: CreateProjectKeySchema, endpoint?: string): Promise<DeepgramResponse<CreateProjectKeyResponse>>;
|
|
36
|
-
/**
|
|
37
|
-
* @see https://developers.deepgram.com/reference/delete-key
|
|
38
|
-
*/
|
|
39
|
-
deleteProjectKey(projectId: string, keyId: string, endpoint?: string): Promise<VoidResponse>;
|
|
40
|
-
/**
|
|
41
|
-
* @see https://developers.deepgram.com/reference/get-members
|
|
42
|
-
*/
|
|
43
|
-
getProjectMembers(projectId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectMembersResponse>>;
|
|
44
|
-
/**
|
|
45
|
-
* @see https://developers.deepgram.com/reference/remove-member
|
|
46
|
-
*/
|
|
47
|
-
removeProjectMember(projectId: string, memberId: string, endpoint?: string): Promise<VoidResponse>;
|
|
48
|
-
/**
|
|
49
|
-
* @see https://developers.deepgram.com/reference/get-member-scopes
|
|
50
|
-
*/
|
|
51
|
-
getProjectMemberScopes(projectId: string, memberId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectMemberScopesResponse>>;
|
|
52
|
-
/**
|
|
53
|
-
* @see https://developers.deepgram.com/reference/update-scope
|
|
54
|
-
*/
|
|
55
|
-
updateProjectMemberScope(projectId: string, memberId: string, options: UpdateProjectMemberScopeSchema, endpoint?: string): Promise<DeepgramResponse<MessageResponse>>;
|
|
56
|
-
/**
|
|
57
|
-
* @see https://developers.deepgram.com/reference/list-invites
|
|
58
|
-
*/
|
|
59
|
-
getProjectInvites(projectId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectInvitesResponse>>;
|
|
60
|
-
/**
|
|
61
|
-
* @see https://developers.deepgram.com/reference/send-invites
|
|
62
|
-
*/
|
|
63
|
-
sendProjectInvite(projectId: string, options: SendProjectInviteSchema, endpoint?: string): Promise<DeepgramResponse<MessageResponse>>;
|
|
64
|
-
/**
|
|
65
|
-
* @see https://developers.deepgram.com/reference/delete-invite
|
|
66
|
-
*/
|
|
67
|
-
deleteProjectInvite(projectId: string, email: string, endpoint?: string): Promise<VoidResponse>;
|
|
68
|
-
/**
|
|
69
|
-
* @see https://developers.deepgram.com/reference/leave-project
|
|
70
|
-
*/
|
|
71
|
-
leaveProject(projectId: string, endpoint?: string): Promise<DeepgramResponse<MessageResponse>>;
|
|
72
|
-
/**
|
|
73
|
-
* @see https://developers.deepgram.com/reference/get-all-requests
|
|
74
|
-
*/
|
|
75
|
-
getProjectUsageRequests(projectId: string, options: GetProjectUsageRequestsSchema, endpoint?: string): Promise<DeepgramResponse<GetProjectUsageRequestsResponse>>;
|
|
76
|
-
/**
|
|
77
|
-
* @see https://developers.deepgram.com/reference/get-request
|
|
78
|
-
*/
|
|
79
|
-
getProjectUsageRequest(projectId: string, requestId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectUsageRequestResponse>>;
|
|
80
|
-
/**
|
|
81
|
-
* @see https://developers.deepgram.com/reference/summarize-usage
|
|
82
|
-
*/
|
|
83
|
-
getProjectUsageSummary(projectId: string, options: GetProjectUsageSummarySchema, endpoint?: string): Promise<DeepgramResponse<GetProjectUsageSummaryResponse>>;
|
|
84
|
-
/**
|
|
85
|
-
* @see https://developers.deepgram.com/reference/get-fields
|
|
86
|
-
*/
|
|
87
|
-
getProjectUsageFields(projectId: string, options: GetProjectUsageFieldsSchema, endpoint?: string): Promise<DeepgramResponse<GetProjectUsageFieldsResponse>>;
|
|
88
|
-
/**
|
|
89
|
-
* @see https://developers.deepgram.com/reference/get-all-balances
|
|
90
|
-
*/
|
|
91
|
-
getProjectBalances(projectId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectBalancesResponse>>;
|
|
92
|
-
/**
|
|
93
|
-
* @see https://developers.deepgram.com/reference/get-balance
|
|
94
|
-
*/
|
|
95
|
-
getProjectBalance(projectId: string, balanceId: string, endpoint?: string): Promise<DeepgramResponse<GetProjectBalanceResponse>>;
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=ManageClient.d.ts.map
|
|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O,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC;CAgBxD"}
|
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
11
|
-
import { isDeepgramError } from "../lib/errors";
|
|
12
|
-
import { appendSearchParams } from "../lib/helpers";
|
|
13
|
-
export class ManageClient extends AbstractRestfulClient {
|
|
14
|
-
/**
|
|
15
|
-
* @see https://developers.deepgram.com/docs/authenticating#test-request
|
|
16
|
-
*/
|
|
17
|
-
getTokenDetails(endpoint = "v1/auth/token") {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
try {
|
|
20
|
-
const url = new URL(this.baseUrl);
|
|
21
|
-
url.pathname = endpoint;
|
|
22
|
-
const result = yield this.get(this.fetch, url);
|
|
23
|
-
return { result, error: null };
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
if (isDeepgramError(error)) {
|
|
27
|
-
return { result: null, error };
|
|
28
|
-
}
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @see https://developers.deepgram.com/reference/get-projects
|
|
35
|
-
*/
|
|
36
|
-
getProjects(endpoint = "v1/projects") {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
try {
|
|
39
|
-
const url = new URL(this.baseUrl);
|
|
40
|
-
url.pathname = endpoint;
|
|
41
|
-
const result = yield this.get(this.fetch, url);
|
|
42
|
-
return { result, error: null };
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
if (isDeepgramError(error)) {
|
|
46
|
-
return { result: null, error };
|
|
47
|
-
}
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* @see https://developers.deepgram.com/reference/get-project
|
|
54
|
-
*/
|
|
55
|
-
getProject(projectId, endpoint = "v1/projects/:projectId") {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
try {
|
|
58
|
-
const url = new URL(this.baseUrl);
|
|
59
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
60
|
-
const result = yield this.get(this.fetch, url);
|
|
61
|
-
return { result, error: null };
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
if (isDeepgramError(error)) {
|
|
65
|
-
return { result: null, error };
|
|
66
|
-
}
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @see https://developers.deepgram.com/reference/update-project
|
|
73
|
-
*/
|
|
74
|
-
updateProject(projectId, options, endpoint = "v1/projects/:projectId") {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
try {
|
|
77
|
-
const url = new URL(this.baseUrl);
|
|
78
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
79
|
-
const body = JSON.stringify(options);
|
|
80
|
-
const result = yield this.patch(this.fetch, url, body);
|
|
81
|
-
return { result, error: null };
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
if (isDeepgramError(error)) {
|
|
85
|
-
return { result: null, error };
|
|
86
|
-
}
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* @see https://developers.deepgram.com/reference/delete-project
|
|
93
|
-
*/
|
|
94
|
-
deleteProject(projectId, endpoint = "v1/projects/:projectId") {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
try {
|
|
97
|
-
const url = new URL(this.baseUrl);
|
|
98
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
99
|
-
yield this.delete(this.fetch, url);
|
|
100
|
-
return { error: null };
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
if (isDeepgramError(error)) {
|
|
104
|
-
return { error };
|
|
105
|
-
}
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @see https://developers.deepgram.com/reference/list-keys
|
|
112
|
-
*/
|
|
113
|
-
getProjectKeys(projectId, endpoint = "v1/projects/:projectId/keys") {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
try {
|
|
116
|
-
const url = new URL(this.baseUrl);
|
|
117
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
118
|
-
const result = yield this.get(this.fetch, url);
|
|
119
|
-
return { result, error: null };
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
if (isDeepgramError(error)) {
|
|
123
|
-
return { result: null, error };
|
|
124
|
-
}
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* @see https://developers.deepgram.com/reference/get-key
|
|
131
|
-
*/
|
|
132
|
-
getProjectKey(projectId, keyId, endpoint = "v1/projects/:projectId/keys/:keyId") {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
try {
|
|
135
|
-
const url = new URL(this.baseUrl);
|
|
136
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
137
|
-
const result = yield this.get(this.fetch, url);
|
|
138
|
-
return { result, error: null };
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
if (isDeepgramError(error)) {
|
|
142
|
-
return { result: null, error };
|
|
143
|
-
}
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @see https://developers.deepgram.com/reference/create-key
|
|
150
|
-
*/
|
|
151
|
-
createProjectKey(projectId, options, endpoint = "v1/projects/:projectId/keys") {
|
|
152
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
try {
|
|
154
|
-
const url = new URL(this.baseUrl);
|
|
155
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
156
|
-
const body = JSON.stringify(options);
|
|
157
|
-
const result = yield this.post(this.fetch, url, body);
|
|
158
|
-
return { result, error: null };
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
if (isDeepgramError(error)) {
|
|
162
|
-
return { result: null, error };
|
|
163
|
-
}
|
|
164
|
-
throw error;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* @see https://developers.deepgram.com/reference/delete-key
|
|
170
|
-
*/
|
|
171
|
-
deleteProjectKey(projectId, keyId, endpoint = "v1/projects/:projectId/keys/:keyId") {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
try {
|
|
174
|
-
const url = new URL(this.baseUrl);
|
|
175
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:keyId/, keyId);
|
|
176
|
-
yield this.delete(this.fetch, url);
|
|
177
|
-
return { error: null };
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
if (isDeepgramError(error)) {
|
|
181
|
-
return { error };
|
|
182
|
-
}
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* @see https://developers.deepgram.com/reference/get-members
|
|
189
|
-
*/
|
|
190
|
-
getProjectMembers(projectId, endpoint = "v1/projects/:projectId/members") {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
try {
|
|
193
|
-
const url = new URL(this.baseUrl);
|
|
194
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
195
|
-
const result = yield this.get(this.fetch, url);
|
|
196
|
-
return { result, error: null };
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
if (isDeepgramError(error)) {
|
|
200
|
-
return { result: null, error };
|
|
201
|
-
}
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @see https://developers.deepgram.com/reference/remove-member
|
|
208
|
-
*/
|
|
209
|
-
removeProjectMember(projectId, memberId, endpoint = "v1/projects/:projectId/members/:memberId") {
|
|
210
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
try {
|
|
212
|
-
const url = new URL(this.baseUrl);
|
|
213
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
214
|
-
yield this.delete(this.fetch, url);
|
|
215
|
-
return { error: null };
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
if (isDeepgramError(error)) {
|
|
219
|
-
return { error };
|
|
220
|
-
}
|
|
221
|
-
throw error;
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* @see https://developers.deepgram.com/reference/get-member-scopes
|
|
227
|
-
*/
|
|
228
|
-
getProjectMemberScopes(projectId, memberId, endpoint = "v1/projects/:projectId/members/:memberId/scopes") {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
try {
|
|
231
|
-
const url = new URL(this.baseUrl);
|
|
232
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
233
|
-
const result = yield this.get(this.fetch, url);
|
|
234
|
-
return { result, error: null };
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
if (isDeepgramError(error)) {
|
|
238
|
-
return { result: null, error };
|
|
239
|
-
}
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* @see https://developers.deepgram.com/reference/update-scope
|
|
246
|
-
*/
|
|
247
|
-
updateProjectMemberScope(projectId, memberId, options, endpoint = "v1/projects/:projectId/members/:memberId/scopes") {
|
|
248
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
try {
|
|
250
|
-
const url = new URL(this.baseUrl);
|
|
251
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:memberId/, memberId);
|
|
252
|
-
const body = JSON.stringify(options);
|
|
253
|
-
const result = yield this.put(this.fetch, url, body);
|
|
254
|
-
return { result, error: null };
|
|
255
|
-
}
|
|
256
|
-
catch (error) {
|
|
257
|
-
if (isDeepgramError(error)) {
|
|
258
|
-
return { result: null, error };
|
|
259
|
-
}
|
|
260
|
-
throw error;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @see https://developers.deepgram.com/reference/list-invites
|
|
266
|
-
*/
|
|
267
|
-
getProjectInvites(projectId, endpoint = "v1/projects/:projectId/invites") {
|
|
268
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
try {
|
|
270
|
-
const url = new URL(this.baseUrl);
|
|
271
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
272
|
-
const result = yield this.get(this.fetch, url);
|
|
273
|
-
return { result, error: null };
|
|
274
|
-
}
|
|
275
|
-
catch (error) {
|
|
276
|
-
if (isDeepgramError(error)) {
|
|
277
|
-
return { result: null, error };
|
|
278
|
-
}
|
|
279
|
-
throw error;
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* @see https://developers.deepgram.com/reference/send-invites
|
|
285
|
-
*/
|
|
286
|
-
sendProjectInvite(projectId, options, endpoint = "v1/projects/:projectId/invites") {
|
|
287
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
-
try {
|
|
289
|
-
const url = new URL(this.baseUrl);
|
|
290
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
291
|
-
const body = JSON.stringify(options);
|
|
292
|
-
const result = yield this.post(this.fetch, url, body);
|
|
293
|
-
return { result, error: null };
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
if (isDeepgramError(error)) {
|
|
297
|
-
return { result: null, error };
|
|
298
|
-
}
|
|
299
|
-
throw error;
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* @see https://developers.deepgram.com/reference/delete-invite
|
|
305
|
-
*/
|
|
306
|
-
deleteProjectInvite(projectId, email, endpoint = "v1/projects/:projectId/invites/:email") {
|
|
307
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
-
try {
|
|
309
|
-
const url = new URL(this.baseUrl);
|
|
310
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:email/, email);
|
|
311
|
-
yield this.delete(this.fetch, url);
|
|
312
|
-
return { error: null };
|
|
313
|
-
}
|
|
314
|
-
catch (error) {
|
|
315
|
-
if (isDeepgramError(error)) {
|
|
316
|
-
return { error };
|
|
317
|
-
}
|
|
318
|
-
throw error;
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* @see https://developers.deepgram.com/reference/leave-project
|
|
324
|
-
*/
|
|
325
|
-
leaveProject(projectId, endpoint = "v1/projects/:projectId/leave") {
|
|
326
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
-
try {
|
|
328
|
-
const url = new URL(this.baseUrl);
|
|
329
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
330
|
-
const result = yield this.delete(this.fetch, url);
|
|
331
|
-
return { result, error: null };
|
|
332
|
-
}
|
|
333
|
-
catch (error) {
|
|
334
|
-
if (isDeepgramError(error)) {
|
|
335
|
-
return { result: null, error };
|
|
336
|
-
}
|
|
337
|
-
throw error;
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* @see https://developers.deepgram.com/reference/get-all-requests
|
|
343
|
-
*/
|
|
344
|
-
getProjectUsageRequests(projectId, options, endpoint = "v1/projects/:projectId/requests") {
|
|
345
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
-
try {
|
|
347
|
-
const url = new URL(this.baseUrl);
|
|
348
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
349
|
-
appendSearchParams(url.searchParams, options);
|
|
350
|
-
const result = yield this.get(this.fetch, url);
|
|
351
|
-
return { result, error: null };
|
|
352
|
-
}
|
|
353
|
-
catch (error) {
|
|
354
|
-
if (isDeepgramError(error)) {
|
|
355
|
-
return { result: null, error };
|
|
356
|
-
}
|
|
357
|
-
throw error;
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* @see https://developers.deepgram.com/reference/get-request
|
|
363
|
-
*/
|
|
364
|
-
getProjectUsageRequest(projectId, requestId, endpoint = "v1/projects/:projectId/requests/:requestId") {
|
|
365
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
-
try {
|
|
367
|
-
const url = new URL(this.baseUrl);
|
|
368
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:requestId/, requestId);
|
|
369
|
-
const result = yield this.get(this.fetch, url);
|
|
370
|
-
return { result, error: null };
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
if (isDeepgramError(error)) {
|
|
374
|
-
return { result: null, error };
|
|
375
|
-
}
|
|
376
|
-
throw error;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* @see https://developers.deepgram.com/reference/summarize-usage
|
|
382
|
-
*/
|
|
383
|
-
getProjectUsageSummary(projectId, options, endpoint = "v1/projects/:projectId/usage") {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
-
try {
|
|
386
|
-
const url = new URL(this.baseUrl);
|
|
387
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
388
|
-
appendSearchParams(url.searchParams, options);
|
|
389
|
-
const result = yield this.get(this.fetch, url);
|
|
390
|
-
return { result, error: null };
|
|
391
|
-
}
|
|
392
|
-
catch (error) {
|
|
393
|
-
if (isDeepgramError(error)) {
|
|
394
|
-
return { result: null, error };
|
|
395
|
-
}
|
|
396
|
-
throw error;
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* @see https://developers.deepgram.com/reference/get-fields
|
|
402
|
-
*/
|
|
403
|
-
getProjectUsageFields(projectId, options, endpoint = "v1/projects/:projectId/usage/fields") {
|
|
404
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
try {
|
|
406
|
-
const url = new URL(this.baseUrl);
|
|
407
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
408
|
-
appendSearchParams(url.searchParams, options);
|
|
409
|
-
const result = yield this.get(this.fetch, url);
|
|
410
|
-
return { result, error: null };
|
|
411
|
-
}
|
|
412
|
-
catch (error) {
|
|
413
|
-
if (isDeepgramError(error)) {
|
|
414
|
-
return { result: null, error };
|
|
415
|
-
}
|
|
416
|
-
throw error;
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* @see https://developers.deepgram.com/reference/get-all-balances
|
|
422
|
-
*/
|
|
423
|
-
getProjectBalances(projectId, endpoint = "v1/projects/:projectId/balances") {
|
|
424
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
-
try {
|
|
426
|
-
const url = new URL(this.baseUrl);
|
|
427
|
-
url.pathname = endpoint.replace(/:projectId/, projectId);
|
|
428
|
-
const result = yield this.get(this.fetch, url);
|
|
429
|
-
return { result, error: null };
|
|
430
|
-
}
|
|
431
|
-
catch (error) {
|
|
432
|
-
if (isDeepgramError(error)) {
|
|
433
|
-
return { result: null, error };
|
|
434
|
-
}
|
|
435
|
-
throw error;
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* @see https://developers.deepgram.com/reference/get-balance
|
|
441
|
-
*/
|
|
442
|
-
getProjectBalance(projectId, balanceId, endpoint = "v1/projects/:projectId/balances/:balanceId") {
|
|
443
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
444
|
-
try {
|
|
445
|
-
const url = new URL(this.baseUrl);
|
|
446
|
-
url.pathname = endpoint.replace(/:projectId/, projectId).replace(/:balanceId/, balanceId);
|
|
447
|
-
const result = yield this.get(this.fetch, url);
|
|
448
|
-
return { result, error: null };
|
|
449
|
-
}
|
|
450
|
-
catch (error) {
|
|
451
|
-
if (isDeepgramError(error)) {
|
|
452
|
-
return { result: null, error };
|
|
453
|
-
}
|
|
454
|
-
throw error;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
//# sourceMappingURL=ManageClient.js.map
|