@deepgram/sdk 5.0.0-alpha.3 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/LICENSE +1 -1
  2. package/dist/browser/index.global.js +496 -1104
  3. package/dist/cjs/BaseClient.d.ts +7 -7
  4. package/dist/cjs/BaseClient.js +2 -2
  5. package/dist/cjs/Client.d.ts +1 -2
  6. package/dist/cjs/CustomClient.js +253 -249
  7. package/dist/cjs/api/resources/agent/client/Client.d.ts +1 -2
  8. package/dist/cjs/api/resources/agent/resources/v1/client/Client.d.ts +1 -2
  9. package/dist/cjs/api/resources/agent/resources/v1/client/Socket.d.ts +8 -8
  10. package/dist/cjs/api/resources/agent/resources/v1/client/Socket.js +9 -9
  11. package/dist/cjs/api/resources/agent/resources/v1/resources/settings/client/Client.d.ts +1 -2
  12. package/dist/cjs/api/resources/agent/resources/v1/resources/settings/resources/think/client/Client.d.ts +1 -2
  13. package/dist/cjs/api/resources/agent/resources/v1/resources/settings/resources/think/resources/models/client/Client.d.ts +1 -2
  14. package/dist/cjs/api/resources/auth/client/Client.d.ts +1 -2
  15. package/dist/cjs/api/resources/auth/resources/v1/client/Client.d.ts +1 -2
  16. package/dist/cjs/api/resources/auth/resources/v1/resources/tokens/client/Client.d.ts +1 -2
  17. package/dist/cjs/api/resources/listen/client/Client.d.ts +1 -2
  18. package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +1 -2
  19. package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +29 -80
  20. package/dist/cjs/api/resources/listen/resources/v1/client/Socket.d.ts +4 -4
  21. package/dist/cjs/api/resources/listen/resources/v1/client/Socket.js +5 -5
  22. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/Client.d.ts +1 -2
  23. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/Client.js +76 -298
  24. package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +1 -2
  25. package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +11 -26
  26. package/dist/cjs/api/resources/listen/resources/v2/client/Socket.d.ts +2 -2
  27. package/dist/cjs/api/resources/listen/resources/v2/client/Socket.js +3 -3
  28. package/dist/cjs/api/resources/manage/client/Client.d.ts +1 -2
  29. package/dist/cjs/api/resources/manage/resources/v1/client/Client.d.ts +1 -2
  30. package/dist/cjs/api/resources/manage/resources/v1/resources/models/client/Client.d.ts +1 -2
  31. package/dist/cjs/api/resources/manage/resources/v1/resources/models/client/Client.js +3 -4
  32. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/client/Client.d.ts +1 -2
  33. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/client/Client.js +4 -7
  34. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/client/Client.d.ts +1 -2
  35. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/balances/client/Client.d.ts +1 -2
  36. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.d.ts +1 -2
  37. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.js +9 -27
  38. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.d.ts +1 -2
  39. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.js +4 -7
  40. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.d.ts +1 -2
  41. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.js +3 -4
  42. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.d.ts +1 -2
  43. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.js +3 -4
  44. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/client/Client.d.ts +1 -2
  45. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/resources/invites/client/Client.d.ts +1 -2
  46. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/members/resources/scopes/client/Client.d.ts +1 -2
  47. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.d.ts +1 -2
  48. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.js +3 -4
  49. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.d.ts +1 -2
  50. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.js +12 -31
  51. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.d.ts +1 -2
  52. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.js +46 -133
  53. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.d.ts +1 -2
  54. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.js +47 -136
  55. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.d.ts +1 -2
  56. package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.js +4 -7
  57. package/dist/cjs/api/resources/read/client/Client.d.ts +1 -2
  58. package/dist/cjs/api/resources/read/resources/v1/client/Client.d.ts +1 -2
  59. package/dist/cjs/api/resources/read/resources/v1/resources/text/client/Client.d.ts +1 -2
  60. package/dist/cjs/api/resources/read/resources/v1/resources/text/client/Client.js +14 -52
  61. package/dist/cjs/api/resources/selfHosted/client/Client.d.ts +1 -2
  62. package/dist/cjs/api/resources/selfHosted/resources/v1/client/Client.d.ts +1 -2
  63. package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.d.ts +1 -2
  64. package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.js +4 -12
  65. package/dist/cjs/api/resources/speak/client/Client.d.ts +1 -2
  66. package/dist/cjs/api/resources/speak/resources/v1/client/Client.d.ts +1 -2
  67. package/dist/cjs/api/resources/speak/resources/v1/client/Client.js +6 -13
  68. package/dist/cjs/api/resources/speak/resources/v1/client/Socket.d.ts +4 -4
  69. package/dist/cjs/api/resources/speak/resources/v1/client/Socket.js +4 -4
  70. package/dist/cjs/api/resources/speak/resources/v1/resources/audio/client/Client.d.ts +1 -2
  71. package/dist/cjs/api/resources/speak/resources/v1/resources/audio/client/Client.js +11 -33
  72. package/dist/cjs/auth/HeaderAuthProvider.d.ts +14 -8
  73. package/dist/cjs/auth/HeaderAuthProvider.js +19 -9
  74. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
  75. package/dist/cjs/core/fetcher/Fetcher.d.ts +1 -2
  76. package/dist/cjs/core/headers.d.ts +2 -2
  77. package/dist/cjs/core/websocket/ws.d.ts +1 -1
  78. package/dist/cjs/version.d.ts +1 -1
  79. package/dist/cjs/version.js +1 -1
  80. package/dist/esm/BaseClient.d.mts +7 -7
  81. package/dist/esm/BaseClient.mjs +2 -2
  82. package/dist/esm/Client.d.mts +1 -2
  83. package/dist/esm/CustomClient.mjs +254 -250
  84. package/dist/esm/api/resources/agent/client/Client.d.mts +1 -2
  85. package/dist/esm/api/resources/agent/resources/v1/client/Client.d.mts +1 -2
  86. package/dist/esm/api/resources/agent/resources/v1/client/Socket.d.mts +8 -8
  87. package/dist/esm/api/resources/agent/resources/v1/client/Socket.mjs +9 -9
  88. package/dist/esm/api/resources/agent/resources/v1/resources/settings/client/Client.d.mts +1 -2
  89. package/dist/esm/api/resources/agent/resources/v1/resources/settings/resources/think/client/Client.d.mts +1 -2
  90. package/dist/esm/api/resources/agent/resources/v1/resources/settings/resources/think/resources/models/client/Client.d.mts +1 -2
  91. package/dist/esm/api/resources/auth/client/Client.d.mts +1 -2
  92. package/dist/esm/api/resources/auth/resources/v1/client/Client.d.mts +1 -2
  93. package/dist/esm/api/resources/auth/resources/v1/resources/tokens/client/Client.d.mts +1 -2
  94. package/dist/esm/api/resources/listen/client/Client.d.mts +1 -2
  95. package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +1 -2
  96. package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +29 -80
  97. package/dist/esm/api/resources/listen/resources/v1/client/Socket.d.mts +4 -4
  98. package/dist/esm/api/resources/listen/resources/v1/client/Socket.mjs +5 -5
  99. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/Client.d.mts +1 -2
  100. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/Client.mjs +76 -298
  101. package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +1 -2
  102. package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +11 -26
  103. package/dist/esm/api/resources/listen/resources/v2/client/Socket.d.mts +2 -2
  104. package/dist/esm/api/resources/listen/resources/v2/client/Socket.mjs +3 -3
  105. package/dist/esm/api/resources/manage/client/Client.d.mts +1 -2
  106. package/dist/esm/api/resources/manage/resources/v1/client/Client.d.mts +1 -2
  107. package/dist/esm/api/resources/manage/resources/v1/resources/models/client/Client.d.mts +1 -2
  108. package/dist/esm/api/resources/manage/resources/v1/resources/models/client/Client.mjs +3 -4
  109. package/dist/esm/api/resources/manage/resources/v1/resources/projects/client/Client.d.mts +1 -2
  110. package/dist/esm/api/resources/manage/resources/v1/resources/projects/client/Client.mjs +4 -7
  111. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/client/Client.d.mts +1 -2
  112. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/balances/client/Client.d.mts +1 -2
  113. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.d.mts +1 -2
  114. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/client/Client.mjs +9 -27
  115. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.d.mts +1 -2
  116. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/fields/client/Client.mjs +4 -7
  117. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.d.mts +1 -2
  118. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/purchases/client/Client.mjs +3 -4
  119. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.d.mts +1 -2
  120. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.mjs +3 -4
  121. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/client/Client.d.mts +1 -2
  122. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/resources/invites/client/Client.d.mts +1 -2
  123. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/members/resources/scopes/client/Client.d.mts +1 -2
  124. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.d.mts +1 -2
  125. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/models/client/Client.mjs +3 -4
  126. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.d.mts +1 -2
  127. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.mjs +12 -31
  128. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.d.mts +1 -2
  129. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/client/Client.mjs +46 -133
  130. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.d.mts +1 -2
  131. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/client/Client.mjs +47 -136
  132. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.d.mts +1 -2
  133. package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/fields/client/Client.mjs +4 -7
  134. package/dist/esm/api/resources/read/client/Client.d.mts +1 -2
  135. package/dist/esm/api/resources/read/resources/v1/client/Client.d.mts +1 -2
  136. package/dist/esm/api/resources/read/resources/v1/resources/text/client/Client.d.mts +1 -2
  137. package/dist/esm/api/resources/read/resources/v1/resources/text/client/Client.mjs +14 -52
  138. package/dist/esm/api/resources/selfHosted/client/Client.d.mts +1 -2
  139. package/dist/esm/api/resources/selfHosted/resources/v1/client/Client.d.mts +1 -2
  140. package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.d.mts +1 -2
  141. package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/client/Client.mjs +4 -12
  142. package/dist/esm/api/resources/speak/client/Client.d.mts +1 -2
  143. package/dist/esm/api/resources/speak/resources/v1/client/Client.d.mts +1 -2
  144. package/dist/esm/api/resources/speak/resources/v1/client/Client.mjs +6 -13
  145. package/dist/esm/api/resources/speak/resources/v1/client/Socket.d.mts +4 -4
  146. package/dist/esm/api/resources/speak/resources/v1/client/Socket.mjs +4 -4
  147. package/dist/esm/api/resources/speak/resources/v1/resources/audio/client/Client.d.mts +1 -2
  148. package/dist/esm/api/resources/speak/resources/v1/resources/audio/client/Client.mjs +11 -33
  149. package/dist/esm/auth/HeaderAuthProvider.d.mts +14 -8
  150. package/dist/esm/auth/HeaderAuthProvider.mjs +19 -9
  151. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
  152. package/dist/esm/core/fetcher/Fetcher.d.mts +1 -2
  153. package/dist/esm/core/headers.d.mts +2 -2
  154. package/dist/esm/core/websocket/ws.d.mts +1 -1
  155. package/dist/esm/version.d.mts +1 -1
  156. package/dist/esm/version.mjs +1 -1
  157. package/package.json +10 -7
@@ -2,8 +2,7 @@ import type { BaseClientOptions } from "../../../../../../BaseClient.mjs";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
3
3
  import { TextClient } from "../resources/text/client/Client.mjs";
4
4
  export declare namespace V1Client {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ type Options = BaseClientOptions;
7
6
  }
8
7
  export declare class V1Client {
9
8
  protected readonly _options: NormalizedClientOptionsWithAuth<V1Client.Options>;
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../../../../../Ba
3
3
  import * as core from "../../../../../../../../core/index.mjs";
4
4
  import * as Deepgram from "../../../../../../../index.mjs";
5
5
  export declare namespace TextClient {
6
- interface Options extends BaseClientOptions {
7
- }
6
+ type Options = BaseClientOptions;
8
7
  interface RequestOptions extends BaseRequestOptions {
9
8
  }
10
9
  }
@@ -53,58 +53,20 @@ export class TextClient {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
55
55
  const { callback, callback_method: callbackMethod, sentiment, summarize, tag, topics, custom_topic: customTopic, custom_topic_mode: customTopicMode, intents, custom_intent: customIntent, custom_intent_mode: customIntentMode, language, body: _body, } = request;
56
- const _queryParams = {};
57
- if (callback != null) {
58
- _queryParams.callback = callback;
59
- }
60
- if (callbackMethod != null) {
61
- _queryParams.callback_method = callbackMethod;
62
- }
63
- if (sentiment != null) {
64
- _queryParams.sentiment = sentiment.toString();
65
- }
66
- if (summarize != null) {
67
- _queryParams.summarize = summarize;
68
- }
69
- if (tag != null) {
70
- if (Array.isArray(tag)) {
71
- _queryParams.tag = tag.map((item) => item);
72
- }
73
- else {
74
- _queryParams.tag = tag;
75
- }
76
- }
77
- if (topics != null) {
78
- _queryParams.topics = topics.toString();
79
- }
80
- if (customTopic != null) {
81
- if (Array.isArray(customTopic)) {
82
- _queryParams.custom_topic = customTopic.map((item) => item);
83
- }
84
- else {
85
- _queryParams.custom_topic = customTopic;
86
- }
87
- }
88
- if (customTopicMode != null) {
89
- _queryParams.custom_topic_mode = customTopicMode;
90
- }
91
- if (intents != null) {
92
- _queryParams.intents = intents.toString();
93
- }
94
- if (customIntent != null) {
95
- if (Array.isArray(customIntent)) {
96
- _queryParams.custom_intent = customIntent.map((item) => item);
97
- }
98
- else {
99
- _queryParams.custom_intent = customIntent;
100
- }
101
- }
102
- if (customIntentMode != null) {
103
- _queryParams.custom_intent_mode = customIntentMode;
104
- }
105
- if (language != null) {
106
- _queryParams.language = language;
107
- }
56
+ const _queryParams = {
57
+ callback,
58
+ callback_method: callbackMethod != null ? callbackMethod : undefined,
59
+ sentiment,
60
+ summarize: summarize != null ? summarize : undefined,
61
+ tag,
62
+ topics,
63
+ custom_topic: customTopic,
64
+ custom_topic_mode: customTopicMode != null ? customTopicMode : undefined,
65
+ intents,
66
+ custom_intent: customIntent,
67
+ custom_intent_mode: customIntentMode != null ? customIntentMode : undefined,
68
+ language,
69
+ };
108
70
  const _authRequest = yield this._options.authProvider.getAuthRequest();
109
71
  const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
110
72
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -2,8 +2,7 @@ import type { BaseClientOptions } from "../../../../BaseClient.mjs";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
3
3
  import { V1Client } from "../resources/v1/client/Client.mjs";
4
4
  export declare namespace SelfHostedClient {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ type Options = BaseClientOptions;
7
6
  }
8
7
  export declare class SelfHostedClient {
9
8
  protected readonly _options: NormalizedClientOptionsWithAuth<SelfHostedClient.Options>;
@@ -2,8 +2,7 @@ import type { BaseClientOptions } from "../../../../../../BaseClient.mjs";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.mjs";
3
3
  import { DistributionCredentialsClient } from "../resources/distributionCredentials/client/Client.mjs";
4
4
  export declare namespace V1Client {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ type Options = BaseClientOptions;
7
6
  }
8
7
  export declare class V1Client {
9
8
  protected readonly _options: NormalizedClientOptionsWithAuth<V1Client.Options>;
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../../../../../Ba
3
3
  import * as core from "../../../../../../../../core/index.mjs";
4
4
  import * as Deepgram from "../../../../../../../index.mjs";
5
5
  export declare namespace DistributionCredentialsClient {
6
- interface Options extends BaseClientOptions {
7
- }
6
+ type Options = BaseClientOptions;
8
7
  interface RequestOptions extends BaseRequestOptions {
9
8
  }
10
9
  }
@@ -102,18 +102,10 @@ export class DistributionCredentialsClient {
102
102
  return __awaiter(this, arguments, void 0, function* (project_id, request = {}, requestOptions) {
103
103
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
104
104
  const { scopes, provider } = request, _body = __rest(request, ["scopes", "provider"]);
105
- const _queryParams = {};
106
- if (scopes != null) {
107
- if (Array.isArray(scopes)) {
108
- _queryParams.scopes = scopes.map((item) => item);
109
- }
110
- else {
111
- _queryParams.scopes = scopes;
112
- }
113
- }
114
- if (provider != null) {
115
- _queryParams.provider = provider;
116
- }
105
+ const _queryParams = {
106
+ scopes: Array.isArray(scopes) ? scopes.map((item) => item) : scopes != null ? scopes : undefined,
107
+ provider: provider != null ? provider : undefined,
108
+ };
117
109
  const _authRequest = yield this._options.authProvider.getAuthRequest();
118
110
  const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
119
111
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -2,8 +2,7 @@ import type { BaseClientOptions } from "../../../../BaseClient.mjs";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
3
3
  import { V1Client } from "../resources/v1/client/Client.mjs";
4
4
  export declare namespace SpeakClient {
5
- interface Options extends BaseClientOptions {
6
- }
5
+ type Options = BaseClientOptions;
7
6
  }
8
7
  export declare class SpeakClient {
9
8
  protected readonly _options: NormalizedClientOptionsWithAuth<SpeakClient.Options>;
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClie
3
3
  import { AudioClient } from "../resources/audio/client/Client.mjs";
4
4
  import { V1Socket } from "./Socket.mjs";
5
5
  export declare namespace V1Client {
6
- interface Options extends BaseClientOptions {
7
- }
6
+ type Options = BaseClientOptions;
8
7
  interface ConnectArgs {
9
8
  encoding?: string;
10
9
  mip_opt_out?: string;
@@ -26,19 +26,12 @@ export class V1Client {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  var _a, _b;
28
28
  const { encoding, mip_opt_out: mipOptOut, model, sample_rate: sampleRate, headers, debug, reconnectAttempts, } = args;
29
- const _queryParams = {};
30
- if (encoding != null) {
31
- _queryParams.encoding = encoding;
32
- }
33
- if (mipOptOut != null) {
34
- _queryParams.mip_opt_out = mipOptOut;
35
- }
36
- if (model != null) {
37
- _queryParams.model = model;
38
- }
39
- if (sampleRate != null) {
40
- _queryParams.sample_rate = sampleRate;
41
- }
29
+ const _queryParams = {
30
+ encoding,
31
+ mip_opt_out: mipOptOut,
32
+ model,
33
+ sample_rate: sampleRate,
34
+ };
42
35
  const _headers = mergeHeaders(mergeOnlyDefinedHeaders({ Authorization: args.Authorization }), headers);
43
36
  const socket = new core.ReconnectingWebSocket({
44
37
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.DeepgramEnvironment.Production).production, "/v1/speak"),
@@ -33,10 +33,10 @@ export declare class V1Socket {
33
33
  * ```
34
34
  */
35
35
  on<T extends keyof V1Socket.EventHandlers>(event: T, callback: V1Socket.EventHandlers[T]): void;
36
- sendSpeakV1Text(message: Deepgram.speak.SpeakV1Text): void;
37
- sendSpeakV1Flush(message: Deepgram.speak.SpeakV1Flush): void;
38
- sendSpeakV1Clear(message: Deepgram.speak.SpeakV1Clear): void;
39
- sendSpeakV1Close(message: Deepgram.speak.SpeakV1Close): void;
36
+ sendText(message: Deepgram.speak.SpeakV1Text): void;
37
+ sendFlush(message: Deepgram.speak.SpeakV1Flush): void;
38
+ sendClear(message: Deepgram.speak.SpeakV1Clear): void;
39
+ sendClose(message: Deepgram.speak.SpeakV1Close): void;
40
40
  /** Connect to the websocket and register event handlers. */
41
41
  connect(): V1Socket;
42
42
  /** Close the websocket and unregister event handlers. */
@@ -54,19 +54,19 @@ export class V1Socket {
54
54
  on(event, callback) {
55
55
  this.eventHandlers[event] = callback;
56
56
  }
57
- sendSpeakV1Text(message) {
57
+ sendText(message) {
58
58
  this.assertSocketIsOpen();
59
59
  this.sendJson(message);
60
60
  }
61
- sendSpeakV1Flush(message) {
61
+ sendFlush(message) {
62
62
  this.assertSocketIsOpen();
63
63
  this.sendJson(message);
64
64
  }
65
- sendSpeakV1Clear(message) {
65
+ sendClear(message) {
66
66
  this.assertSocketIsOpen();
67
67
  this.sendJson(message);
68
68
  }
69
- sendSpeakV1Close(message) {
69
+ sendClose(message) {
70
70
  this.assertSocketIsOpen();
71
71
  this.sendJson(message);
72
72
  }
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../../../../../Ba
3
3
  import * as core from "../../../../../../../../core/index.mjs";
4
4
  import * as Deepgram from "../../../../../../../index.mjs";
5
5
  export declare namespace AudioClient {
6
- interface Options extends BaseClientOptions {
7
- }
6
+ type Options = BaseClientOptions;
8
7
  interface RequestOptions extends BaseRequestOptions {
9
8
  }
10
9
  }
@@ -41,39 +41,17 @@ export class AudioClient {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
42
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
43
43
  const { callback, callback_method: callbackMethod, mip_opt_out: mipOptOut, tag, bit_rate: bitRate, container, encoding, model, sample_rate: sampleRate } = request, _body = __rest(request, ["callback", "callback_method", "mip_opt_out", "tag", "bit_rate", "container", "encoding", "model", "sample_rate"]);
44
- const _queryParams = {};
45
- if (callback != null) {
46
- _queryParams.callback = callback;
47
- }
48
- if (callbackMethod != null) {
49
- _queryParams.callback_method = callbackMethod;
50
- }
51
- if (mipOptOut != null) {
52
- _queryParams.mip_opt_out = mipOptOut.toString();
53
- }
54
- if (tag != null) {
55
- if (Array.isArray(tag)) {
56
- _queryParams.tag = tag.map((item) => item);
57
- }
58
- else {
59
- _queryParams.tag = tag;
60
- }
61
- }
62
- if (bitRate != null) {
63
- _queryParams.bit_rate = bitRate.toString();
64
- }
65
- if (container != null) {
66
- _queryParams.container = container;
67
- }
68
- if (encoding != null) {
69
- _queryParams.encoding = encoding;
70
- }
71
- if (model != null) {
72
- _queryParams.model = model;
73
- }
74
- if (sampleRate != null) {
75
- _queryParams.sample_rate = sampleRate.toString();
76
- }
44
+ const _queryParams = {
45
+ callback,
46
+ callback_method: callbackMethod != null ? callbackMethod : undefined,
47
+ mip_opt_out: mipOptOut,
48
+ tag,
49
+ bit_rate: bitRate,
50
+ container: container != null ? container : undefined,
51
+ encoding: encoding != null ? encoding : undefined,
52
+ model: model != null ? model : undefined,
53
+ sample_rate: sampleRate,
54
+ };
77
55
  const _authRequest = yield this._options.authProvider.getAuthRequest();
78
56
  const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
79
57
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -1,14 +1,20 @@
1
1
  import * as core from "../core/index.mjs";
2
- export declare namespace HeaderAuthProvider {
3
- interface Options {
4
- apiKey?: core.Supplier<string | undefined>;
5
- }
6
- }
2
+ declare const PARAM_KEY: "apiKey";
7
3
  export declare class HeaderAuthProvider implements core.AuthProvider {
8
- private readonly headerValue;
4
+ private readonly options;
9
5
  constructor(options: HeaderAuthProvider.Options);
10
- static canCreate(options: HeaderAuthProvider.Options): boolean;
11
- getAuthRequest(_arg?: {
6
+ static canCreate(options: Partial<HeaderAuthProvider.Options>): boolean;
7
+ getAuthRequest({ endpointMetadata, }?: {
12
8
  endpointMetadata?: core.EndpointMetadata;
13
9
  }): Promise<core.AuthRequest>;
14
10
  }
11
+ export declare namespace HeaderAuthProvider {
12
+ const AUTH_SCHEME: "ApiKeyAuth";
13
+ const AUTH_CONFIG_ERROR_MESSAGE: string;
14
+ type Options = AuthOptions;
15
+ type AuthOptions = {
16
+ [PARAM_KEY]?: core.Supplier<string> | undefined;
17
+ };
18
+ function createInstance(options: Options): core.AuthProvider;
19
+ }
20
+ export {};
@@ -10,27 +10,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  import * as core from "../core/index.mjs";
12
12
  import * as errors from "../errors/index.mjs";
13
+ const PARAM_KEY = "apiKey";
14
+ const ENV_HEADER_KEY = "DEEPGRAM_API_KEY";
15
+ const HEADER_NAME = "Authorization";
13
16
  export class HeaderAuthProvider {
14
17
  constructor(options) {
15
- this.headerValue = options.apiKey;
18
+ this.options = options;
16
19
  }
17
20
  static canCreate(options) {
18
21
  var _a;
19
- return options.apiKey != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a.DEEPGRAM_API_KEY) != null;
22
+ return (options === null || options === void 0 ? void 0 : options[PARAM_KEY]) != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a[ENV_HEADER_KEY]) != null;
20
23
  }
21
- getAuthRequest(_arg) {
22
- return __awaiter(this, void 0, void 0, function* () {
24
+ getAuthRequest() {
25
+ return __awaiter(this, arguments, void 0, function* ({ endpointMetadata, } = {}) {
23
26
  var _a, _b;
24
- const apiKey = (_a = (yield core.Supplier.get(this.headerValue))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b.DEEPGRAM_API_KEY;
25
- if (apiKey == null) {
27
+ const headerValue = (_a = (yield core.Supplier.get(this.options[PARAM_KEY]))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b[ENV_HEADER_KEY];
28
+ if (headerValue == null) {
26
29
  throw new errors.DeepgramError({
27
- message: "Please specify a apiKey by either passing it in to the constructor or initializing a DEEPGRAM_API_KEY environment variable",
30
+ message: HeaderAuthProvider.AUTH_CONFIG_ERROR_MESSAGE,
28
31
  });
29
32
  }
30
- const headerValue = `Token ${apiKey}`;
31
33
  return {
32
- headers: { Authorization: headerValue },
34
+ headers: { [HEADER_NAME]: headerValue },
33
35
  };
34
36
  });
35
37
  }
36
38
  }
39
+ (function (HeaderAuthProvider) {
40
+ HeaderAuthProvider.AUTH_SCHEME = "ApiKeyAuth";
41
+ HeaderAuthProvider.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${PARAM_KEY}' when initializing the client, or set the '${ENV_HEADER_KEY}' environment variable`;
42
+ function createInstance(options) {
43
+ return new HeaderAuthProvider(options);
44
+ }
45
+ HeaderAuthProvider.createInstance = createInstance;
46
+ })(HeaderAuthProvider || (HeaderAuthProvider = {}));
@@ -1,12 +1,12 @@
1
1
  import type { EndpointMetadata } from "./EndpointMetadata.mjs";
2
2
  import type { Supplier } from "./Supplier.mjs";
3
3
  type EndpointSupplierFn<T> = (arg: {
4
- endpointMetadata: EndpointMetadata;
4
+ endpointMetadata?: EndpointMetadata;
5
5
  }) => T | Promise<T>;
6
6
  export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
7
7
  export declare const EndpointSupplier: {
8
8
  get: <T>(supplier: EndpointSupplier<T>, arg: {
9
- endpointMetadata: EndpointMetadata;
9
+ endpointMetadata?: EndpointMetadata;
10
10
  }) => Promise<T>;
11
11
  };
12
12
  export {};
@@ -1,14 +1,13 @@
1
1
  import { type LogConfig, type Logger } from "../logging/logger.mjs";
2
2
  import type { APIResponse } from "./APIResponse.mjs";
3
3
  import type { EndpointMetadata } from "./EndpointMetadata.mjs";
4
- import { EndpointSupplier } from "./EndpointSupplier.mjs";
5
4
  export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
6
5
  export declare namespace Fetcher {
7
6
  interface Args {
8
7
  url: string;
9
8
  method: string;
10
9
  contentType?: string;
11
- headers?: Record<string, string | EndpointSupplier<string | null | undefined> | null | undefined>;
10
+ headers?: Record<string, unknown>;
12
11
  queryParameters?: Record<string, unknown>;
13
12
  body?: unknown;
14
13
  timeoutMs?: number;
@@ -1,2 +1,2 @@
1
- export declare function mergeHeaders<THeaderValue>(...headersArray: (Record<string, THeaderValue> | null | undefined)[]): Record<string, string | THeaderValue>;
2
- export declare function mergeOnlyDefinedHeaders<THeaderValue>(...headersArray: (Record<string, THeaderValue> | null | undefined)[]): Record<string, THeaderValue>;
1
+ export declare function mergeHeaders(...headersArray: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
2
+ export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
@@ -8,7 +8,7 @@ export declare namespace ReconnectingWebSocket {
8
8
  protocols?: string | string[];
9
9
  options?: ReconnectingWebSocket.Options;
10
10
  headers?: Record<string, unknown>;
11
- queryParameters?: Record<string, string | string[] | object | object[] | null | undefined>;
11
+ queryParameters?: Record<string, unknown>;
12
12
  }
13
13
  type Options = {
14
14
  WebSocket?: any;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.228";
1
+ export declare const SDK_VERSION = "0.0.259";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.0.228";
1
+ export const SDK_VERSION = "0.0.259";
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@deepgram/sdk",
3
- "version": "5.0.0-alpha.3",
3
+ "version": "5.0.0-beta.1",
4
4
  "private": false,
5
- "repository": "github:deepgram/deepgram-js-sdk",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/deepgram/deepgram-js-sdk.git"
8
+ },
6
9
  "license": "MIT",
7
10
  "type": "commonjs",
8
11
  "main": "./dist/cjs/index.js",
@@ -33,14 +36,14 @@
33
36
  "ws": "^8.16.0"
34
37
  },
35
38
  "devDependencies": {
36
- "@biomejs/biome": "2.3.1",
37
- "@types/node": "^18.19.70",
39
+ "webpack": "^5.97.1",
40
+ "ts-loader": "^9.5.1",
38
41
  "@types/ws": "^8.5.10",
42
+ "vitest": "^3.2.4",
39
43
  "msw": "2.11.2",
40
- "ts-loader": "^9.5.1",
44
+ "@types/node": "^18.19.70",
41
45
  "typescript": "~5.7.2",
42
- "vitest": "^3.2.4",
43
- "webpack": "^5.97.1"
46
+ "@biomejs/biome": "2.3.1"
44
47
  },
45
48
  "browser": {
46
49
  "fs": false,