@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
@@ -130,9 +130,9 @@ var Deepgram = (() => {
130
130
  }
131
131
  });
132
132
 
133
- // node_modules/.pnpm/ws@8.18.3/node_modules/ws/browser.js
133
+ // node_modules/.pnpm/ws@8.19.0/node_modules/ws/browser.js
134
134
  var require_browser = __commonJS({
135
- "node_modules/.pnpm/ws@8.18.3/node_modules/ws/browser.js"(exports, module) {
135
+ "node_modules/.pnpm/ws@8.19.0/node_modules/ws/browser.js"(exports, module) {
136
136
  "use strict";
137
137
  module.exports = function() {
138
138
  throw new Error(
@@ -3374,30 +3374,42 @@ var Deepgram = (() => {
3374
3374
  var ReconnectingWebSocket = _ReconnectingWebSocket;
3375
3375
 
3376
3376
  // src/auth/HeaderAuthProvider.ts
3377
- var HeaderAuthProvider = class {
3377
+ var PARAM_KEY = "apiKey";
3378
+ var ENV_HEADER_KEY = "DEEPGRAM_API_KEY";
3379
+ var HEADER_NAME = "Authorization";
3380
+ var HeaderAuthProvider = class _HeaderAuthProvider {
3378
3381
  constructor(options) {
3379
- this.headerValue = options.apiKey;
3382
+ this.options = options;
3380
3383
  }
3381
3384
  static canCreate(options) {
3382
3385
  var _a;
3383
- return options.apiKey != null || ((_a = process.env) == null ? void 0 : _a.DEEPGRAM_API_KEY) != null;
3386
+ return (options == null ? void 0 : options[PARAM_KEY]) != null || ((_a = process.env) == null ? void 0 : _a[ENV_HEADER_KEY]) != null;
3384
3387
  }
3385
- getAuthRequest(_arg) {
3386
- return __async(this, null, function* () {
3388
+ getAuthRequest() {
3389
+ return __async(this, arguments, function* ({
3390
+ endpointMetadata
3391
+ } = {}) {
3387
3392
  var _a, _b;
3388
- const apiKey = (_b = yield Supplier.get(this.headerValue)) != null ? _b : (_a = process.env) == null ? void 0 : _a.DEEPGRAM_API_KEY;
3389
- if (apiKey == null) {
3393
+ const headerValue = (_b = yield Supplier.get(this.options[PARAM_KEY])) != null ? _b : (_a = process.env) == null ? void 0 : _a[ENV_HEADER_KEY];
3394
+ if (headerValue == null) {
3390
3395
  throw new DeepgramError({
3391
- message: "Please specify a apiKey by either passing it in to the constructor or initializing a DEEPGRAM_API_KEY environment variable"
3396
+ message: _HeaderAuthProvider.AUTH_CONFIG_ERROR_MESSAGE
3392
3397
  });
3393
3398
  }
3394
- const headerValue = `Token ${apiKey}`;
3395
3399
  return {
3396
- headers: { Authorization: headerValue }
3400
+ headers: { [HEADER_NAME]: headerValue }
3397
3401
  };
3398
3402
  });
3399
3403
  }
3400
3404
  };
3405
+ ((HeaderAuthProvider2) => {
3406
+ HeaderAuthProvider2.AUTH_SCHEME = "ApiKeyAuth";
3407
+ HeaderAuthProvider2.AUTH_CONFIG_ERROR_MESSAGE = `Please provide '${PARAM_KEY}' when initializing the client, or set the '${ENV_HEADER_KEY}' environment variable`;
3408
+ function createInstance(options) {
3409
+ return new HeaderAuthProvider2(options);
3410
+ }
3411
+ HeaderAuthProvider2.createInstance = createInstance;
3412
+ })(HeaderAuthProvider || (HeaderAuthProvider = {}));
3401
3413
 
3402
3414
  // src/core/headers.ts
3403
3415
  function mergeHeaders(...headersArray) {
@@ -3429,8 +3441,8 @@ var Deepgram = (() => {
3429
3441
  {
3430
3442
  "X-Fern-Language": "JavaScript",
3431
3443
  "X-Fern-SDK-Name": "",
3432
- "X-Fern-SDK-Version": "0.0.228",
3433
- "User-Agent": "/0.0.228",
3444
+ "X-Fern-SDK-Version": "0.0.259",
3445
+ "User-Agent": "/0.0.259",
3434
3446
  "X-Fern-Runtime": RUNTIME.type,
3435
3447
  "X-Fern-Runtime-Version": RUNTIME.version
3436
3448
  },
@@ -3625,37 +3637,37 @@ var Deepgram = (() => {
3625
3637
  on(event, callback) {
3626
3638
  this.eventHandlers[event] = callback;
3627
3639
  }
3628
- sendAgentV1Settings(message) {
3640
+ sendSettings(message) {
3629
3641
  this.assertSocketIsOpen();
3630
3642
  this.sendJson(message);
3631
3643
  }
3632
- sendAgentV1UpdateSpeak(message) {
3644
+ sendUpdateSpeak(message) {
3633
3645
  this.assertSocketIsOpen();
3634
3646
  this.sendJson(message);
3635
3647
  }
3636
- sendAgentV1InjectUserMessage(message) {
3648
+ sendInjectUserMessage(message) {
3637
3649
  this.assertSocketIsOpen();
3638
3650
  this.sendJson(message);
3639
3651
  }
3640
- sendAgentV1InjectAgentMessage(message) {
3652
+ sendInjectAgentMessage(message) {
3641
3653
  this.assertSocketIsOpen();
3642
3654
  this.sendJson(message);
3643
3655
  }
3644
- sendAgentV1SendFunctionCallResponse(message) {
3656
+ sendFunctionCallResponse(message) {
3645
3657
  this.assertSocketIsOpen();
3646
3658
  this.sendJson(message);
3647
3659
  }
3648
- sendAgentV1KeepAlive(message) {
3660
+ sendKeepAlive(message) {
3649
3661
  this.assertSocketIsOpen();
3650
3662
  this.sendJson(message);
3651
3663
  }
3652
- sendAgentV1UpdatePrompt(message) {
3664
+ sendUpdatePrompt(message) {
3653
3665
  this.assertSocketIsOpen();
3654
3666
  this.sendJson(message);
3655
3667
  }
3656
- sendAgentV1Media(message) {
3668
+ sendMedia(message) {
3657
3669
  this.assertSocketIsOpen();
3658
- this.sendJson(message);
3670
+ this.sendBinary(message);
3659
3671
  }
3660
3672
  /** Connect to the websocket and register event handlers. */
3661
3673
  connect() {
@@ -3975,147 +3987,44 @@ var Deepgram = (() => {
3975
3987
  "version",
3976
3988
  "mip_opt_out"
3977
3989
  ]);
3978
- const _queryParams = {};
3979
- if (callback != null) {
3980
- _queryParams.callback = callback;
3981
- }
3982
- if (callbackMethod != null) {
3983
- _queryParams.callback_method = callbackMethod;
3984
- }
3985
- if (extra != null) {
3986
- if (Array.isArray(extra)) {
3987
- _queryParams.extra = extra.map((item) => item);
3988
- } else {
3989
- _queryParams.extra = extra;
3990
- }
3991
- }
3992
- if (sentiment != null) {
3993
- _queryParams.sentiment = sentiment.toString();
3994
- }
3995
- if (summarize != null) {
3996
- _queryParams.summarize = summarize;
3997
- }
3998
- if (tag != null) {
3999
- if (Array.isArray(tag)) {
4000
- _queryParams.tag = tag.map((item) => item);
4001
- } else {
4002
- _queryParams.tag = tag;
4003
- }
4004
- }
4005
- if (topics != null) {
4006
- _queryParams.topics = topics.toString();
4007
- }
4008
- if (customTopic != null) {
4009
- if (Array.isArray(customTopic)) {
4010
- _queryParams.custom_topic = customTopic.map((item) => item);
4011
- } else {
4012
- _queryParams.custom_topic = customTopic;
4013
- }
4014
- }
4015
- if (customTopicMode != null) {
4016
- _queryParams.custom_topic_mode = customTopicMode;
4017
- }
4018
- if (intents != null) {
4019
- _queryParams.intents = intents.toString();
4020
- }
4021
- if (customIntent != null) {
4022
- if (Array.isArray(customIntent)) {
4023
- _queryParams.custom_intent = customIntent.map((item) => item);
4024
- } else {
4025
- _queryParams.custom_intent = customIntent;
4026
- }
4027
- }
4028
- if (customIntentMode != null) {
4029
- _queryParams.custom_intent_mode = customIntentMode;
4030
- }
4031
- if (detectEntities != null) {
4032
- _queryParams.detect_entities = detectEntities.toString();
4033
- }
4034
- if (detectLanguage != null) {
4035
- _queryParams.detect_language = detectLanguage.toString();
4036
- }
4037
- if (diarize != null) {
4038
- _queryParams.diarize = diarize.toString();
4039
- }
4040
- if (dictation != null) {
4041
- _queryParams.dictation = dictation.toString();
4042
- }
4043
- if (encoding != null) {
4044
- _queryParams.encoding = encoding;
4045
- }
4046
- if (fillerWords != null) {
4047
- _queryParams.filler_words = fillerWords.toString();
4048
- }
4049
- if (keyterm != null) {
4050
- if (Array.isArray(keyterm)) {
4051
- _queryParams.keyterm = keyterm.map((item) => item);
4052
- } else {
4053
- _queryParams.keyterm = keyterm;
4054
- }
4055
- }
4056
- if (keywords != null) {
4057
- if (Array.isArray(keywords)) {
4058
- _queryParams.keywords = keywords.map((item) => item);
4059
- } else {
4060
- _queryParams.keywords = keywords;
4061
- }
4062
- }
4063
- if (language != null) {
4064
- _queryParams.language = language;
4065
- }
4066
- if (measurements != null) {
4067
- _queryParams.measurements = measurements.toString();
4068
- }
4069
- if (model != null) {
4070
- _queryParams.model = model;
4071
- }
4072
- if (multichannel != null) {
4073
- _queryParams.multichannel = multichannel.toString();
4074
- }
4075
- if (numerals != null) {
4076
- _queryParams.numerals = numerals.toString();
4077
- }
4078
- if (paragraphs != null) {
4079
- _queryParams.paragraphs = paragraphs.toString();
4080
- }
4081
- if (profanityFilter != null) {
4082
- _queryParams.profanity_filter = profanityFilter.toString();
4083
- }
4084
- if (punctuate != null) {
4085
- _queryParams.punctuate = punctuate.toString();
4086
- }
4087
- if (redact != null) {
4088
- _queryParams.redact = redact;
4089
- }
4090
- if (replace != null) {
4091
- if (Array.isArray(replace)) {
4092
- _queryParams.replace = replace.map((item) => item);
4093
- } else {
4094
- _queryParams.replace = replace;
4095
- }
4096
- }
4097
- if (search != null) {
4098
- if (Array.isArray(search)) {
4099
- _queryParams.search = search.map((item) => item);
4100
- } else {
4101
- _queryParams.search = search;
4102
- }
4103
- }
4104
- if (smartFormat != null) {
4105
- _queryParams.smart_format = smartFormat.toString();
4106
- }
4107
- if (utterances != null) {
4108
- _queryParams.utterances = utterances.toString();
4109
- }
4110
- if (uttSplit != null) {
4111
- _queryParams.utt_split = uttSplit.toString();
4112
- }
4113
- if (version != null) {
4114
- _queryParams.version = version;
4115
- }
4116
- if (mipOptOut != null) {
4117
- _queryParams.mip_opt_out = mipOptOut.toString();
4118
- }
3990
+ const _queryParams = {
3991
+ callback,
3992
+ callback_method: callbackMethod != null ? callbackMethod : void 0,
3993
+ extra,
3994
+ sentiment,
3995
+ summarize: summarize != null ? summarize : void 0,
3996
+ tag,
3997
+ topics,
3998
+ custom_topic: customTopic,
3999
+ custom_topic_mode: customTopicMode != null ? customTopicMode : void 0,
4000
+ intents,
4001
+ custom_intent: customIntent,
4002
+ custom_intent_mode: customIntentMode != null ? customIntentMode : void 0,
4003
+ detect_entities: detectEntities,
4004
+ detect_language: detectLanguage,
4005
+ diarize,
4006
+ dictation,
4007
+ encoding: encoding != null ? encoding : void 0,
4008
+ filler_words: fillerWords,
4009
+ keyterm,
4010
+ keywords,
4011
+ language,
4012
+ measurements,
4013
+ model: model != null ? model : void 0,
4014
+ multichannel,
4015
+ numerals,
4016
+ paragraphs,
4017
+ profanity_filter: profanityFilter,
4018
+ punctuate,
4019
+ redact,
4020
+ replace,
4021
+ search,
4022
+ smart_format: smartFormat,
4023
+ utterances,
4024
+ utt_split: uttSplit,
4025
+ version: version != null ? version : void 0,
4026
+ mip_opt_out: mipOptOut
4027
+ };
4119
4028
  const _authRequest = yield this._options.authProvider.getAuthRequest();
4120
4029
  const _headers = mergeHeaders(
4121
4030
  _authRequest.headers,
@@ -4179,147 +4088,44 @@ var Deepgram = (() => {
4179
4088
  __transcribeFile(uploadable, request, requestOptions) {
4180
4089
  return __async(this, null, function* () {
4181
4090
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4182
- const _queryParams = {};
4183
- if (request.callback != null) {
4184
- _queryParams.callback = request.callback;
4185
- }
4186
- if (request.callback_method != null) {
4187
- _queryParams.callback_method = request.callback_method;
4188
- }
4189
- if (request.extra != null) {
4190
- if (Array.isArray(request.extra)) {
4191
- _queryParams.extra = request.extra.map((item) => item);
4192
- } else {
4193
- _queryParams.extra = request.extra;
4194
- }
4195
- }
4196
- if (request.sentiment != null) {
4197
- _queryParams.sentiment = request.sentiment.toString();
4198
- }
4199
- if (request.summarize != null) {
4200
- _queryParams.summarize = request.summarize;
4201
- }
4202
- if (request.tag != null) {
4203
- if (Array.isArray(request.tag)) {
4204
- _queryParams.tag = request.tag.map((item) => item);
4205
- } else {
4206
- _queryParams.tag = request.tag;
4207
- }
4208
- }
4209
- if (request.topics != null) {
4210
- _queryParams.topics = request.topics.toString();
4211
- }
4212
- if (request.custom_topic != null) {
4213
- if (Array.isArray(request.custom_topic)) {
4214
- _queryParams.custom_topic = request.custom_topic.map((item) => item);
4215
- } else {
4216
- _queryParams.custom_topic = request.custom_topic;
4217
- }
4218
- }
4219
- if (request.custom_topic_mode != null) {
4220
- _queryParams.custom_topic_mode = request.custom_topic_mode;
4221
- }
4222
- if (request.intents != null) {
4223
- _queryParams.intents = request.intents.toString();
4224
- }
4225
- if (request.custom_intent != null) {
4226
- if (Array.isArray(request.custom_intent)) {
4227
- _queryParams.custom_intent = request.custom_intent.map((item) => item);
4228
- } else {
4229
- _queryParams.custom_intent = request.custom_intent;
4230
- }
4231
- }
4232
- if (request.custom_intent_mode != null) {
4233
- _queryParams.custom_intent_mode = request.custom_intent_mode;
4234
- }
4235
- if (request.detect_entities != null) {
4236
- _queryParams.detect_entities = request.detect_entities.toString();
4237
- }
4238
- if (request.detect_language != null) {
4239
- _queryParams.detect_language = request.detect_language.toString();
4240
- }
4241
- if (request.diarize != null) {
4242
- _queryParams.diarize = request.diarize.toString();
4243
- }
4244
- if (request.dictation != null) {
4245
- _queryParams.dictation = request.dictation.toString();
4246
- }
4247
- if (request.encoding != null) {
4248
- _queryParams.encoding = request.encoding;
4249
- }
4250
- if (request.filler_words != null) {
4251
- _queryParams.filler_words = request.filler_words.toString();
4252
- }
4253
- if (request.keyterm != null) {
4254
- if (Array.isArray(request.keyterm)) {
4255
- _queryParams.keyterm = request.keyterm.map((item) => item);
4256
- } else {
4257
- _queryParams.keyterm = request.keyterm;
4258
- }
4259
- }
4260
- if (request.keywords != null) {
4261
- if (Array.isArray(request.keywords)) {
4262
- _queryParams.keywords = request.keywords.map((item) => item);
4263
- } else {
4264
- _queryParams.keywords = request.keywords;
4265
- }
4266
- }
4267
- if (request.language != null) {
4268
- _queryParams.language = request.language;
4269
- }
4270
- if (request.measurements != null) {
4271
- _queryParams.measurements = request.measurements.toString();
4272
- }
4273
- if (request.model != null) {
4274
- _queryParams.model = request.model;
4275
- }
4276
- if (request.multichannel != null) {
4277
- _queryParams.multichannel = request.multichannel.toString();
4278
- }
4279
- if (request.numerals != null) {
4280
- _queryParams.numerals = request.numerals.toString();
4281
- }
4282
- if (request.paragraphs != null) {
4283
- _queryParams.paragraphs = request.paragraphs.toString();
4284
- }
4285
- if (request.profanity_filter != null) {
4286
- _queryParams.profanity_filter = request.profanity_filter.toString();
4287
- }
4288
- if (request.punctuate != null) {
4289
- _queryParams.punctuate = request.punctuate.toString();
4290
- }
4291
- if (request.redact != null) {
4292
- _queryParams.redact = request.redact;
4293
- }
4294
- if (request.replace != null) {
4295
- if (Array.isArray(request.replace)) {
4296
- _queryParams.replace = request.replace.map((item) => item);
4297
- } else {
4298
- _queryParams.replace = request.replace;
4299
- }
4300
- }
4301
- if (request.search != null) {
4302
- if (Array.isArray(request.search)) {
4303
- _queryParams.search = request.search.map((item) => item);
4304
- } else {
4305
- _queryParams.search = request.search;
4306
- }
4307
- }
4308
- if (request.smart_format != null) {
4309
- _queryParams.smart_format = request.smart_format.toString();
4310
- }
4311
- if (request.utterances != null) {
4312
- _queryParams.utterances = request.utterances.toString();
4313
- }
4314
- if (request.utt_split != null) {
4315
- _queryParams.utt_split = request.utt_split.toString();
4316
- }
4317
- if (request.version != null) {
4318
- _queryParams.version = request.version;
4319
- }
4320
- if (request.mip_opt_out != null) {
4321
- _queryParams.mip_opt_out = request.mip_opt_out.toString();
4322
- }
4091
+ const _queryParams = {
4092
+ callback: request.callback,
4093
+ callback_method: request.callback_method != null ? request.callback_method : void 0,
4094
+ extra: request.extra,
4095
+ sentiment: request.sentiment,
4096
+ summarize: request.summarize != null ? request.summarize : void 0,
4097
+ tag: request.tag,
4098
+ topics: request.topics,
4099
+ custom_topic: request.custom_topic,
4100
+ custom_topic_mode: request.custom_topic_mode != null ? request.custom_topic_mode : void 0,
4101
+ intents: request.intents,
4102
+ custom_intent: request.custom_intent,
4103
+ custom_intent_mode: request.custom_intent_mode != null ? request.custom_intent_mode : void 0,
4104
+ detect_entities: request.detect_entities,
4105
+ detect_language: request.detect_language,
4106
+ diarize: request.diarize,
4107
+ dictation: request.dictation,
4108
+ encoding: request.encoding != null ? request.encoding : void 0,
4109
+ filler_words: request.filler_words,
4110
+ keyterm: request.keyterm,
4111
+ keywords: request.keywords,
4112
+ language: request.language,
4113
+ measurements: request.measurements,
4114
+ model: request.model != null ? request.model : void 0,
4115
+ multichannel: request.multichannel,
4116
+ numerals: request.numerals,
4117
+ paragraphs: request.paragraphs,
4118
+ profanity_filter: request.profanity_filter,
4119
+ punctuate: request.punctuate,
4120
+ redact: request.redact,
4121
+ replace: request.replace,
4122
+ search: request.search,
4123
+ smart_format: request.smart_format,
4124
+ utterances: request.utterances,
4125
+ utt_split: request.utt_split,
4126
+ version: request.version != null ? request.version : void 0,
4127
+ mip_opt_out: request.mip_opt_out
4128
+ };
4323
4129
  const _binaryUploadRequest = yield file_exports.toBinaryUploadRequest(uploadable);
4324
4130
  const _authRequest = yield this._options.authProvider.getAuthRequest();
4325
4131
  const _headers = mergeHeaders(
@@ -4414,19 +4220,19 @@ var Deepgram = (() => {
4414
4220
  on(event, callback) {
4415
4221
  this.eventHandlers[event] = callback;
4416
4222
  }
4417
- sendListenV1Media(message) {
4223
+ sendMedia(message) {
4418
4224
  this.assertSocketIsOpen();
4419
- this.sendJson(message);
4225
+ this.sendBinary(message);
4420
4226
  }
4421
- sendListenV1Finalize(message) {
4227
+ sendFinalize(message) {
4422
4228
  this.assertSocketIsOpen();
4423
4229
  this.sendJson(message);
4424
4230
  }
4425
- sendListenV1CloseStream(message) {
4231
+ sendCloseStream(message) {
4426
4232
  this.assertSocketIsOpen();
4427
4233
  this.sendJson(message);
4428
4234
  }
4429
- sendListenV1KeepAlive(message) {
4235
+ sendKeepAlive(message) {
4430
4236
  this.assertSocketIsOpen();
4431
4237
  this.sendJson(message);
4432
4238
  }
@@ -4528,86 +4334,35 @@ var Deepgram = (() => {
4528
4334
  debug,
4529
4335
  reconnectAttempts
4530
4336
  } = args;
4531
- const _queryParams = {};
4532
- if (callback != null) {
4533
- _queryParams.callback = callback;
4534
- }
4535
- if (callbackMethod != null) {
4536
- _queryParams.callback_method = callbackMethod;
4537
- }
4538
- if (channels != null) {
4539
- _queryParams.channels = channels;
4540
- }
4541
- if (diarize != null) {
4542
- _queryParams.diarize = diarize;
4543
- }
4544
- if (dictation != null) {
4545
- _queryParams.dictation = dictation;
4546
- }
4547
- if (encoding != null) {
4548
- _queryParams.encoding = encoding;
4549
- }
4550
- if (endpointing != null) {
4551
- _queryParams.endpointing = endpointing;
4552
- }
4553
- if (extra != null) {
4554
- _queryParams.extra = extra;
4555
- }
4556
- if (interimResults != null) {
4557
- _queryParams.interim_results = interimResults;
4558
- }
4559
- if (keyterm != null) {
4560
- _queryParams.keyterm = keyterm;
4561
- }
4562
- if (keywords != null) {
4563
- _queryParams.keywords = keywords;
4564
- }
4565
- if (language != null) {
4566
- _queryParams.language = language;
4567
- }
4568
- if (mipOptOut != null) {
4569
- _queryParams.mip_opt_out = mipOptOut;
4570
- }
4571
- _queryParams.model = model;
4572
- if (multichannel != null) {
4573
- _queryParams.multichannel = multichannel;
4574
- }
4575
- if (numerals != null) {
4576
- _queryParams.numerals = numerals;
4577
- }
4578
- if (profanityFilter != null) {
4579
- _queryParams.profanity_filter = profanityFilter;
4580
- }
4581
- if (punctuate != null) {
4582
- _queryParams.punctuate = punctuate;
4583
- }
4584
- if (redact != null) {
4585
- _queryParams.redact = redact;
4586
- }
4587
- if (replace != null) {
4588
- _queryParams.replace = replace;
4589
- }
4590
- if (sampleRate != null) {
4591
- _queryParams.sample_rate = sampleRate;
4592
- }
4593
- if (search != null) {
4594
- _queryParams.search = search;
4595
- }
4596
- if (smartFormat != null) {
4597
- _queryParams.smart_format = smartFormat;
4598
- }
4599
- if (tag != null) {
4600
- _queryParams.tag = tag;
4601
- }
4602
- if (utteranceEndMs != null) {
4603
- _queryParams.utterance_end_ms = utteranceEndMs;
4604
- }
4605
- if (vadEvents != null) {
4606
- _queryParams.vad_events = vadEvents;
4607
- }
4608
- if (version != null) {
4609
- _queryParams.version = version;
4610
- }
4337
+ const _queryParams = {
4338
+ callback,
4339
+ callback_method: callbackMethod,
4340
+ channels,
4341
+ diarize,
4342
+ dictation,
4343
+ encoding,
4344
+ endpointing,
4345
+ extra,
4346
+ interim_results: interimResults,
4347
+ keyterm,
4348
+ keywords,
4349
+ language,
4350
+ mip_opt_out: mipOptOut,
4351
+ model,
4352
+ multichannel,
4353
+ numerals,
4354
+ profanity_filter: profanityFilter,
4355
+ punctuate,
4356
+ redact,
4357
+ replace,
4358
+ sample_rate: sampleRate,
4359
+ search,
4360
+ smart_format: smartFormat,
4361
+ tag,
4362
+ utterance_end_ms: utteranceEndMs,
4363
+ vad_events: vadEvents,
4364
+ version
4365
+ };
4611
4366
  const _headers = mergeHeaders(
4612
4367
  mergeOnlyDefinedHeaders({ Authorization: args.Authorization }),
4613
4368
  headers
@@ -4672,11 +4427,11 @@ var Deepgram = (() => {
4672
4427
  on(event, callback) {
4673
4428
  this.eventHandlers[event] = callback;
4674
4429
  }
4675
- sendListenV2Media(message) {
4430
+ sendMedia(message) {
4676
4431
  this.assertSocketIsOpen();
4677
- this.sendJson(message);
4432
+ this.sendBinary(message);
4678
4433
  }
4679
- sendListenV2CloseStream(message) {
4434
+ sendCloseStream(message) {
4680
4435
  this.assertSocketIsOpen();
4681
4436
  this.sendJson(message);
4682
4437
  }
@@ -4756,32 +4511,17 @@ var Deepgram = (() => {
4756
4511
  debug,
4757
4512
  reconnectAttempts
4758
4513
  } = args;
4759
- const _queryParams = {};
4760
- _queryParams.model = model;
4761
- if (encoding != null) {
4762
- _queryParams.encoding = encoding;
4763
- }
4764
- if (sampleRate != null) {
4765
- _queryParams.sample_rate = sampleRate;
4766
- }
4767
- if (eagerEotThreshold != null) {
4768
- _queryParams.eager_eot_threshold = eagerEotThreshold;
4769
- }
4770
- if (eotThreshold != null) {
4771
- _queryParams.eot_threshold = eotThreshold;
4772
- }
4773
- if (eotTimeoutMs != null) {
4774
- _queryParams.eot_timeout_ms = eotTimeoutMs;
4775
- }
4776
- if (keyterm != null) {
4777
- _queryParams.keyterm = keyterm;
4778
- }
4779
- if (mipOptOut != null) {
4780
- _queryParams.mip_opt_out = mipOptOut;
4781
- }
4782
- if (tag != null) {
4783
- _queryParams.tag = tag;
4784
- }
4514
+ const _queryParams = {
4515
+ model,
4516
+ encoding,
4517
+ sample_rate: sampleRate,
4518
+ eager_eot_threshold: eagerEotThreshold,
4519
+ eot_threshold: eotThreshold,
4520
+ eot_timeout_ms: eotTimeoutMs,
4521
+ keyterm,
4522
+ mip_opt_out: mipOptOut,
4523
+ tag
4524
+ };
4785
4525
  const _headers = mergeHeaders(
4786
4526
  mergeOnlyDefinedHeaders({ Authorization: args.Authorization }),
4787
4527
  headers
@@ -4841,10 +4581,9 @@ var Deepgram = (() => {
4841
4581
  return __async(this, arguments, function* (request = {}, requestOptions) {
4842
4582
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4843
4583
  const { include_outdated: includeOutdated } = request;
4844
- const _queryParams = {};
4845
- if (includeOutdated != null) {
4846
- _queryParams.include_outdated = includeOutdated.toString();
4847
- }
4584
+ const _queryParams = {
4585
+ include_outdated: includeOutdated
4586
+ };
4848
4587
  const _authRequest = yield this._options.authProvider.getAuthRequest();
4849
4588
  const _headers = mergeHeaders(
4850
4589
  _authRequest.headers,
@@ -5102,32 +4841,15 @@ var Deepgram = (() => {
5102
4841
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
5103
4842
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5104
4843
  const { start, end, accessor, deployment, tag, line_item: lineItem, grouping } = request;
5105
- const _queryParams = {};
5106
- if (start != null) {
5107
- _queryParams.start = start;
5108
- }
5109
- if (end != null) {
5110
- _queryParams.end = end;
5111
- }
5112
- if (accessor != null) {
5113
- _queryParams.accessor = accessor;
5114
- }
5115
- if (deployment != null) {
5116
- _queryParams.deployment = deployment;
5117
- }
5118
- if (tag != null) {
5119
- _queryParams.tag = tag;
5120
- }
5121
- if (lineItem != null) {
5122
- _queryParams.line_item = lineItem;
5123
- }
5124
- if (grouping != null) {
5125
- if (Array.isArray(grouping)) {
5126
- _queryParams.grouping = grouping.map((item) => item);
5127
- } else {
5128
- _queryParams.grouping = grouping;
5129
- }
5130
- }
4844
+ const _queryParams = {
4845
+ start,
4846
+ end,
4847
+ accessor,
4848
+ deployment: deployment != null ? deployment : void 0,
4849
+ tag,
4850
+ line_item: lineItem,
4851
+ grouping: Array.isArray(grouping) ? grouping.map((item) => item) : grouping != null ? grouping : void 0
4852
+ };
5131
4853
  const _authRequest = yield this._options.authProvider.getAuthRequest();
5132
4854
  const _headers = mergeHeaders(
5133
4855
  _authRequest.headers,
@@ -5200,13 +4922,10 @@ var Deepgram = (() => {
5200
4922
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
5201
4923
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5202
4924
  const { start, end } = request;
5203
- const _queryParams = {};
5204
- if (start != null) {
5205
- _queryParams.start = start;
5206
- }
5207
- if (end != null) {
5208
- _queryParams.end = end;
5209
- }
4925
+ const _queryParams = {
4926
+ start,
4927
+ end
4928
+ };
5210
4929
  const _authRequest = yield this._options.authProvider.getAuthRequest();
5211
4930
  const _headers = mergeHeaders(
5212
4931
  _authRequest.headers,
@@ -5278,10 +4997,9 @@ var Deepgram = (() => {
5278
4997
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
5279
4998
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5280
4999
  const { limit } = request;
5281
- const _queryParams = {};
5282
- if (limit != null) {
5283
- _queryParams.limit = limit.toString();
5284
- }
5000
+ const _queryParams = {
5001
+ limit
5002
+ };
5285
5003
  const _authRequest = yield this._options.authProvider.getAuthRequest();
5286
5004
  const _headers = mergeHeaders(
5287
5005
  _authRequest.headers,
@@ -5379,10 +5097,9 @@ var Deepgram = (() => {
5379
5097
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
5380
5098
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5381
5099
  const { status } = request;
5382
- const _queryParams = {};
5383
- if (status != null) {
5384
- _queryParams.status = status;
5385
- }
5100
+ const _queryParams = {
5101
+ status: status != null ? status : void 0
5102
+ };
5386
5103
  const _authRequest = yield this._options.authProvider.getAuthRequest();
5387
5104
  const _headers = mergeHeaders(
5388
5105
  _authRequest.headers,
@@ -6129,10 +5846,9 @@ var Deepgram = (() => {
6129
5846
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
6130
5847
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
6131
5848
  const { include_outdated: includeOutdated } = request;
6132
- const _queryParams = {};
6133
- if (includeOutdated != null) {
6134
- _queryParams.include_outdated = includeOutdated.toString();
6135
- }
5849
+ const _queryParams = {
5850
+ include_outdated: includeOutdated
5851
+ };
6136
5852
  const _authRequest = yield this._options.authProvider.getAuthRequest();
6137
5853
  const _headers = mergeHeaders(
6138
5854
  _authRequest.headers,
@@ -6285,37 +6001,18 @@ var Deepgram = (() => {
6285
6001
  method,
6286
6002
  status
6287
6003
  } = request;
6288
- const _queryParams = {};
6289
- if (start != null) {
6290
- _queryParams.start = start;
6291
- }
6292
- if (end != null) {
6293
- _queryParams.end = end;
6294
- }
6295
- if (limit != null) {
6296
- _queryParams.limit = limit.toString();
6297
- }
6298
- if (page != null) {
6299
- _queryParams.page = page.toString();
6300
- }
6301
- if (accessor != null) {
6302
- _queryParams.accessor = accessor;
6303
- }
6304
- if (requestId != null) {
6305
- _queryParams.request_id = requestId;
6306
- }
6307
- if (deployment != null) {
6308
- _queryParams.deployment = deployment;
6309
- }
6310
- if (endpoint != null) {
6311
- _queryParams.endpoint = endpoint;
6312
- }
6313
- if (method != null) {
6314
- _queryParams.method = method;
6315
- }
6316
- if (status != null) {
6317
- _queryParams.status = status;
6318
- }
6004
+ const _queryParams = {
6005
+ start,
6006
+ end,
6007
+ limit,
6008
+ page,
6009
+ accessor,
6010
+ request_id: requestId,
6011
+ deployment: deployment != null ? deployment : void 0,
6012
+ endpoint: endpoint != null ? endpoint : void 0,
6013
+ method: method != null ? method : void 0,
6014
+ status: status != null ? status : void 0
6015
+ };
6319
6016
  const _authRequest = yield this._options.authProvider.getAuthRequest();
6320
6017
  const _headers = mergeHeaders(
6321
6018
  _authRequest.headers,
@@ -6541,142 +6238,53 @@ var Deepgram = (() => {
6541
6238
  utterances,
6542
6239
  version
6543
6240
  } = request;
6544
- const _queryParams = {};
6545
- if (start != null) {
6546
- _queryParams.start = start;
6547
- }
6548
- if (end != null) {
6549
- _queryParams.end = end;
6550
- }
6551
- if (grouping != null) {
6552
- _queryParams.grouping = grouping;
6553
- }
6554
- if (accessor != null) {
6555
- _queryParams.accessor = accessor;
6556
- }
6557
- if (alternatives != null) {
6558
- _queryParams.alternatives = alternatives.toString();
6559
- }
6560
- if (callbackMethod != null) {
6561
- _queryParams.callback_method = callbackMethod.toString();
6562
- }
6563
- if (callback != null) {
6564
- _queryParams.callback = callback.toString();
6565
- }
6566
- if (channels != null) {
6567
- _queryParams.channels = channels.toString();
6568
- }
6569
- if (customIntentMode != null) {
6570
- _queryParams.custom_intent_mode = customIntentMode.toString();
6571
- }
6572
- if (customIntent != null) {
6573
- _queryParams.custom_intent = customIntent.toString();
6574
- }
6575
- if (customTopicMode != null) {
6576
- _queryParams.custom_topic_mode = customTopicMode.toString();
6577
- }
6578
- if (customTopic != null) {
6579
- _queryParams.custom_topic = customTopic.toString();
6580
- }
6581
- if (deployment != null) {
6582
- _queryParams.deployment = deployment;
6583
- }
6584
- if (detectEntities != null) {
6585
- _queryParams.detect_entities = detectEntities.toString();
6586
- }
6587
- if (detectLanguage != null) {
6588
- _queryParams.detect_language = detectLanguage.toString();
6589
- }
6590
- if (diarize != null) {
6591
- _queryParams.diarize = diarize.toString();
6592
- }
6593
- if (dictation != null) {
6594
- _queryParams.dictation = dictation.toString();
6595
- }
6596
- if (encoding != null) {
6597
- _queryParams.encoding = encoding.toString();
6598
- }
6599
- if (endpoint != null) {
6600
- _queryParams.endpoint = endpoint;
6601
- }
6602
- if (extra != null) {
6603
- _queryParams.extra = extra.toString();
6604
- }
6605
- if (fillerWords != null) {
6606
- _queryParams.filler_words = fillerWords.toString();
6607
- }
6608
- if (intents != null) {
6609
- _queryParams.intents = intents.toString();
6610
- }
6611
- if (keyterm != null) {
6612
- _queryParams.keyterm = keyterm.toString();
6613
- }
6614
- if (keywords != null) {
6615
- _queryParams.keywords = keywords.toString();
6616
- }
6617
- if (language != null) {
6618
- _queryParams.language = language.toString();
6619
- }
6620
- if (measurements != null) {
6621
- _queryParams.measurements = measurements.toString();
6622
- }
6623
- if (method != null) {
6624
- _queryParams.method = method;
6625
- }
6626
- if (model != null) {
6627
- _queryParams.model = model;
6628
- }
6629
- if (multichannel != null) {
6630
- _queryParams.multichannel = multichannel.toString();
6631
- }
6632
- if (numerals != null) {
6633
- _queryParams.numerals = numerals.toString();
6634
- }
6635
- if (paragraphs != null) {
6636
- _queryParams.paragraphs = paragraphs.toString();
6637
- }
6638
- if (profanityFilter != null) {
6639
- _queryParams.profanity_filter = profanityFilter.toString();
6640
- }
6641
- if (punctuate != null) {
6642
- _queryParams.punctuate = punctuate.toString();
6643
- }
6644
- if (redact != null) {
6645
- _queryParams.redact = redact.toString();
6646
- }
6647
- if (replace != null) {
6648
- _queryParams.replace = replace.toString();
6649
- }
6650
- if (sampleRate != null) {
6651
- _queryParams.sample_rate = sampleRate.toString();
6652
- }
6653
- if (search != null) {
6654
- _queryParams.search = search.toString();
6655
- }
6656
- if (sentiment != null) {
6657
- _queryParams.sentiment = sentiment.toString();
6658
- }
6659
- if (smartFormat != null) {
6660
- _queryParams.smart_format = smartFormat.toString();
6661
- }
6662
- if (summarize != null) {
6663
- _queryParams.summarize = summarize.toString();
6664
- }
6665
- if (tag != null) {
6666
- _queryParams.tag = tag;
6667
- }
6668
- if (topics != null) {
6669
- _queryParams.topics = topics.toString();
6670
- }
6671
- if (uttSplit != null) {
6672
- _queryParams.utt_split = uttSplit.toString();
6673
- }
6674
- if (utterances != null) {
6675
- _queryParams.utterances = utterances.toString();
6676
- }
6677
- if (version != null) {
6678
- _queryParams.version = version.toString();
6679
- }
6241
+ const _queryParams = {
6242
+ start,
6243
+ end,
6244
+ grouping: grouping != null ? grouping : void 0,
6245
+ accessor,
6246
+ alternatives,
6247
+ callback_method: callbackMethod,
6248
+ callback,
6249
+ channels,
6250
+ custom_intent_mode: customIntentMode,
6251
+ custom_intent: customIntent,
6252
+ custom_topic_mode: customTopicMode,
6253
+ custom_topic: customTopic,
6254
+ deployment: deployment != null ? deployment : void 0,
6255
+ detect_entities: detectEntities,
6256
+ detect_language: detectLanguage,
6257
+ diarize,
6258
+ dictation,
6259
+ encoding,
6260
+ endpoint: endpoint != null ? endpoint : void 0,
6261
+ extra,
6262
+ filler_words: fillerWords,
6263
+ intents,
6264
+ keyterm,
6265
+ keywords,
6266
+ language,
6267
+ measurements,
6268
+ method: method != null ? method : void 0,
6269
+ model,
6270
+ multichannel,
6271
+ numerals,
6272
+ paragraphs,
6273
+ profanity_filter: profanityFilter,
6274
+ punctuate,
6275
+ redact,
6276
+ replace,
6277
+ sample_rate: sampleRate,
6278
+ search,
6279
+ sentiment,
6280
+ smart_format: smartFormat,
6281
+ summarize,
6282
+ tag,
6283
+ topics,
6284
+ utt_split: uttSplit,
6285
+ utterances,
6286
+ version
6287
+ };
6680
6288
  const _authRequest = yield this._options.authProvider.getAuthRequest();
6681
6289
  const _headers = mergeHeaders(
6682
6290
  _authRequest.headers,
@@ -6749,13 +6357,10 @@ var Deepgram = (() => {
6749
6357
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
6750
6358
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
6751
6359
  const { start, end } = request;
6752
- const _queryParams = {};
6753
- if (start != null) {
6754
- _queryParams.start = start;
6755
- }
6756
- if (end != null) {
6757
- _queryParams.end = end;
6758
- }
6360
+ const _queryParams = {
6361
+ start,
6362
+ end
6363
+ };
6759
6364
  const _authRequest = yield this._options.authProvider.getAuthRequest();
6760
6365
  const _headers = mergeHeaders(
6761
6366
  _authRequest.headers,
@@ -6923,139 +6528,52 @@ var Deepgram = (() => {
6923
6528
  utterances,
6924
6529
  version
6925
6530
  } = request;
6926
- const _queryParams = {};
6927
- if (start != null) {
6928
- _queryParams.start = start;
6929
- }
6930
- if (end != null) {
6931
- _queryParams.end = end;
6932
- }
6933
- if (accessor != null) {
6934
- _queryParams.accessor = accessor;
6935
- }
6936
- if (alternatives != null) {
6937
- _queryParams.alternatives = alternatives.toString();
6938
- }
6939
- if (callbackMethod != null) {
6940
- _queryParams.callback_method = callbackMethod.toString();
6941
- }
6942
- if (callback != null) {
6943
- _queryParams.callback = callback.toString();
6944
- }
6945
- if (channels != null) {
6946
- _queryParams.channels = channels.toString();
6947
- }
6948
- if (customIntentMode != null) {
6949
- _queryParams.custom_intent_mode = customIntentMode.toString();
6950
- }
6951
- if (customIntent != null) {
6952
- _queryParams.custom_intent = customIntent.toString();
6953
- }
6954
- if (customTopicMode != null) {
6955
- _queryParams.custom_topic_mode = customTopicMode.toString();
6956
- }
6957
- if (customTopic != null) {
6958
- _queryParams.custom_topic = customTopic.toString();
6959
- }
6960
- if (deployment != null) {
6961
- _queryParams.deployment = deployment;
6962
- }
6963
- if (detectEntities != null) {
6964
- _queryParams.detect_entities = detectEntities.toString();
6965
- }
6966
- if (detectLanguage != null) {
6967
- _queryParams.detect_language = detectLanguage.toString();
6968
- }
6969
- if (diarize != null) {
6970
- _queryParams.diarize = diarize.toString();
6971
- }
6972
- if (dictation != null) {
6973
- _queryParams.dictation = dictation.toString();
6974
- }
6975
- if (encoding != null) {
6976
- _queryParams.encoding = encoding.toString();
6977
- }
6978
- if (endpoint != null) {
6979
- _queryParams.endpoint = endpoint;
6980
- }
6981
- if (extra != null) {
6982
- _queryParams.extra = extra.toString();
6983
- }
6984
- if (fillerWords != null) {
6985
- _queryParams.filler_words = fillerWords.toString();
6986
- }
6987
- if (intents != null) {
6988
- _queryParams.intents = intents.toString();
6989
- }
6990
- if (keyterm != null) {
6991
- _queryParams.keyterm = keyterm.toString();
6992
- }
6993
- if (keywords != null) {
6994
- _queryParams.keywords = keywords.toString();
6995
- }
6996
- if (language != null) {
6997
- _queryParams.language = language.toString();
6998
- }
6999
- if (measurements != null) {
7000
- _queryParams.measurements = measurements.toString();
7001
- }
7002
- if (method != null) {
7003
- _queryParams.method = method;
7004
- }
7005
- if (model != null) {
7006
- _queryParams.model = model;
7007
- }
7008
- if (multichannel != null) {
7009
- _queryParams.multichannel = multichannel.toString();
7010
- }
7011
- if (numerals != null) {
7012
- _queryParams.numerals = numerals.toString();
7013
- }
7014
- if (paragraphs != null) {
7015
- _queryParams.paragraphs = paragraphs.toString();
7016
- }
7017
- if (profanityFilter != null) {
7018
- _queryParams.profanity_filter = profanityFilter.toString();
7019
- }
7020
- if (punctuate != null) {
7021
- _queryParams.punctuate = punctuate.toString();
7022
- }
7023
- if (redact != null) {
7024
- _queryParams.redact = redact.toString();
7025
- }
7026
- if (replace != null) {
7027
- _queryParams.replace = replace.toString();
7028
- }
7029
- if (sampleRate != null) {
7030
- _queryParams.sample_rate = sampleRate.toString();
7031
- }
7032
- if (search != null) {
7033
- _queryParams.search = search.toString();
7034
- }
7035
- if (sentiment != null) {
7036
- _queryParams.sentiment = sentiment.toString();
7037
- }
7038
- if (smartFormat != null) {
7039
- _queryParams.smart_format = smartFormat.toString();
7040
- }
7041
- if (summarize != null) {
7042
- _queryParams.summarize = summarize.toString();
7043
- }
7044
- if (tag != null) {
7045
- _queryParams.tag = tag;
7046
- }
7047
- if (topics != null) {
7048
- _queryParams.topics = topics.toString();
7049
- }
7050
- if (uttSplit != null) {
7051
- _queryParams.utt_split = uttSplit.toString();
7052
- }
7053
- if (utterances != null) {
7054
- _queryParams.utterances = utterances.toString();
7055
- }
7056
- if (version != null) {
7057
- _queryParams.version = version.toString();
7058
- }
6531
+ const _queryParams = {
6532
+ start,
6533
+ end,
6534
+ accessor,
6535
+ alternatives,
6536
+ callback_method: callbackMethod,
6537
+ callback,
6538
+ channels,
6539
+ custom_intent_mode: customIntentMode,
6540
+ custom_intent: customIntent,
6541
+ custom_topic_mode: customTopicMode,
6542
+ custom_topic: customTopic,
6543
+ deployment: deployment != null ? deployment : void 0,
6544
+ detect_entities: detectEntities,
6545
+ detect_language: detectLanguage,
6546
+ diarize,
6547
+ dictation,
6548
+ encoding,
6549
+ endpoint: endpoint != null ? endpoint : void 0,
6550
+ extra,
6551
+ filler_words: fillerWords,
6552
+ intents,
6553
+ keyterm,
6554
+ keywords,
6555
+ language,
6556
+ measurements,
6557
+ method: method != null ? method : void 0,
6558
+ model,
6559
+ multichannel,
6560
+ numerals,
6561
+ paragraphs,
6562
+ profanity_filter: profanityFilter,
6563
+ punctuate,
6564
+ redact,
6565
+ replace,
6566
+ sample_rate: sampleRate,
6567
+ search,
6568
+ sentiment,
6569
+ smart_format: smartFormat,
6570
+ summarize,
6571
+ tag,
6572
+ topics,
6573
+ utt_split: uttSplit,
6574
+ utterances,
6575
+ version
6576
+ };
7059
6577
  const _authRequest = yield this._options.authProvider.getAuthRequest();
7060
6578
  const _headers = mergeHeaders(
7061
6579
  _authRequest.headers,
@@ -7206,13 +6724,10 @@ var Deepgram = (() => {
7206
6724
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
7207
6725
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
7208
6726
  const { limit, page } = request;
7209
- const _queryParams = {};
7210
- if (limit != null) {
7211
- _queryParams.limit = limit.toString();
7212
- }
7213
- if (page != null) {
7214
- _queryParams.page = page.toString();
7215
- }
6727
+ const _queryParams = {
6728
+ limit,
6729
+ page
6730
+ };
7216
6731
  const _authRequest = yield this._options.authProvider.getAuthRequest();
7217
6732
  const _headers = mergeHeaders(
7218
6733
  _authRequest.headers,
@@ -7506,55 +7021,20 @@ var Deepgram = (() => {
7506
7021
  language,
7507
7022
  body: _body
7508
7023
  } = request;
7509
- const _queryParams = {};
7510
- if (callback != null) {
7511
- _queryParams.callback = callback;
7512
- }
7513
- if (callbackMethod != null) {
7514
- _queryParams.callback_method = callbackMethod;
7515
- }
7516
- if (sentiment != null) {
7517
- _queryParams.sentiment = sentiment.toString();
7518
- }
7519
- if (summarize != null) {
7520
- _queryParams.summarize = summarize;
7521
- }
7522
- if (tag != null) {
7523
- if (Array.isArray(tag)) {
7524
- _queryParams.tag = tag.map((item) => item);
7525
- } else {
7526
- _queryParams.tag = tag;
7527
- }
7528
- }
7529
- if (topics != null) {
7530
- _queryParams.topics = topics.toString();
7531
- }
7532
- if (customTopic != null) {
7533
- if (Array.isArray(customTopic)) {
7534
- _queryParams.custom_topic = customTopic.map((item) => item);
7535
- } else {
7536
- _queryParams.custom_topic = customTopic;
7537
- }
7538
- }
7539
- if (customTopicMode != null) {
7540
- _queryParams.custom_topic_mode = customTopicMode;
7541
- }
7542
- if (intents != null) {
7543
- _queryParams.intents = intents.toString();
7544
- }
7545
- if (customIntent != null) {
7546
- if (Array.isArray(customIntent)) {
7547
- _queryParams.custom_intent = customIntent.map((item) => item);
7548
- } else {
7549
- _queryParams.custom_intent = customIntent;
7550
- }
7551
- }
7552
- if (customIntentMode != null) {
7553
- _queryParams.custom_intent_mode = customIntentMode;
7554
- }
7555
- if (language != null) {
7556
- _queryParams.language = language;
7557
- }
7024
+ const _queryParams = {
7025
+ callback,
7026
+ callback_method: callbackMethod != null ? callbackMethod : void 0,
7027
+ sentiment,
7028
+ summarize: summarize != null ? summarize : void 0,
7029
+ tag,
7030
+ topics,
7031
+ custom_topic: customTopic,
7032
+ custom_topic_mode: customTopicMode != null ? customTopicMode : void 0,
7033
+ intents,
7034
+ custom_intent: customIntent,
7035
+ custom_intent_mode: customIntentMode != null ? customIntentMode : void 0,
7036
+ language
7037
+ };
7558
7038
  const _authRequest = yield this._options.authProvider.getAuthRequest();
7559
7039
  const _headers = mergeHeaders(
7560
7040
  _authRequest.headers,
@@ -7709,17 +7189,10 @@ var Deepgram = (() => {
7709
7189
  return __async(this, arguments, function* (project_id, request = {}, requestOptions) {
7710
7190
  var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
7711
7191
  const _a = request, { scopes, provider } = _a, _body = __objRest(_a, ["scopes", "provider"]);
7712
- const _queryParams = {};
7713
- if (scopes != null) {
7714
- if (Array.isArray(scopes)) {
7715
- _queryParams.scopes = scopes.map((item) => item);
7716
- } else {
7717
- _queryParams.scopes = scopes;
7718
- }
7719
- }
7720
- if (provider != null) {
7721
- _queryParams.provider = provider;
7722
- }
7192
+ const _queryParams = {
7193
+ scopes: Array.isArray(scopes) ? scopes.map((item) => item) : scopes != null ? scopes : void 0,
7194
+ provider: provider != null ? provider : void 0
7195
+ };
7723
7196
  const _authRequest = yield this._options.authProvider.getAuthRequest();
7724
7197
  const _headers = mergeHeaders(
7725
7198
  _authRequest.headers,
@@ -7961,38 +7434,17 @@ var Deepgram = (() => {
7961
7434
  "model",
7962
7435
  "sample_rate"
7963
7436
  ]);
7964
- const _queryParams = {};
7965
- if (callback != null) {
7966
- _queryParams.callback = callback;
7967
- }
7968
- if (callbackMethod != null) {
7969
- _queryParams.callback_method = callbackMethod;
7970
- }
7971
- if (mipOptOut != null) {
7972
- _queryParams.mip_opt_out = mipOptOut.toString();
7973
- }
7974
- if (tag != null) {
7975
- if (Array.isArray(tag)) {
7976
- _queryParams.tag = tag.map((item) => item);
7977
- } else {
7978
- _queryParams.tag = tag;
7979
- }
7980
- }
7981
- if (bitRate != null) {
7982
- _queryParams.bit_rate = bitRate.toString();
7983
- }
7984
- if (container != null) {
7985
- _queryParams.container = container;
7986
- }
7987
- if (encoding != null) {
7988
- _queryParams.encoding = encoding;
7989
- }
7990
- if (model != null) {
7991
- _queryParams.model = model;
7992
- }
7993
- if (sampleRate != null) {
7994
- _queryParams.sample_rate = sampleRate.toString();
7995
- }
7437
+ const _queryParams = {
7438
+ callback,
7439
+ callback_method: callbackMethod != null ? callbackMethod : void 0,
7440
+ mip_opt_out: mipOptOut,
7441
+ tag,
7442
+ bit_rate: bitRate,
7443
+ container: container != null ? container : void 0,
7444
+ encoding: encoding != null ? encoding : void 0,
7445
+ model: model != null ? model : void 0,
7446
+ sample_rate: sampleRate
7447
+ };
7996
7448
  const _authRequest = yield this._options.authProvider.getAuthRequest();
7997
7449
  const _headers = mergeHeaders(
7998
7450
  _authRequest.headers,
@@ -8082,19 +7534,19 @@ var Deepgram = (() => {
8082
7534
  on(event, callback) {
8083
7535
  this.eventHandlers[event] = callback;
8084
7536
  }
8085
- sendSpeakV1Text(message) {
7537
+ sendText(message) {
8086
7538
  this.assertSocketIsOpen();
8087
7539
  this.sendJson(message);
8088
7540
  }
8089
- sendSpeakV1Flush(message) {
7541
+ sendFlush(message) {
8090
7542
  this.assertSocketIsOpen();
8091
7543
  this.sendJson(message);
8092
7544
  }
8093
- sendSpeakV1Clear(message) {
7545
+ sendClear(message) {
8094
7546
  this.assertSocketIsOpen();
8095
7547
  this.sendJson(message);
8096
7548
  }
8097
- sendSpeakV1Close(message) {
7549
+ sendClose(message) {
8098
7550
  this.assertSocketIsOpen();
8099
7551
  this.sendJson(message);
8100
7552
  }
@@ -8173,19 +7625,12 @@ var Deepgram = (() => {
8173
7625
  debug,
8174
7626
  reconnectAttempts
8175
7627
  } = args;
8176
- const _queryParams = {};
8177
- if (encoding != null) {
8178
- _queryParams.encoding = encoding;
8179
- }
8180
- if (mipOptOut != null) {
8181
- _queryParams.mip_opt_out = mipOptOut;
8182
- }
8183
- if (model != null) {
8184
- _queryParams.model = model;
8185
- }
8186
- if (sampleRate != null) {
8187
- _queryParams.sample_rate = sampleRate;
8188
- }
7628
+ const _queryParams = {
7629
+ encoding,
7630
+ mip_opt_out: mipOptOut,
7631
+ model,
7632
+ sample_rate: sampleRate
7633
+ };
8189
7634
  const _headers = mergeHeaders(
8190
7635
  mergeOnlyDefinedHeaders({ Authorization: args.Authorization }),
8191
7636
  headers
@@ -8252,6 +7697,7 @@ var Deepgram = (() => {
8252
7697
  };
8253
7698
 
8254
7699
  // src/CustomClient.ts
7700
+ var DEFAULT_CONNECTION_TIMEOUT_MS = 1e4;
8255
7701
  var NodeWebSocket2;
8256
7702
  try {
8257
7703
  NodeWebSocket2 = require_browser();
@@ -8260,22 +7706,44 @@ var Deepgram = (() => {
8260
7706
  NodeWebSocket2 = void 0;
8261
7707
  }
8262
7708
  function generateUUID() {
7709
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
7710
+ return crypto.randomUUID();
7711
+ }
8263
7712
  if (RUNTIME.type === "node") {
8264
7713
  try {
8265
- const crypto2 = __require("crypto");
8266
- return crypto2.randomUUID();
7714
+ const nodeCrypto = __require("crypto");
7715
+ return nodeCrypto.randomUUID();
8267
7716
  } catch (e) {
8268
7717
  }
8269
7718
  }
8270
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
8271
- return crypto.randomUUID();
8272
- }
8273
7719
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
8274
7720
  const r = Math.random() * 16 | 0;
8275
7721
  const v = c === "x" ? r : r & 3 | 8;
8276
7722
  return v.toString(16);
8277
7723
  });
8278
7724
  }
7725
+ var ApiKeyAuthProviderWrapper = class {
7726
+ constructor(originalProvider) {
7727
+ this.originalProvider = originalProvider;
7728
+ }
7729
+ getAuthRequest(arg) {
7730
+ return __async(this, null, function* () {
7731
+ var _a, _b;
7732
+ const authRequest = yield this.originalProvider.getAuthRequest(arg);
7733
+ const authHeader = ((_a = authRequest.headers) == null ? void 0 : _a.Authorization) || ((_b = authRequest.headers) == null ? void 0 : _b.authorization);
7734
+ if (authHeader && typeof authHeader === "string") {
7735
+ if (!authHeader.startsWith("Bearer ") && !authHeader.startsWith("Token ") && !authHeader.startsWith("token ")) {
7736
+ return {
7737
+ headers: __spreadProps(__spreadValues({}, authRequest.headers), {
7738
+ Authorization: `Token ${authHeader}`
7739
+ })
7740
+ };
7741
+ }
7742
+ }
7743
+ return authRequest;
7744
+ });
7745
+ }
7746
+ };
8279
7747
  var AccessTokenAuthProviderWrapper = class {
8280
7748
  constructor(originalProvider, accessToken) {
8281
7749
  this.originalProvider = originalProvider;
@@ -8304,6 +7772,7 @@ var Deepgram = (() => {
8304
7772
  });
8305
7773
  super(optionsWithSessionId);
8306
7774
  this._sessionId = sessionId;
7775
+ this._options.authProvider = new ApiKeyAuthProviderWrapper(this._options.authProvider);
8307
7776
  if (options.accessToken != null) {
8308
7777
  this._options.authProvider = new AccessTokenAuthProviderWrapper(
8309
7778
  this._options.authProvider,
@@ -8419,35 +7888,83 @@ var Deepgram = (() => {
8419
7888
  }
8420
7889
  return options;
8421
7890
  }
7891
+ function setupBinaryHandling(socket, eventHandlers) {
7892
+ var _a;
7893
+ const binaryAwareHandler = (event) => {
7894
+ var _a2, _b, _c;
7895
+ if (typeof event.data === "string") {
7896
+ try {
7897
+ const data = fromJson(event.data);
7898
+ (_a2 = eventHandlers.message) == null ? void 0 : _a2.call(eventHandlers, data);
7899
+ } catch (error) {
7900
+ (_b = eventHandlers.message) == null ? void 0 : _b.call(eventHandlers, event.data);
7901
+ }
7902
+ } else {
7903
+ (_c = eventHandlers.message) == null ? void 0 : _c.call(eventHandlers, event.data);
7904
+ }
7905
+ };
7906
+ const socketAny = socket;
7907
+ if ((_a = socketAny._listeners) == null ? void 0 : _a.message) {
7908
+ socketAny._listeners.message.forEach((listener) => {
7909
+ socket.removeEventListener("message", listener);
7910
+ });
7911
+ }
7912
+ socket.addEventListener("message", binaryAwareHandler);
7913
+ return binaryAwareHandler;
7914
+ }
7915
+ function resetSocketConnectionState(socket) {
7916
+ if (socket.readyState === socket.CLOSED) {
7917
+ socket._connectLock = false;
7918
+ socket._shouldReconnect = true;
7919
+ }
7920
+ }
7921
+ function createWebSocketConnection(_0) {
7922
+ return __async(this, arguments, function* ({
7923
+ options,
7924
+ urlPath,
7925
+ environmentKey,
7926
+ queryParams,
7927
+ headers,
7928
+ debug,
7929
+ reconnectAttempts
7930
+ }) {
7931
+ var _a, _b, _c, _d, _e, _f;
7932
+ const authRequest = yield (_a = options.authProvider) == null ? void 0 : _a.getAuthRequest();
7933
+ const mergedHeaders = mergeHeaders(
7934
+ (_b = options.headers) != null ? _b : {},
7935
+ (_c = authRequest == null ? void 0 : authRequest.headers) != null ? _c : {},
7936
+ headers
7937
+ );
7938
+ const _headers = yield resolveHeaders(mergedHeaders);
7939
+ const wsOptions = getWebSocketOptions(_headers);
7940
+ const baseUrl = (_e = yield Supplier.get(options.baseUrl)) != null ? _e : ((_d = yield Supplier.get(options.environment)) != null ? _d : DeepgramEnvironment.Production)[environmentKey];
7941
+ return new ReconnectingWebSocket({
7942
+ url: url_exports.join(baseUrl, urlPath),
7943
+ protocols: (_f = wsOptions.protocols) != null ? _f : [],
7944
+ queryParameters: queryParams,
7945
+ headers: wsOptions.headers,
7946
+ options: {
7947
+ WebSocket: wsOptions.WebSocket,
7948
+ debug: debug != null ? debug : false,
7949
+ maxRetries: reconnectAttempts != null ? reconnectAttempts : 30,
7950
+ startClosed: true,
7951
+ connectionTimeout: DEFAULT_CONNECTION_TIMEOUT_MS
7952
+ }
7953
+ });
7954
+ });
7955
+ }
8422
7956
  var WrappedAgentV1Client = class extends V1Client {
8423
7957
  connect() {
8424
7958
  return __async(this, arguments, function* (args = {}) {
8425
- var _a, _b, _c, _d, _e, _f;
8426
7959
  const { headers, debug, reconnectAttempts } = args;
8427
- const authRequest = yield (_a = this._options.authProvider) == null ? void 0 : _a.getAuthRequest();
8428
- const mergedHeaders = mergeHeaders(
8429
- (_b = this._options.headers) != null ? _b : {},
8430
- (_c = authRequest == null ? void 0 : authRequest.headers) != null ? _c : {},
8431
- headers
8432
- );
8433
- const _headers = yield resolveHeaders(mergedHeaders);
8434
- const wsOptions = getWebSocketOptions(_headers);
8435
- const socket = new ReconnectingWebSocket({
8436
- url: url_exports.join(
8437
- (_e = yield Supplier.get(this._options.baseUrl)) != null ? _e : ((_d = yield Supplier.get(this._options.environment)) != null ? _d : DeepgramEnvironment.Production).agent,
8438
- "/v1/agent/converse"
8439
- ),
8440
- protocols: (_f = wsOptions.protocols) != null ? _f : [],
8441
- queryParameters: {},
8442
- headers: wsOptions.headers,
8443
- options: {
8444
- WebSocket: wsOptions.WebSocket,
8445
- debug: debug != null ? debug : false,
8446
- maxRetries: reconnectAttempts != null ? reconnectAttempts : 30,
8447
- startClosed: true,
8448
- connectionTimeout: 1e4
8449
- // Increase timeout to 10 seconds
8450
- }
7960
+ const socket = yield createWebSocketConnection({
7961
+ options: this._options,
7962
+ urlPath: "/v1/agent/converse",
7963
+ environmentKey: "agent",
7964
+ queryParams: {},
7965
+ headers,
7966
+ debug,
7967
+ reconnectAttempts
8451
7968
  });
8452
7969
  return new WrappedAgentV1Socket({ socket });
8453
7970
  });
@@ -8459,35 +7976,10 @@ var Deepgram = (() => {
8459
7976
  this.setupBinaryHandling();
8460
7977
  }
8461
7978
  setupBinaryHandling() {
8462
- var _a;
8463
- this.binaryAwareHandler = (event) => {
8464
- var _a2, _b, _c, _d, _e, _f;
8465
- if (typeof event.data === "string") {
8466
- try {
8467
- const data = fromJson(event.data);
8468
- (_b = (_a2 = this.eventHandlers).message) == null ? void 0 : _b.call(_a2, data);
8469
- } catch (error) {
8470
- (_d = (_c = this.eventHandlers).message) == null ? void 0 : _d.call(_c, event.data);
8471
- }
8472
- } else {
8473
- (_f = (_e = this.eventHandlers).message) == null ? void 0 : _f.call(_e, event.data);
8474
- }
8475
- };
8476
- const socketAny = this.socket;
8477
- if ((_a = socketAny._listeners) == null ? void 0 : _a.message) {
8478
- socketAny._listeners.message.forEach((listener) => {
8479
- this.socket.removeEventListener("message", listener);
8480
- });
8481
- }
8482
- if (this.binaryAwareHandler) {
8483
- this.socket.addEventListener("message", this.binaryAwareHandler);
8484
- }
7979
+ this.binaryAwareHandler = setupBinaryHandling(this.socket, this.eventHandlers);
8485
7980
  }
8486
7981
  connect() {
8487
- if (this.socket.readyState === this.socket.CLOSED) {
8488
- this.socket._connectLock = false;
8489
- this.socket._shouldReconnect = true;
8490
- }
7982
+ resetSocketConnectionState(this.socket);
8491
7983
  super.connect();
8492
7984
  this.setupBinaryHandling();
8493
7985
  return this;
@@ -8496,7 +7988,6 @@ var Deepgram = (() => {
8496
7988
  var WrappedListenV1Client = class extends V1Client3 {
8497
7989
  connect(args) {
8498
7990
  return __async(this, null, function* () {
8499
- var _a, _b, _c, _d;
8500
7991
  const {
8501
7992
  callback,
8502
7993
  callback_method: callbackMethod,
@@ -8557,30 +8048,14 @@ var Deepgram = (() => {
8557
8048
  if (utteranceEndMs != null) _queryParams.utterance_end_ms = utteranceEndMs;
8558
8049
  if (vadEvents != null) _queryParams.vad_events = vadEvents;
8559
8050
  if (version != null) _queryParams.version = version;
8560
- const authRequest = yield this._options.authProvider.getAuthRequest();
8561
- const mergedHeaders = mergeHeaders(
8562
- (_a = this._options.headers) != null ? _a : {},
8563
- authRequest.headers,
8564
- headers
8565
- );
8566
- const _headers = yield resolveHeaders(mergedHeaders);
8567
- const wsOptions = getWebSocketOptions(_headers);
8568
- const socket = new ReconnectingWebSocket({
8569
- url: url_exports.join(
8570
- (_c = yield Supplier.get(this._options.baseUrl)) != null ? _c : ((_b = yield Supplier.get(this._options.environment)) != null ? _b : DeepgramEnvironment.Production).production,
8571
- "/v1/listen"
8572
- ),
8573
- protocols: (_d = wsOptions.protocols) != null ? _d : [],
8574
- queryParameters: _queryParams,
8575
- headers: wsOptions.headers,
8576
- options: {
8577
- WebSocket: wsOptions.WebSocket,
8578
- debug: debug != null ? debug : false,
8579
- maxRetries: reconnectAttempts != null ? reconnectAttempts : 30,
8580
- startClosed: true,
8581
- connectionTimeout: 1e4
8582
- // Increase timeout to 10 seconds
8583
- }
8051
+ const socket = yield createWebSocketConnection({
8052
+ options: this._options,
8053
+ urlPath: "/v1/listen",
8054
+ environmentKey: "production",
8055
+ queryParams: _queryParams,
8056
+ headers,
8057
+ debug,
8058
+ reconnectAttempts
8584
8059
  });
8585
8060
  return new WrappedListenV1Socket({ socket });
8586
8061
  });
@@ -8592,35 +8067,10 @@ var Deepgram = (() => {
8592
8067
  this.setupBinaryHandling();
8593
8068
  }
8594
8069
  setupBinaryHandling() {
8595
- var _a;
8596
- this.binaryAwareHandler = (event) => {
8597
- var _a2, _b, _c, _d, _e, _f;
8598
- if (typeof event.data === "string") {
8599
- try {
8600
- const data = fromJson(event.data);
8601
- (_b = (_a2 = this.eventHandlers).message) == null ? void 0 : _b.call(_a2, data);
8602
- } catch (error) {
8603
- (_d = (_c = this.eventHandlers).message) == null ? void 0 : _d.call(_c, event.data);
8604
- }
8605
- } else {
8606
- (_f = (_e = this.eventHandlers).message) == null ? void 0 : _f.call(_e, event.data);
8607
- }
8608
- };
8609
- const socketAny = this.socket;
8610
- if ((_a = socketAny._listeners) == null ? void 0 : _a.message) {
8611
- socketAny._listeners.message.forEach((listener) => {
8612
- this.socket.removeEventListener("message", listener);
8613
- });
8614
- }
8615
- if (this.binaryAwareHandler) {
8616
- this.socket.addEventListener("message", this.binaryAwareHandler);
8617
- }
8070
+ this.binaryAwareHandler = setupBinaryHandling(this.socket, this.eventHandlers);
8618
8071
  }
8619
8072
  connect() {
8620
- if (this.socket.readyState === this.socket.CLOSED) {
8621
- this.socket._connectLock = false;
8622
- this.socket._shouldReconnect = true;
8623
- }
8073
+ resetSocketConnectionState(this.socket);
8624
8074
  super.connect();
8625
8075
  this.setupBinaryHandling();
8626
8076
  return this;
@@ -8629,7 +8079,6 @@ var Deepgram = (() => {
8629
8079
  var WrappedListenV2Client = class extends V2Client {
8630
8080
  connect(args) {
8631
8081
  return __async(this, null, function* () {
8632
- var _a, _b, _c, _d, _e, _f;
8633
8082
  const {
8634
8083
  model,
8635
8084
  encoding,
@@ -8654,30 +8103,14 @@ var Deepgram = (() => {
8654
8103
  if (keyterm != null) _queryParams.keyterm = keyterm;
8655
8104
  if (mipOptOut != null) _queryParams.mip_opt_out = mipOptOut;
8656
8105
  if (tag != null) _queryParams.tag = tag;
8657
- const authRequest = yield (_a = this._options.authProvider) == null ? void 0 : _a.getAuthRequest();
8658
- const mergedHeaders = mergeHeaders(
8659
- (_b = this._options.headers) != null ? _b : {},
8660
- (_c = authRequest == null ? void 0 : authRequest.headers) != null ? _c : {},
8661
- headers
8662
- );
8663
- const _headers = yield resolveHeaders(mergedHeaders);
8664
- const wsOptions = getWebSocketOptions(_headers);
8665
- const socket = new ReconnectingWebSocket({
8666
- url: url_exports.join(
8667
- (_e = yield Supplier.get(this._options.baseUrl)) != null ? _e : ((_d = yield Supplier.get(this._options.environment)) != null ? _d : DeepgramEnvironment.Production).production,
8668
- "/v2/listen"
8669
- ),
8670
- protocols: (_f = wsOptions.protocols) != null ? _f : [],
8671
- queryParameters: _queryParams,
8672
- headers: wsOptions.headers,
8673
- options: {
8674
- WebSocket: wsOptions.WebSocket,
8675
- debug: debug != null ? debug : false,
8676
- maxRetries: reconnectAttempts != null ? reconnectAttempts : 30,
8677
- startClosed: true,
8678
- connectionTimeout: 1e4
8679
- // Increase timeout to 10 seconds
8680
- }
8106
+ const socket = yield createWebSocketConnection({
8107
+ options: this._options,
8108
+ urlPath: "/v2/listen",
8109
+ environmentKey: "production",
8110
+ queryParams: _queryParams,
8111
+ headers,
8112
+ debug,
8113
+ reconnectAttempts
8681
8114
  });
8682
8115
  return new WrappedListenV2Socket({ socket });
8683
8116
  });
@@ -8689,44 +8122,44 @@ var Deepgram = (() => {
8689
8122
  this.setupBinaryHandling();
8690
8123
  }
8691
8124
  setupBinaryHandling() {
8692
- var _a;
8693
- this.binaryAwareHandler = (event) => {
8694
- var _a2, _b, _c, _d, _e, _f;
8695
- if (typeof event.data === "string") {
8696
- try {
8697
- const data = fromJson(event.data);
8698
- (_b = (_a2 = this.eventHandlers).message) == null ? void 0 : _b.call(_a2, data);
8699
- } catch (error) {
8700
- (_d = (_c = this.eventHandlers).message) == null ? void 0 : _d.call(_c, event.data);
8701
- }
8702
- } else {
8703
- (_f = (_e = this.eventHandlers).message) == null ? void 0 : _f.call(_e, event.data);
8704
- }
8705
- };
8706
- const socketAny = this.socket;
8707
- if ((_a = socketAny._listeners) == null ? void 0 : _a.message) {
8708
- socketAny._listeners.message.forEach((listener) => {
8709
- this.socket.removeEventListener("message", listener);
8710
- });
8711
- }
8712
- if (this.binaryAwareHandler) {
8713
- this.socket.addEventListener("message", this.binaryAwareHandler);
8714
- }
8125
+ this.binaryAwareHandler = setupBinaryHandling(this.socket, this.eventHandlers);
8715
8126
  }
8716
8127
  connect() {
8717
- if (this.socket.readyState === this.socket.CLOSED) {
8718
- this.socket._connectLock = false;
8719
- this.socket._shouldReconnect = true;
8720
- }
8128
+ resetSocketConnectionState(this.socket);
8721
8129
  super.connect();
8722
8130
  this.setupBinaryHandling();
8723
8131
  return this;
8724
8132
  }
8133
+ /**
8134
+ * Send a WebSocket ping frame to keep the connection alive.
8135
+ *
8136
+ * In Node.js, this uses the native WebSocket ping() method from the 'ws' library.
8137
+ * In browsers, WebSocket ping/pong is handled automatically by the browser and
8138
+ * cannot be manually triggered, so this method will throw an error.
8139
+ *
8140
+ * @param data Optional data to send with the ping (Node.js only)
8141
+ * @throws Error if not in Node.js environment or WebSocket is not connected
8142
+ */
8143
+ ping(data) {
8144
+ const ws = this.socket._ws;
8145
+ if (!ws) {
8146
+ throw new Error("WebSocket is not connected. Call connect() and waitForOpen() first.");
8147
+ }
8148
+ if (ws.readyState !== ws.OPEN) {
8149
+ throw new Error("WebSocket is not in OPEN state.");
8150
+ }
8151
+ if (RUNTIME.type === "node" && typeof ws.ping === "function") {
8152
+ ws.ping(data);
8153
+ } else {
8154
+ throw new Error(
8155
+ "WebSocket ping is not supported in browser environments. Browser WebSocket connections handle ping/pong automatically. If you need keepalive in the browser, consider sending periodic audio data or using a timer."
8156
+ );
8157
+ }
8158
+ }
8725
8159
  };
8726
8160
  var WrappedSpeakV1Client = class extends V1Client7 {
8727
8161
  connect(args) {
8728
8162
  return __async(this, null, function* () {
8729
- var _a, _b, _c, _d;
8730
8163
  const {
8731
8164
  encoding,
8732
8165
  mip_opt_out: mipOptOut,
@@ -8741,30 +8174,14 @@ var Deepgram = (() => {
8741
8174
  if (mipOptOut != null) _queryParams.mip_opt_out = mipOptOut;
8742
8175
  if (model != null) _queryParams.model = model;
8743
8176
  if (sampleRate != null) _queryParams.sample_rate = sampleRate;
8744
- const authRequest = yield this._options.authProvider.getAuthRequest();
8745
- const mergedHeaders = mergeHeaders(
8746
- (_a = this._options.headers) != null ? _a : {},
8747
- authRequest.headers,
8748
- headers
8749
- );
8750
- const _headers = yield resolveHeaders(mergedHeaders);
8751
- const wsOptions = getWebSocketOptions(_headers);
8752
- const socket = new ReconnectingWebSocket({
8753
- url: url_exports.join(
8754
- (_c = yield Supplier.get(this._options.baseUrl)) != null ? _c : ((_b = yield Supplier.get(this._options.environment)) != null ? _b : DeepgramEnvironment.Production).production,
8755
- "/v1/speak"
8756
- ),
8757
- protocols: (_d = wsOptions.protocols) != null ? _d : [],
8758
- queryParameters: _queryParams,
8759
- headers: wsOptions.headers,
8760
- options: {
8761
- WebSocket: wsOptions.WebSocket,
8762
- debug: debug != null ? debug : false,
8763
- maxRetries: reconnectAttempts != null ? reconnectAttempts : 30,
8764
- startClosed: true,
8765
- connectionTimeout: 1e4
8766
- // Increase timeout to 10 seconds
8767
- }
8177
+ const socket = yield createWebSocketConnection({
8178
+ options: this._options,
8179
+ urlPath: "/v1/speak",
8180
+ environmentKey: "production",
8181
+ queryParams: _queryParams,
8182
+ headers,
8183
+ debug,
8184
+ reconnectAttempts
8768
8185
  });
8769
8186
  return new WrappedSpeakV1Socket({ socket });
8770
8187
  });
@@ -8776,35 +8193,10 @@ var Deepgram = (() => {
8776
8193
  this.setupBinaryHandling();
8777
8194
  }
8778
8195
  setupBinaryHandling() {
8779
- var _a;
8780
- this.binaryAwareHandler = (event) => {
8781
- var _a2, _b, _c, _d, _e, _f;
8782
- if (typeof event.data === "string") {
8783
- try {
8784
- const data = fromJson(event.data);
8785
- (_b = (_a2 = this.eventHandlers).message) == null ? void 0 : _b.call(_a2, data);
8786
- } catch (error) {
8787
- (_d = (_c = this.eventHandlers).message) == null ? void 0 : _d.call(_c, event.data);
8788
- }
8789
- } else {
8790
- (_f = (_e = this.eventHandlers).message) == null ? void 0 : _f.call(_e, event.data);
8791
- }
8792
- };
8793
- const socketAny = this.socket;
8794
- if ((_a = socketAny._listeners) == null ? void 0 : _a.message) {
8795
- socketAny._listeners.message.forEach((listener) => {
8796
- this.socket.removeEventListener("message", listener);
8797
- });
8798
- }
8799
- if (this.binaryAwareHandler) {
8800
- this.socket.addEventListener("message", this.binaryAwareHandler);
8801
- }
8196
+ this.binaryAwareHandler = setupBinaryHandling(this.socket, this.eventHandlers);
8802
8197
  }
8803
8198
  connect() {
8804
- if (this.socket.readyState === this.socket.CLOSED) {
8805
- this.socket._connectLock = false;
8806
- this.socket._shouldReconnect = true;
8807
- }
8199
+ resetSocketConnectionState(this.socket);
8808
8200
  super.connect();
8809
8201
  this.setupBinaryHandling();
8810
8202
  return this;