@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.
Files changed (295) hide show
  1. package/README.md +129 -9
  2. package/dist/main/DeepgramClient.d.ts +65 -12
  3. package/dist/main/DeepgramClient.d.ts.map +1 -1
  4. package/dist/main/DeepgramClient.js +73 -18
  5. package/dist/main/DeepgramClient.js.map +1 -1
  6. package/dist/main/index.d.ts +13 -4
  7. package/dist/main/index.d.ts.map +1 -1
  8. package/dist/main/index.js +18 -8
  9. package/dist/main/index.js.map +1 -1
  10. package/dist/main/lib/constants.d.ts +16 -7
  11. package/dist/main/lib/constants.d.ts.map +1 -1
  12. package/dist/main/lib/constants.js +26 -9
  13. package/dist/main/lib/constants.js.map +1 -1
  14. package/dist/main/lib/enums/LiveConnectionState.d.ts +5 -0
  15. package/dist/main/lib/enums/LiveConnectionState.d.ts.map +1 -1
  16. package/dist/main/lib/enums/LiveConnectionState.js +5 -0
  17. package/dist/main/lib/enums/LiveConnectionState.js.map +1 -1
  18. package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts +24 -3
  19. package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
  20. package/dist/main/lib/enums/LiveTranscriptionEvents.js +23 -2
  21. package/dist/main/lib/enums/LiveTranscriptionEvents.js.map +1 -1
  22. package/dist/main/lib/enums/index.d.ts +2 -2
  23. package/dist/main/lib/enums/index.d.ts.map +1 -1
  24. package/dist/main/lib/enums/index.js +16 -5
  25. package/dist/main/lib/enums/index.js.map +1 -1
  26. package/dist/main/lib/fetch.d.ts +19 -1
  27. package/dist/main/lib/fetch.d.ts.map +1 -1
  28. package/dist/main/lib/fetch.js +19 -1
  29. package/dist/main/lib/fetch.js.map +1 -1
  30. package/dist/main/lib/helpers.d.ts +9 -5
  31. package/dist/main/lib/helpers.d.ts.map +1 -1
  32. package/dist/main/lib/helpers.js +82 -7
  33. package/dist/main/lib/helpers.js.map +1 -1
  34. package/dist/main/lib/types/CreateProjectKeySchema.d.ts +0 -1
  35. package/dist/main/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
  36. package/dist/main/lib/types/DeepgramClientOptions.d.ts +75 -8
  37. package/dist/main/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  38. package/dist/main/lib/types/Fetch.d.ts +3 -13
  39. package/dist/main/lib/types/Fetch.d.ts.map +1 -1
  40. package/dist/main/lib/types/LiveConfigOptions.d.ts +6 -3
  41. package/dist/main/lib/types/LiveConfigOptions.d.ts.map +1 -1
  42. package/dist/main/lib/types/TranscriptionSchema.d.ts +0 -1
  43. package/dist/main/lib/types/TranscriptionSchema.d.ts.map +1 -1
  44. package/dist/main/lib/types/UpdateProjectMemberScopeSchema.d.ts +1 -1
  45. package/dist/main/lib/types/UpdateProjectMemberScopeSchema.d.ts.map +1 -1
  46. package/dist/main/lib/types/UpdateProjectSchema.d.ts +0 -1
  47. package/dist/main/lib/types/UpdateProjectSchema.d.ts.map +1 -1
  48. package/dist/main/lib/types/index.d.ts +39 -39
  49. package/dist/main/lib/types/index.d.ts.map +1 -1
  50. package/dist/main/lib/types/index.js +53 -0
  51. package/dist/main/lib/types/index.js.map +1 -1
  52. package/dist/main/lib/version.d.ts +1 -1
  53. package/dist/main/lib/version.js +1 -1
  54. package/dist/main/packages/AbstractClient.d.ts +63 -10
  55. package/dist/main/packages/AbstractClient.d.ts.map +1 -1
  56. package/dist/main/packages/AbstractClient.js +103 -50
  57. package/dist/main/packages/AbstractClient.js.map +1 -1
  58. package/dist/main/packages/AbstractLiveClient.d.ts +114 -0
  59. package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -0
  60. package/dist/main/packages/AbstractLiveClient.js +238 -0
  61. package/dist/main/packages/AbstractLiveClient.js.map +1 -0
  62. package/dist/main/packages/AbstractRestClient.d.ts +105 -0
  63. package/dist/main/packages/AbstractRestClient.d.ts.map +1 -0
  64. package/dist/main/packages/AbstractRestClient.js +185 -0
  65. package/dist/main/packages/AbstractRestClient.js.map +1 -0
  66. package/dist/main/packages/ListenClient.d.ts +21 -4
  67. package/dist/main/packages/ListenClient.d.ts.map +1 -1
  68. package/dist/main/packages/ListenClient.js +25 -5
  69. package/dist/main/packages/ListenClient.js.map +1 -1
  70. package/dist/main/packages/ListenLiveClient.d.ts +58 -0
  71. package/dist/main/packages/ListenLiveClient.d.ts.map +1 -0
  72. package/dist/main/packages/ListenLiveClient.js +119 -0
  73. package/dist/main/packages/ListenLiveClient.js.map +1 -0
  74. package/dist/main/packages/ListenRestClient.d.ts +57 -0
  75. package/dist/main/packages/ListenRestClient.d.ts.map +1 -0
  76. package/dist/main/packages/ListenRestClient.js +167 -0
  77. package/dist/main/packages/ListenRestClient.js.map +1 -0
  78. package/dist/main/packages/ManageRestClient.d.ts +286 -0
  79. package/dist/main/packages/ManageRestClient.d.ts.map +1 -0
  80. package/dist/main/packages/ManageRestClient.js +628 -0
  81. package/dist/main/packages/ManageRestClient.js.map +1 -0
  82. package/dist/main/packages/ReadRestClient.d.ts +57 -0
  83. package/dist/main/packages/ReadRestClient.d.ts.map +1 -0
  84. package/dist/main/packages/ReadRestClient.js +165 -0
  85. package/dist/main/packages/ReadRestClient.js.map +1 -0
  86. package/dist/main/packages/SelfHostedRestClient.d.ts +47 -0
  87. package/dist/main/packages/SelfHostedRestClient.d.ts.map +1 -0
  88. package/dist/main/packages/SelfHostedRestClient.js +120 -0
  89. package/dist/main/packages/SelfHostedRestClient.js.map +1 -0
  90. package/dist/main/packages/SpeakRestClient.d.ts +36 -0
  91. package/dist/main/packages/SpeakRestClient.d.ts.map +1 -0
  92. package/dist/main/packages/SpeakRestClient.js +84 -0
  93. package/dist/main/packages/SpeakRestClient.js.map +1 -0
  94. package/dist/main/packages/index.d.ts +10 -8
  95. package/dist/main/packages/index.d.ts.map +1 -1
  96. package/dist/main/packages/index.js +24 -17
  97. package/dist/main/packages/index.js.map +1 -1
  98. package/dist/module/DeepgramClient.d.ts +65 -12
  99. package/dist/module/DeepgramClient.d.ts.map +1 -1
  100. package/dist/module/DeepgramClient.js +72 -17
  101. package/dist/module/DeepgramClient.js.map +1 -1
  102. package/dist/module/index.d.ts +13 -4
  103. package/dist/module/index.d.ts.map +1 -1
  104. package/dist/module/index.js +18 -8
  105. package/dist/module/index.js.map +1 -1
  106. package/dist/module/lib/constants.d.ts +16 -7
  107. package/dist/module/lib/constants.d.ts.map +1 -1
  108. package/dist/module/lib/constants.js +26 -9
  109. package/dist/module/lib/constants.js.map +1 -1
  110. package/dist/module/lib/enums/LiveConnectionState.d.ts +5 -0
  111. package/dist/module/lib/enums/LiveConnectionState.d.ts.map +1 -1
  112. package/dist/module/lib/enums/LiveConnectionState.js +5 -0
  113. package/dist/module/lib/enums/LiveConnectionState.js.map +1 -1
  114. package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts +24 -3
  115. package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
  116. package/dist/module/lib/enums/LiveTranscriptionEvents.js +23 -2
  117. package/dist/module/lib/enums/LiveTranscriptionEvents.js.map +1 -1
  118. package/dist/module/lib/enums/index.d.ts +2 -2
  119. package/dist/module/lib/enums/index.d.ts.map +1 -1
  120. package/dist/module/lib/enums/index.js +2 -2
  121. package/dist/module/lib/enums/index.js.map +1 -1
  122. package/dist/module/lib/fetch.d.ts +19 -1
  123. package/dist/module/lib/fetch.d.ts.map +1 -1
  124. package/dist/module/lib/fetch.js +19 -1
  125. package/dist/module/lib/fetch.js.map +1 -1
  126. package/dist/module/lib/helpers.d.ts +9 -5
  127. package/dist/module/lib/helpers.d.ts.map +1 -1
  128. package/dist/module/lib/helpers.js +75 -4
  129. package/dist/module/lib/helpers.js.map +1 -1
  130. package/dist/module/lib/types/CreateProjectKeySchema.d.ts +0 -1
  131. package/dist/module/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
  132. package/dist/module/lib/types/DeepgramClientOptions.d.ts +75 -8
  133. package/dist/module/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  134. package/dist/module/lib/types/Fetch.d.ts +3 -13
  135. package/dist/module/lib/types/Fetch.d.ts.map +1 -1
  136. package/dist/module/lib/types/LiveConfigOptions.d.ts +6 -3
  137. package/dist/module/lib/types/LiveConfigOptions.d.ts.map +1 -1
  138. package/dist/module/lib/types/TranscriptionSchema.d.ts +0 -1
  139. package/dist/module/lib/types/TranscriptionSchema.d.ts.map +1 -1
  140. package/dist/module/lib/types/UpdateProjectMemberScopeSchema.d.ts +1 -1
  141. package/dist/module/lib/types/UpdateProjectMemberScopeSchema.d.ts.map +1 -1
  142. package/dist/module/lib/types/UpdateProjectSchema.d.ts +0 -1
  143. package/dist/module/lib/types/UpdateProjectSchema.d.ts.map +1 -1
  144. package/dist/module/lib/types/index.d.ts +39 -39
  145. package/dist/module/lib/types/index.d.ts.map +1 -1
  146. package/dist/module/lib/types/index.js +39 -1
  147. package/dist/module/lib/types/index.js.map +1 -1
  148. package/dist/module/lib/version.d.ts +1 -1
  149. package/dist/module/lib/version.js +1 -1
  150. package/dist/module/packages/AbstractClient.d.ts +63 -10
  151. package/dist/module/packages/AbstractClient.d.ts.map +1 -1
  152. package/dist/module/packages/AbstractClient.js +99 -50
  153. package/dist/module/packages/AbstractClient.js.map +1 -1
  154. package/dist/module/packages/AbstractLiveClient.d.ts +114 -0
  155. package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -0
  156. package/dist/module/packages/AbstractLiveClient.js +211 -0
  157. package/dist/module/packages/AbstractLiveClient.js.map +1 -0
  158. package/dist/module/packages/AbstractRestClient.d.ts +105 -0
  159. package/dist/module/packages/AbstractRestClient.d.ts.map +1 -0
  160. package/dist/module/packages/AbstractRestClient.js +178 -0
  161. package/dist/module/packages/AbstractRestClient.js.map +1 -0
  162. package/dist/module/packages/ListenClient.d.ts +21 -4
  163. package/dist/module/packages/ListenClient.d.ts.map +1 -1
  164. package/dist/module/packages/ListenClient.js +25 -5
  165. package/dist/module/packages/ListenClient.js.map +1 -1
  166. package/dist/module/packages/ListenLiveClient.d.ts +58 -0
  167. package/dist/module/packages/ListenLiveClient.d.ts.map +1 -0
  168. package/dist/module/packages/ListenLiveClient.js +115 -0
  169. package/dist/module/packages/ListenLiveClient.js.map +1 -0
  170. package/dist/module/packages/ListenRestClient.d.ts +57 -0
  171. package/dist/module/packages/ListenRestClient.d.ts.map +1 -0
  172. package/dist/module/packages/ListenRestClient.js +163 -0
  173. package/dist/module/packages/ListenRestClient.js.map +1 -0
  174. package/dist/module/packages/ManageRestClient.d.ts +286 -0
  175. package/dist/module/packages/ManageRestClient.d.ts.map +1 -0
  176. package/dist/module/packages/ManageRestClient.js +624 -0
  177. package/dist/module/packages/ManageRestClient.js.map +1 -0
  178. package/dist/module/packages/ReadRestClient.d.ts +57 -0
  179. package/dist/module/packages/ReadRestClient.d.ts.map +1 -0
  180. package/dist/module/packages/ReadRestClient.js +161 -0
  181. package/dist/module/packages/ReadRestClient.js.map +1 -0
  182. package/dist/module/packages/SelfHostedRestClient.d.ts +47 -0
  183. package/dist/module/packages/SelfHostedRestClient.d.ts.map +1 -0
  184. package/dist/module/packages/SelfHostedRestClient.js +116 -0
  185. package/dist/module/packages/SelfHostedRestClient.js.map +1 -0
  186. package/dist/module/packages/SpeakRestClient.d.ts +36 -0
  187. package/dist/module/packages/SpeakRestClient.d.ts.map +1 -0
  188. package/dist/module/packages/SpeakRestClient.js +80 -0
  189. package/dist/module/packages/SpeakRestClient.js.map +1 -0
  190. package/dist/module/packages/index.d.ts +10 -8
  191. package/dist/module/packages/index.d.ts.map +1 -1
  192. package/dist/module/packages/index.js +10 -8
  193. package/dist/module/packages/index.js.map +1 -1
  194. package/dist/umd/deepgram.js +1 -1
  195. package/package.json +8 -6
  196. package/src/DeepgramClient.ts +81 -17
  197. package/src/index.ts +32 -7
  198. package/src/lib/constants.ts +33 -13
  199. package/src/lib/enums/LiveConnectionState.ts +11 -4
  200. package/src/lib/enums/LiveTranscriptionEvents.ts +27 -4
  201. package/src/lib/enums/index.ts +2 -2
  202. package/src/lib/fetch.ts +22 -2
  203. package/src/lib/helpers.ts +98 -9
  204. package/src/lib/types/CreateProjectKeySchema.ts +0 -1
  205. package/src/lib/types/DeepgramClientOptions.ts +75 -11
  206. package/src/lib/types/Fetch.ts +2 -24
  207. package/src/lib/types/LiveConfigOptions.ts +7 -3
  208. package/src/lib/types/TranscriptionSchema.ts +0 -2
  209. package/src/lib/types/UpdateProjectMemberScopeSchema.ts +1 -1
  210. package/src/lib/types/UpdateProjectSchema.ts +0 -1
  211. package/src/lib/types/index.ts +39 -54
  212. package/src/lib/version.ts +1 -1
  213. package/src/packages/AbstractClient.ts +129 -61
  214. package/src/packages/AbstractLiveClient.ts +280 -0
  215. package/src/packages/AbstractRestClient.ts +221 -0
  216. package/src/packages/ListenClient.ts +26 -5
  217. package/src/packages/ListenLiveClient.ts +133 -0
  218. package/src/packages/ListenRestClient.ts +201 -0
  219. package/src/packages/ManageRestClient.ts +760 -0
  220. package/src/packages/ReadRestClient.ts +200 -0
  221. package/src/packages/SelfHostedRestClient.ts +134 -0
  222. package/src/packages/SpeakRestClient.ts +79 -0
  223. package/src/packages/index.ts +10 -8
  224. package/dist/main/packages/AbstractRestfulClient.d.ts +0 -26
  225. package/dist/main/packages/AbstractRestfulClient.d.ts.map +0 -1
  226. package/dist/main/packages/AbstractRestfulClient.js +0 -118
  227. package/dist/main/packages/AbstractRestfulClient.js.map +0 -1
  228. package/dist/main/packages/AbstractWsClient.d.ts +0 -10
  229. package/dist/main/packages/AbstractWsClient.d.ts.map +0 -1
  230. package/dist/main/packages/AbstractWsClient.js +0 -33
  231. package/dist/main/packages/AbstractWsClient.js.map +0 -1
  232. package/dist/main/packages/LiveClient.d.ts +0 -28
  233. package/dist/main/packages/LiveClient.d.ts.map +0 -1
  234. package/dist/main/packages/LiveClient.js +0 -110
  235. package/dist/main/packages/LiveClient.js.map +0 -1
  236. package/dist/main/packages/ManageClient.d.ts +0 -97
  237. package/dist/main/packages/ManageClient.d.ts.map +0 -1
  238. package/dist/main/packages/ManageClient.js +0 -463
  239. package/dist/main/packages/ManageClient.js.map +0 -1
  240. package/dist/main/packages/OnPremClient.d.ts +0 -21
  241. package/dist/main/packages/OnPremClient.d.ts.map +0 -1
  242. package/dist/main/packages/OnPremClient.js +0 -99
  243. package/dist/main/packages/OnPremClient.js.map +0 -1
  244. package/dist/main/packages/PrerecordedClient.d.ts +0 -10
  245. package/dist/main/packages/PrerecordedClient.d.ts.map +0 -1
  246. package/dist/main/packages/PrerecordedClient.js +0 -125
  247. package/dist/main/packages/PrerecordedClient.js.map +0 -1
  248. package/dist/main/packages/ReadClient.d.ts +0 -10
  249. package/dist/main/packages/ReadClient.d.ts.map +0 -1
  250. package/dist/main/packages/ReadClient.js +0 -123
  251. package/dist/main/packages/ReadClient.js.map +0 -1
  252. package/dist/main/packages/SpeakClient.d.ts +0 -12
  253. package/dist/main/packages/SpeakClient.d.ts.map +0 -1
  254. package/dist/main/packages/SpeakClient.js +0 -57
  255. package/dist/main/packages/SpeakClient.js.map +0 -1
  256. package/dist/module/packages/AbstractRestfulClient.d.ts +0 -26
  257. package/dist/module/packages/AbstractRestfulClient.d.ts.map +0 -1
  258. package/dist/module/packages/AbstractRestfulClient.js +0 -114
  259. package/dist/module/packages/AbstractRestfulClient.js.map +0 -1
  260. package/dist/module/packages/AbstractWsClient.d.ts +0 -10
  261. package/dist/module/packages/AbstractWsClient.d.ts.map +0 -1
  262. package/dist/module/packages/AbstractWsClient.js +0 -29
  263. package/dist/module/packages/AbstractWsClient.js.map +0 -1
  264. package/dist/module/packages/LiveClient.d.ts +0 -28
  265. package/dist/module/packages/LiveClient.d.ts.map +0 -1
  266. package/dist/module/packages/LiveClient.js +0 -106
  267. package/dist/module/packages/LiveClient.js.map +0 -1
  268. package/dist/module/packages/ManageClient.d.ts +0 -97
  269. package/dist/module/packages/ManageClient.d.ts.map +0 -1
  270. package/dist/module/packages/ManageClient.js +0 -459
  271. package/dist/module/packages/ManageClient.js.map +0 -1
  272. package/dist/module/packages/OnPremClient.d.ts +0 -21
  273. package/dist/module/packages/OnPremClient.d.ts.map +0 -1
  274. package/dist/module/packages/OnPremClient.js +0 -95
  275. package/dist/module/packages/OnPremClient.js.map +0 -1
  276. package/dist/module/packages/PrerecordedClient.d.ts +0 -10
  277. package/dist/module/packages/PrerecordedClient.d.ts.map +0 -1
  278. package/dist/module/packages/PrerecordedClient.js +0 -121
  279. package/dist/module/packages/PrerecordedClient.js.map +0 -1
  280. package/dist/module/packages/ReadClient.d.ts +0 -10
  281. package/dist/module/packages/ReadClient.d.ts.map +0 -1
  282. package/dist/module/packages/ReadClient.js +0 -119
  283. package/dist/module/packages/ReadClient.js.map +0 -1
  284. package/dist/module/packages/SpeakClient.d.ts +0 -12
  285. package/dist/module/packages/SpeakClient.d.ts.map +0 -1
  286. package/dist/module/packages/SpeakClient.js +0 -53
  287. package/dist/module/packages/SpeakClient.js.map +0 -1
  288. package/src/packages/AbstractRestfulClient.ts +0 -160
  289. package/src/packages/AbstractWsClient.ts +0 -42
  290. package/src/packages/LiveClient.ts +0 -140
  291. package/src/packages/ManageClient.ts +0 -584
  292. package/src/packages/OnPremClient.ts +0 -113
  293. package/src/packages/PrerecordedClient.ts +0 -162
  294. package/src/packages/ReadClient.ts +0 -161
  295. 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,MAAM,WAAW,CAAC;AAYzC,MAAM,OAAO,UAAW,SAAQ,gBAAgB;IAG9C,YACY,GAAW,EACX,UAA6C,eAAe,EAC9D,uBAAmC,EAAE,EAC7C,QAAQ,GAAG,WAAW;QAEtB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QALV,QAAG,GAAH,GAAG,CAAQ;QACX,YAAO,GAAP,OAAO,CAAqD;QAC9D,yBAAoB,GAApB,oBAAoB,CAAiB;QAK7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,GAAG,CAAC,QAAQ,GAAG,G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;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
@@ -1 +0,0 @@
1
- {"version":3,"file":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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