@deepgram/sdk 3.4.4 → 3.5.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 (56) hide show
  1. package/dist/main/lib/constants.d.ts +1 -0
  2. package/dist/main/lib/constants.d.ts.map +1 -1
  3. package/dist/main/lib/constants.js +19 -2
  4. package/dist/main/lib/constants.js.map +1 -1
  5. package/dist/main/lib/helpers.d.ts +3 -1
  6. package/dist/main/lib/helpers.d.ts.map +1 -1
  7. package/dist/main/lib/helpers.js +7 -4
  8. package/dist/main/lib/helpers.js.map +1 -1
  9. package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +2 -0
  10. package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
  11. package/dist/main/lib/types/SyncPrerecordedResponse.d.ts +2 -0
  12. package/dist/main/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
  13. package/dist/main/lib/types/TranscriptionSchema.d.ts +4 -0
  14. package/dist/main/lib/types/TranscriptionSchema.d.ts.map +1 -1
  15. package/dist/main/lib/version.d.ts +1 -1
  16. package/dist/main/lib/version.js +1 -1
  17. package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -1
  18. package/dist/main/packages/AbstractLiveClient.js +17 -0
  19. package/dist/main/packages/AbstractLiveClient.js.map +1 -1
  20. package/dist/main/packages/ListenLiveClient.d.ts +4 -0
  21. package/dist/main/packages/ListenLiveClient.d.ts.map +1 -1
  22. package/dist/main/packages/ListenLiveClient.js +8 -0
  23. package/dist/main/packages/ListenLiveClient.js.map +1 -1
  24. package/dist/module/lib/constants.d.ts +1 -0
  25. package/dist/module/lib/constants.d.ts.map +1 -1
  26. package/dist/module/lib/constants.js +19 -2
  27. package/dist/module/lib/constants.js.map +1 -1
  28. package/dist/module/lib/helpers.d.ts +3 -1
  29. package/dist/module/lib/helpers.d.ts.map +1 -1
  30. package/dist/module/lib/helpers.js +4 -3
  31. package/dist/module/lib/helpers.js.map +1 -1
  32. package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +2 -0
  33. package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
  34. package/dist/module/lib/types/SyncPrerecordedResponse.d.ts +2 -0
  35. package/dist/module/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
  36. package/dist/module/lib/types/TranscriptionSchema.d.ts +4 -0
  37. package/dist/module/lib/types/TranscriptionSchema.d.ts.map +1 -1
  38. package/dist/module/lib/version.d.ts +1 -1
  39. package/dist/module/lib/version.js +1 -1
  40. package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -1
  41. package/dist/module/packages/AbstractLiveClient.js +17 -0
  42. package/dist/module/packages/AbstractLiveClient.js.map +1 -1
  43. package/dist/module/packages/ListenLiveClient.d.ts +4 -0
  44. package/dist/module/packages/ListenLiveClient.d.ts.map +1 -1
  45. package/dist/module/packages/ListenLiveClient.js +8 -0
  46. package/dist/module/packages/ListenLiveClient.js.map +1 -1
  47. package/dist/umd/deepgram.js +1 -1
  48. package/package.json +2 -1
  49. package/src/lib/constants.ts +19 -4
  50. package/src/lib/helpers.ts +6 -3
  51. package/src/lib/types/LiveTranscriptionEvent.ts +2 -0
  52. package/src/lib/types/SyncPrerecordedResponse.ts +2 -0
  53. package/src/lib/types/TranscriptionSchema.ts +5 -0
  54. package/src/lib/version.ts +1 -1
  55. package/src/packages/AbstractLiveClient.ts +18 -0
  56. package/src/packages/ListenLiveClient.ts +11 -0
@@ -2,6 +2,7 @@ import { AbstractClient, noop } from "./AbstractClient";
2
2
  import { CONNECTION_STATE, SOCKET_STATES } from "../lib/constants";
3
3
  import type { DeepgramClientOptions, LiveSchema } from "../lib/types";
4
4
  import type { WebSocket as WSWebSocket } from "ws";
5
+ import { isBun } from "../lib/helpers";
5
6
 
6
7
  /**
7
8
  * Represents a constructor for a WebSocket-like object that can be used in the application.
@@ -119,6 +120,23 @@ export abstract class AbstractLiveClient extends AbstractClient {
119
120
  return;
120
121
  }
121
122
 
123
+ /**
124
+ * @summary Bun websocket transport has a bug where it's native WebSocket implementation messes up the headers
125
+ * @summary This is a workaround to use the WS package for the websocket connection instead of the native Bun WebSocket
126
+ * @summary you can track the issue here
127
+ * @link https://github.com/oven-sh/bun/issues/4529
128
+ */
129
+ if (isBun()) {
130
+ import("ws").then(({ default: WS }) => {
131
+ this.conn = new WS(requestUrl, {
132
+ headers: this.headers,
133
+ });
134
+ console.log(`Using WS package`);
135
+ this.setupConnection();
136
+ });
137
+ return;
138
+ }
139
+
122
140
  /**
123
141
  * Native websocket transport (browser)
124
142
  */
@@ -111,6 +111,17 @@ export class ListenLiveClient extends AbstractLiveClient {
111
111
  );
112
112
  }
113
113
 
114
+ /**
115
+ * Sends a "Finalize" message to flush any transcription sitting in the server's buffer.
116
+ */
117
+ public finalize(): void {
118
+ this.send(
119
+ JSON.stringify({
120
+ type: "Finalize",
121
+ })
122
+ );
123
+ }
124
+
114
125
  /**
115
126
  * @deprecated Since version 3.4. Will be removed in version 4.0. Use `requestClose` instead.
116
127
  */