@deepgram/sdk 5.3.0 → 5.5.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.
Files changed (87) hide show
  1. package/dist/browser/index.global.js +474 -18
  2. package/dist/cjs/BaseClient.d.ts +3 -0
  3. package/dist/cjs/BaseClient.js +20 -2
  4. package/dist/cjs/CustomClient.d.ts +75 -6
  5. package/dist/cjs/CustomClient.js +421 -15
  6. package/dist/cjs/api/errors/BadRequestError.js +1 -1
  7. package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.ts +7 -3
  8. package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.js +1 -7
  9. package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +1 -0
  10. package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +2 -1
  11. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.ts +2 -2
  12. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.ts +2 -2
  13. package/dist/cjs/api/resources/listen/resources/v1/types/DiarizeModel.d.ts +5 -0
  14. package/dist/cjs/api/{types/CreateKeyV1RequestOne.js → resources/listen/resources/v1/types/DiarizeModel.js} +5 -0
  15. package/dist/cjs/api/resources/listen/resources/v1/types/index.d.ts +1 -0
  16. package/dist/cjs/api/resources/listen/resources/v1/types/index.js +1 -0
  17. package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +1 -0
  18. package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +2 -1
  19. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.ts +2 -1
  20. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.js +5 -1
  21. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.ts +4 -0
  22. package/dist/cjs/api/types/DeepgramListenProviderV2.d.ts +7 -1
  23. package/dist/cjs/api/types/ListenV1Diarize.d.ts +1 -1
  24. package/dist/cjs/api/types/ListenV1Diarize.js +1 -1
  25. package/dist/cjs/api/types/ListenV2ProfanityFilter.d.ts +6 -0
  26. package/dist/cjs/api/types/ListenV2ProfanityFilter.js +9 -0
  27. package/dist/cjs/api/types/index.d.ts +1 -0
  28. package/dist/cjs/api/types/index.js +1 -0
  29. package/dist/cjs/auth/HeaderAuthProvider.js +2 -1
  30. package/dist/cjs/core/auth/AuthProvider.d.ts +1 -0
  31. package/dist/cjs/core/auth/AuthProvider.js +7 -0
  32. package/dist/cjs/core/auth/index.d.ts +1 -1
  33. package/dist/cjs/core/auth/index.js +3 -1
  34. package/dist/cjs/core/fetcher/getResponseBody.js +11 -0
  35. package/dist/cjs/core/fetcher/requestWithRetries.js +4 -1
  36. package/dist/cjs/core/fetcher/signals.js +9 -1
  37. package/dist/cjs/errors/DeepgramError.js +1 -1
  38. package/dist/cjs/errors/DeepgramTimeoutError.js +1 -1
  39. package/dist/cjs/index.d.ts +2 -0
  40. package/dist/cjs/index.js +1 -0
  41. package/dist/cjs/version.d.ts +1 -1
  42. package/dist/cjs/version.js +1 -1
  43. package/dist/esm/BaseClient.d.mts +3 -0
  44. package/dist/esm/BaseClient.mjs +20 -2
  45. package/dist/esm/CustomClient.d.mts +75 -6
  46. package/dist/esm/CustomClient.mjs +421 -15
  47. package/dist/esm/api/errors/BadRequestError.mjs +1 -1
  48. package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts +7 -3
  49. package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.mjs +1 -7
  50. package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +1 -0
  51. package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +2 -1
  52. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.mts +2 -2
  53. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.mts +2 -2
  54. package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.d.mts +5 -0
  55. package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.mjs +5 -0
  56. package/dist/esm/api/resources/listen/resources/v1/types/index.d.mts +1 -0
  57. package/dist/esm/api/resources/listen/resources/v1/types/index.mjs +1 -0
  58. package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +1 -0
  59. package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +2 -1
  60. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.mts +2 -1
  61. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.mjs +5 -1
  62. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.mts +4 -0
  63. package/dist/esm/api/types/DeepgramListenProviderV2.d.mts +7 -1
  64. package/dist/esm/api/types/ListenV1Diarize.d.mts +1 -1
  65. package/dist/esm/api/types/ListenV1Diarize.mjs +1 -1
  66. package/dist/esm/api/types/ListenV2ProfanityFilter.d.mts +6 -0
  67. package/dist/esm/api/types/ListenV2ProfanityFilter.mjs +6 -0
  68. package/dist/esm/api/types/index.d.mts +1 -0
  69. package/dist/esm/api/types/index.mjs +1 -0
  70. package/dist/esm/auth/HeaderAuthProvider.mjs +2 -1
  71. package/dist/esm/core/auth/AuthProvider.d.mts +1 -0
  72. package/dist/esm/core/auth/AuthProvider.mjs +6 -1
  73. package/dist/esm/core/auth/index.d.mts +1 -1
  74. package/dist/esm/core/auth/index.mjs +1 -0
  75. package/dist/esm/core/fetcher/getResponseBody.mjs +11 -0
  76. package/dist/esm/core/fetcher/requestWithRetries.mjs +4 -1
  77. package/dist/esm/core/fetcher/signals.mjs +9 -1
  78. package/dist/esm/errors/DeepgramError.mjs +1 -1
  79. package/dist/esm/errors/DeepgramTimeoutError.mjs +1 -1
  80. package/dist/esm/index.d.mts +2 -0
  81. package/dist/esm/index.mjs +1 -0
  82. package/dist/esm/version.d.mts +1 -1
  83. package/dist/esm/version.mjs +1 -1
  84. package/package.json +1 -1
  85. package/dist/cjs/api/types/CreateKeyV1RequestOne.d.ts +0 -1
  86. package/dist/esm/api/types/CreateKeyV1RequestOne.d.mts +0 -1
  87. package/dist/esm/api/types/CreateKeyV1RequestOne.mjs +0 -2
@@ -1,6 +1,7 @@
1
1
  import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.js";
2
2
  import * as core from "./core/index.js";
3
3
  import type * as environments from "./environments.js";
4
+ export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | HeaderAuthProvider.AuthOptions;
4
5
  export type BaseClientOptions = {
5
6
  environment?: core.Supplier<environments.DeepgramEnvironment | environments.DeepgramEnvironmentUrls>;
6
7
  /** Specify a custom URL to connect the client to. */
@@ -16,6 +17,8 @@ export type BaseClientOptions = {
16
17
  fetcher?: core.FetchFunction;
17
18
  /** Configure logging for the client. */
18
19
  logging?: core.logging.LogConfig | core.logging.Logger;
20
+ /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
21
+ auth?: AuthOption;
19
22
  } & HeaderAuthProvider.AuthOptions;
20
23
  export interface BaseRequestOptions {
21
24
  /** The maximum time to wait for a response in seconds. */
@@ -39,12 +39,15 @@ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
39
  const HeaderAuthProvider_js_1 = require("./auth/HeaderAuthProvider.js");
40
40
  const headers_js_1 = require("./core/headers.js");
41
41
  const core = __importStar(require("./core/index.js"));
42
+ // Derive the SDK version from the single source of truth (src/version.ts), which
43
+ // carries the release-please marker. Avoids a second hardcoded version that drifts.
44
+ const version_js_1 = require("./version.js");
42
45
  function normalizeClientOptions(options) {
43
46
  const headers = (0, headers_js_1.mergeHeaders)({
44
47
  "X-Fern-Language": "JavaScript",
45
48
  "X-Fern-SDK-Name": "@deepgram/sdk",
46
- "X-Fern-SDK-Version": "5.2.1",
47
- "User-Agent": "@deepgram/sdk/5.2.1",
49
+ "X-Fern-SDK-Version": version_js_1.SDK_VERSION,
50
+ "User-Agent": `@deepgram/sdk/${version_js_1.SDK_VERSION}`,
48
51
  "X-Fern-Runtime": core.RUNTIME.type,
49
52
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
53
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -53,6 +56,21 @@ function normalizeClientOptions(options) {
53
56
  function normalizeClientOptionsWithAuth(options) {
54
57
  var _a;
55
58
  const normalized = normalizeClientOptions(options);
59
+ if (options.auth === false) {
60
+ normalized.authProvider = new core.NoOpAuthProvider();
61
+ return normalized;
62
+ }
63
+ if (options.auth != null) {
64
+ if (typeof options.auth === "function") {
65
+ normalized.authProvider = { getAuthRequest: options.auth };
66
+ return normalized;
67
+ }
68
+ if (core.isAuthProvider(options.auth)) {
69
+ normalized.authProvider = options.auth;
70
+ return normalized;
71
+ }
72
+ Object.assign(normalized, options.auth);
73
+ }
56
74
  const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
57
75
  (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new HeaderAuthProvider_js_1.HeaderAuthProvider(normalizedWithNoOpAuthProvider));
58
76
  return normalized;
@@ -2,36 +2,105 @@ import { DeepgramClient } from "./Client.js";
2
2
  import type { AgentClient } from "./api/resources/agent/client/Client.js";
3
3
  import type { ListenClient } from "./api/resources/listen/client/Client.js";
4
4
  import type { SpeakClient } from "./api/resources/speak/client/Client.js";
5
+ import { V1Client as AgentV1Client } from "./api/resources/agent/resources/v1/client/Client.js";
6
+ import { V1Client as ListenV1Client } from "./api/resources/listen/resources/v1/client/Client.js";
7
+ import { V2Client as ListenV2Client } from "./api/resources/listen/resources/v2/client/Client.js";
8
+ import { V1Client as SpeakV1Client } from "./api/resources/speak/resources/v1/client/Client.js";
9
+ import { V1Socket as AgentV1Socket } from "./api/resources/agent/resources/v1/client/Socket.js";
10
+ import { V1Socket as ListenV1Socket } from "./api/resources/listen/resources/v1/client/Socket.js";
11
+ import { V2Socket as ListenV2Socket } from "./api/resources/listen/resources/v2/client/Socket.js";
12
+ import { V1Socket as SpeakV1Socket } from "./api/resources/speak/resources/v1/client/Socket.js";
5
13
  import * as core from "./core/index.js";
14
+ import type { DeepgramTransportFactory } from "./transport.js";
15
+ export type AgentV1ConnectionArgs = Omit<AgentV1Client.ConnectArgs, "Authorization"> & {
16
+ Authorization?: string;
17
+ };
18
+ export type ListenV1ConnectionArgs = Omit<ListenV1Client.ConnectArgs, "Authorization"> & {
19
+ Authorization?: string;
20
+ };
21
+ export type ListenV2ConnectionArgs = Omit<ListenV2Client.ConnectArgs, "Authorization" | "keyterm"> & {
22
+ Authorization?: string;
23
+ keyterm?: string | string[];
24
+ };
25
+ export type SpeakV1ConnectionArgs = Omit<SpeakV1Client.ConnectArgs, "Authorization"> & {
26
+ Authorization?: string;
27
+ };
28
+ export interface AgentV1ClientWithWebSocket extends AgentV1Client {
29
+ connect(args?: AgentV1ConnectionArgs): Promise<AgentV1Socket>;
30
+ createConnection(args?: AgentV1ConnectionArgs): Promise<AgentV1Socket>;
31
+ }
32
+ export interface ListenV1ClientWithWebSocket extends ListenV1Client {
33
+ connect(args: ListenV1ConnectionArgs): Promise<ListenV1Socket>;
34
+ createConnection(args: ListenV1ConnectionArgs): Promise<ListenV1Socket>;
35
+ }
36
+ export interface ListenV2ClientWithWebSocket extends ListenV2Client {
37
+ connect(args: ListenV2ConnectionArgs): Promise<ListenV2Socket>;
38
+ createConnection(args: ListenV2ConnectionArgs): Promise<ListenV2Socket>;
39
+ }
40
+ export interface SpeakV1ClientWithWebSocket extends SpeakV1Client {
41
+ connect(args: SpeakV1ConnectionArgs): Promise<SpeakV1Socket>;
42
+ createConnection(args: SpeakV1ConnectionArgs): Promise<SpeakV1Socket>;
43
+ }
44
+ export interface AgentClientWithWebSockets extends AgentClient {
45
+ readonly v1: AgentV1ClientWithWebSocket;
46
+ }
47
+ export interface ListenClientWithWebSockets extends ListenClient {
48
+ readonly v1: ListenV1ClientWithWebSocket;
49
+ readonly v2: ListenV2ClientWithWebSocket;
50
+ }
51
+ export interface SpeakClientWithWebSockets extends SpeakClient {
52
+ readonly v1: SpeakV1ClientWithWebSocket;
53
+ }
6
54
  /**
7
55
  * Custom wrapper around DeepgramClient that ensures the custom websocket implementation
8
56
  * from ws.ts is always used, even if the auto-generated code changes.
9
57
  */
58
+ export interface CustomDeepgramClientOptions extends DeepgramClient.Options {
59
+ accessToken?: core.Supplier<string | undefined>;
60
+ transportFactory?: DeepgramTransportFactory;
61
+ /**
62
+ * Whether the SDK should retry streaming connections at the wrapper level
63
+ * after a transport failure. Defaults to `true` for native websocket
64
+ * connections. When a `transportFactory` is provided, this is auto-set to
65
+ * `false` because custom transports own their own retry/reconnect lifecycle
66
+ * — wrapping a self-retrying transport in another retry layer creates
67
+ * double-retry storms under burst load. Pass `reconnect: true` together
68
+ * with `transportFactory` to opt back into wrapper-level retries.
69
+ */
70
+ reconnect?: boolean;
71
+ }
10
72
  export declare class CustomDeepgramClient extends DeepgramClient {
11
73
  private _customAgent;
12
74
  private _customListen;
13
75
  private _customSpeak;
14
76
  private readonly _sessionId;
15
- constructor(options?: DeepgramClient.Options & {
16
- accessToken?: core.Supplier<string | undefined>;
17
- });
77
+ private readonly _reconnect;
78
+ constructor(options?: CustomDeepgramClientOptions);
18
79
  /**
19
80
  * Get the session ID that was generated for this client instance.
20
81
  */
21
82
  get sessionId(): string;
83
+ /**
84
+ * Whether the SDK will retry streaming connections at the wrapper level
85
+ * after a transport-side failure. Returns `false` when a `transportFactory`
86
+ * was supplied without an explicit `reconnect: true` override, signalling
87
+ * that the custom transport is expected to manage its own reconnect
88
+ * lifecycle.
89
+ */
90
+ get reconnect(): boolean;
22
91
  /**
23
92
  * Override the agent getter to return a wrapped client that ensures
24
93
  * the custom websocket implementation is used.
25
94
  */
26
- get agent(): AgentClient;
95
+ get agent(): AgentClientWithWebSockets;
27
96
  /**
28
97
  * Override the listen getter to return a wrapped client that ensures
29
98
  * the custom websocket implementation is used.
30
99
  */
31
- get listen(): ListenClient;
100
+ get listen(): ListenClientWithWebSockets;
32
101
  /**
33
102
  * Override the speak getter to return a wrapped client that ensures
34
103
  * the custom websocket implementation is used.
35
104
  */
36
- get speak(): SpeakClient;
105
+ get speak(): SpeakClientWithWebSockets;
37
106
  }