@deepgram/sdk 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.global.js +474 -18
- package/dist/cjs/BaseClient.d.ts +3 -0
- package/dist/cjs/BaseClient.js +20 -2
- package/dist/cjs/CustomClient.d.ts +75 -6
- package/dist/cjs/CustomClient.js +421 -15
- package/dist/cjs/api/errors/BadRequestError.js +1 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.ts +7 -3
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.js +1 -7
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +2 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.ts +2 -2
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.ts +2 -2
- package/dist/cjs/api/resources/listen/resources/v1/types/DiarizeModel.d.ts +5 -0
- package/dist/cjs/api/{types/CreateKeyV1RequestOne.js → resources/listen/resources/v1/types/DiarizeModel.js} +5 -0
- package/dist/cjs/api/resources/listen/resources/v1/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v1/types/index.js +1 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +1 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +2 -1
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.ts +2 -1
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.js +5 -1
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.ts +4 -0
- package/dist/cjs/api/types/DeepgramListenProviderV2.d.ts +7 -1
- package/dist/cjs/api/types/ListenV1Diarize.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Diarize.js +1 -1
- package/dist/cjs/api/types/ListenV2ProfanityFilter.d.ts +6 -0
- package/dist/cjs/api/types/ListenV2ProfanityFilter.js +9 -0
- package/dist/cjs/api/types/index.d.ts +1 -0
- package/dist/cjs/api/types/index.js +1 -0
- package/dist/cjs/auth/HeaderAuthProvider.js +2 -1
- package/dist/cjs/core/auth/AuthProvider.d.ts +1 -0
- package/dist/cjs/core/auth/AuthProvider.js +7 -0
- package/dist/cjs/core/auth/index.d.ts +1 -1
- package/dist/cjs/core/auth/index.js +3 -1
- package/dist/cjs/core/fetcher/getResponseBody.js +11 -0
- package/dist/cjs/core/fetcher/requestWithRetries.js +4 -1
- package/dist/cjs/core/fetcher/signals.js +9 -1
- package/dist/cjs/errors/DeepgramError.js +1 -1
- package/dist/cjs/errors/DeepgramTimeoutError.js +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +3 -0
- package/dist/esm/BaseClient.mjs +20 -2
- package/dist/esm/CustomClient.d.mts +75 -6
- package/dist/esm/CustomClient.mjs +421 -15
- package/dist/esm/api/errors/BadRequestError.mjs +1 -1
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts +7 -3
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.mjs +1 -7
- package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +2 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.mts +2 -2
- package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.mts +2 -2
- package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.d.mts +5 -0
- package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.mjs +5 -0
- package/dist/esm/api/resources/listen/resources/v1/types/index.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v1/types/index.mjs +1 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +1 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +2 -1
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.mts +2 -1
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.mjs +5 -1
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.mts +4 -0
- package/dist/esm/api/types/DeepgramListenProviderV2.d.mts +7 -1
- package/dist/esm/api/types/ListenV1Diarize.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Diarize.mjs +1 -1
- package/dist/esm/api/types/ListenV2ProfanityFilter.d.mts +6 -0
- package/dist/esm/api/types/ListenV2ProfanityFilter.mjs +6 -0
- package/dist/esm/api/types/index.d.mts +1 -0
- package/dist/esm/api/types/index.mjs +1 -0
- package/dist/esm/auth/HeaderAuthProvider.mjs +2 -1
- package/dist/esm/core/auth/AuthProvider.d.mts +1 -0
- package/dist/esm/core/auth/AuthProvider.mjs +6 -1
- package/dist/esm/core/auth/index.d.mts +1 -1
- package/dist/esm/core/auth/index.mjs +1 -0
- package/dist/esm/core/fetcher/getResponseBody.mjs +11 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +4 -1
- package/dist/esm/core/fetcher/signals.mjs +9 -1
- package/dist/esm/errors/DeepgramError.mjs +1 -1
- package/dist/esm/errors/DeepgramTimeoutError.mjs +1 -1
- package/dist/esm/index.d.mts +2 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/api/types/CreateKeyV1RequestOne.d.ts +0 -1
- package/dist/esm/api/types/CreateKeyV1RequestOne.d.mts +0 -1
- package/dist/esm/api/types/CreateKeyV1RequestOne.mjs +0 -2
|
@@ -130,9 +130,9 @@ var Deepgram = (() => {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
// node_modules/.pnpm/ws@8.
|
|
133
|
+
// node_modules/.pnpm/ws@8.21.0/node_modules/ws/browser.js
|
|
134
134
|
var require_browser = __commonJS({
|
|
135
|
-
"node_modules/.pnpm/ws@8.
|
|
135
|
+
"node_modules/.pnpm/ws@8.21.0/node_modules/ws/browser.js"(exports, module) {
|
|
136
136
|
"use strict";
|
|
137
137
|
module.exports = function() {
|
|
138
138
|
throw new Error(
|
|
@@ -182,6 +182,7 @@ var Deepgram = (() => {
|
|
|
182
182
|
ListenV1VadEvents: () => ListenV1VadEvents,
|
|
183
183
|
ListenV2Encoding: () => ListenV2Encoding,
|
|
184
184
|
ListenV2Model: () => ListenV2Model,
|
|
185
|
+
ListenV2ProfanityFilter: () => ListenV2ProfanityFilter,
|
|
185
186
|
OpenAiSpeakProvider: () => OpenAiSpeakProvider,
|
|
186
187
|
OpenAiThinkProvider: () => OpenAiThinkProvider,
|
|
187
188
|
SpeakV1Encoding: () => SpeakV1Encoding,
|
|
@@ -227,6 +228,7 @@ var Deepgram = (() => {
|
|
|
227
228
|
ListenV1VadEvents: () => ListenV1VadEvents,
|
|
228
229
|
ListenV2Encoding: () => ListenV2Encoding,
|
|
229
230
|
ListenV2Model: () => ListenV2Model,
|
|
231
|
+
ListenV2ProfanityFilter: () => ListenV2ProfanityFilter,
|
|
230
232
|
OpenAiSpeakProvider: () => OpenAiSpeakProvider,
|
|
231
233
|
OpenAiThinkProvider: () => OpenAiThinkProvider,
|
|
232
234
|
SpeakV1Encoding: () => SpeakV1Encoding,
|
|
@@ -264,7 +266,7 @@ var Deepgram = (() => {
|
|
|
264
266
|
if (Error.captureStackTrace) {
|
|
265
267
|
Error.captureStackTrace(this, this.constructor);
|
|
266
268
|
}
|
|
267
|
-
this.name =
|
|
269
|
+
this.name = "DeepgramError";
|
|
268
270
|
this.statusCode = statusCode;
|
|
269
271
|
this.body = body;
|
|
270
272
|
this.rawResponse = rawResponse;
|
|
@@ -299,7 +301,7 @@ var Deepgram = (() => {
|
|
|
299
301
|
if (Error.captureStackTrace) {
|
|
300
302
|
Error.captureStackTrace(this, this.constructor);
|
|
301
303
|
}
|
|
302
|
-
this.name =
|
|
304
|
+
this.name = "DeepgramTimeoutError";
|
|
303
305
|
if ((opts == null ? void 0 : opts.cause) != null) {
|
|
304
306
|
this.cause = opts.cause;
|
|
305
307
|
}
|
|
@@ -319,7 +321,7 @@ var Deepgram = (() => {
|
|
|
319
321
|
if (Error.captureStackTrace) {
|
|
320
322
|
Error.captureStackTrace(this, this.constructor);
|
|
321
323
|
}
|
|
322
|
-
this.name =
|
|
324
|
+
this.name = "BadRequestError";
|
|
323
325
|
}
|
|
324
326
|
};
|
|
325
327
|
|
|
@@ -433,6 +435,7 @@ var Deepgram = (() => {
|
|
|
433
435
|
// src/api/resources/listen/index.ts
|
|
434
436
|
var listen_exports = {};
|
|
435
437
|
__export(listen_exports, {
|
|
438
|
+
DiarizeModel: () => DiarizeModel,
|
|
436
439
|
ListenV1CloseStream: () => ListenV1CloseStream,
|
|
437
440
|
ListenV1Finalize: () => ListenV1Finalize,
|
|
438
441
|
ListenV1KeepAlive: () => ListenV1KeepAlive,
|
|
@@ -445,6 +448,7 @@ var Deepgram = (() => {
|
|
|
445
448
|
// src/api/resources/listen/resources/v1/index.ts
|
|
446
449
|
var v1_exports3 = {};
|
|
447
450
|
__export(v1_exports3, {
|
|
451
|
+
DiarizeModel: () => DiarizeModel,
|
|
448
452
|
ListenV1CloseStream: () => ListenV1CloseStream,
|
|
449
453
|
ListenV1Finalize: () => ListenV1Finalize,
|
|
450
454
|
ListenV1KeepAlive: () => ListenV1KeepAlive,
|
|
@@ -552,6 +556,12 @@ var Deepgram = (() => {
|
|
|
552
556
|
Latest: "latest"
|
|
553
557
|
};
|
|
554
558
|
|
|
559
|
+
// src/api/resources/listen/resources/v1/types/DiarizeModel.ts
|
|
560
|
+
var DiarizeModel = {
|
|
561
|
+
Latest: "latest",
|
|
562
|
+
V1: "v1"
|
|
563
|
+
};
|
|
564
|
+
|
|
555
565
|
// src/api/resources/listen/resources/v1/types/ListenV1CloseStream.ts
|
|
556
566
|
var ListenV1CloseStream;
|
|
557
567
|
((ListenV1CloseStream2) => {
|
|
@@ -593,8 +603,10 @@ var Deepgram = (() => {
|
|
|
593
603
|
var ListenV2CloseStream;
|
|
594
604
|
((ListenV2CloseStream2) => {
|
|
595
605
|
ListenV2CloseStream2.Type = {
|
|
606
|
+
/** @deprecated Use "CloseStream". Retained for backward compatibility. */
|
|
596
607
|
Finalize: "Finalize",
|
|
597
608
|
CloseStream: "CloseStream",
|
|
609
|
+
/** @deprecated Use "CloseStream". Retained for backward compatibility. */
|
|
598
610
|
KeepAlive: "KeepAlive"
|
|
599
611
|
};
|
|
600
612
|
})(ListenV2CloseStream || (ListenV2CloseStream = {}));
|
|
@@ -1421,6 +1433,12 @@ var Deepgram = (() => {
|
|
|
1421
1433
|
FluxGeneralMulti: "flux-general-multi"
|
|
1422
1434
|
};
|
|
1423
1435
|
|
|
1436
|
+
// src/api/types/ListenV2ProfanityFilter.ts
|
|
1437
|
+
var ListenV2ProfanityFilter = {
|
|
1438
|
+
True: "true",
|
|
1439
|
+
False: "false"
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1424
1442
|
// src/api/types/OpenAiSpeakProvider.ts
|
|
1425
1443
|
var OpenAiSpeakProvider;
|
|
1426
1444
|
((OpenAiSpeakProvider2) => {
|
|
@@ -1543,6 +1561,11 @@ var Deepgram = (() => {
|
|
|
1543
1561
|
FortyEightThousand: "48000"
|
|
1544
1562
|
};
|
|
1545
1563
|
|
|
1564
|
+
// src/core/auth/AuthProvider.ts
|
|
1565
|
+
function isAuthProvider(value) {
|
|
1566
|
+
return typeof value === "object" && value !== null && "getAuthRequest" in value && typeof value.getAuthRequest === "function";
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1546
1569
|
// src/core/auth/NoOpAuthProvider.ts
|
|
1547
1570
|
var NoOpAuthProvider = class {
|
|
1548
1571
|
getAuthRequest() {
|
|
@@ -1787,6 +1810,14 @@ var Deepgram = (() => {
|
|
|
1787
1810
|
}
|
|
1788
1811
|
|
|
1789
1812
|
// src/core/fetcher/getResponseBody.ts
|
|
1813
|
+
function retainResponse(target, response) {
|
|
1814
|
+
Object.defineProperty(target, "__fern_response_ref", {
|
|
1815
|
+
value: response,
|
|
1816
|
+
enumerable: false,
|
|
1817
|
+
configurable: true,
|
|
1818
|
+
writable: false
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1790
1821
|
function getResponseBody(response, responseType) {
|
|
1791
1822
|
return __async(this, null, function* () {
|
|
1792
1823
|
switch (responseType) {
|
|
@@ -1806,6 +1837,7 @@ var Deepgram = (() => {
|
|
|
1806
1837
|
}
|
|
1807
1838
|
};
|
|
1808
1839
|
}
|
|
1840
|
+
retainResponse(response.body, response);
|
|
1809
1841
|
return response.body;
|
|
1810
1842
|
case "streaming":
|
|
1811
1843
|
if (response.body == null) {
|
|
@@ -1817,6 +1849,7 @@ var Deepgram = (() => {
|
|
|
1817
1849
|
}
|
|
1818
1850
|
};
|
|
1819
1851
|
}
|
|
1852
|
+
retainResponse(response.body, response);
|
|
1820
1853
|
return response.body;
|
|
1821
1854
|
case "text":
|
|
1822
1855
|
return yield response.text();
|
|
@@ -1984,11 +2017,15 @@ var Deepgram = (() => {
|
|
|
1984
2017
|
for (const signal of signals) {
|
|
1985
2018
|
if (signal.aborted) {
|
|
1986
2019
|
controller.abort(signal == null ? void 0 : signal.reason);
|
|
1987
|
-
|
|
2020
|
+
return controller.signal;
|
|
1988
2021
|
}
|
|
1989
2022
|
signal.addEventListener("abort", () => controller.abort(signal == null ? void 0 : signal.reason), {
|
|
1990
2023
|
signal: controller.signal
|
|
1991
2024
|
});
|
|
2025
|
+
if (signal.aborted) {
|
|
2026
|
+
controller.abort(signal == null ? void 0 : signal.reason);
|
|
2027
|
+
return controller.signal;
|
|
2028
|
+
}
|
|
1992
2029
|
}
|
|
1993
2030
|
return controller.signal;
|
|
1994
2031
|
}
|
|
@@ -2067,6 +2104,9 @@ var Deepgram = (() => {
|
|
|
2067
2104
|
var MAX_RETRY_DELAY = 6e4;
|
|
2068
2105
|
var DEFAULT_MAX_RETRIES = 2;
|
|
2069
2106
|
var JITTER_FACTOR = 0.2;
|
|
2107
|
+
function isRetryableStatusCode(statusCode) {
|
|
2108
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
2109
|
+
}
|
|
2070
2110
|
function addPositiveJitter(delay) {
|
|
2071
2111
|
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
2072
2112
|
return delay * jitterMultiplier;
|
|
@@ -2106,7 +2146,7 @@ var Deepgram = (() => {
|
|
|
2106
2146
|
return __async(this, arguments, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
2107
2147
|
let response = yield requestFn();
|
|
2108
2148
|
for (let i = 0; i < maxRetries; ++i) {
|
|
2109
|
-
if (
|
|
2149
|
+
if (isRetryableStatusCode(response.status)) {
|
|
2110
2150
|
const delay = getRetryDelayFromHeaders(response, i);
|
|
2111
2151
|
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
2112
2152
|
response = yield requestFn();
|
|
@@ -3499,6 +3539,7 @@ var Deepgram = (() => {
|
|
|
3499
3539
|
var PARAM_KEY = "apiKey";
|
|
3500
3540
|
var ENV_HEADER_KEY = "DEEPGRAM_API_KEY";
|
|
3501
3541
|
var HEADER_NAME = "Authorization";
|
|
3542
|
+
var HEADER_PREFIX = "Token ";
|
|
3502
3543
|
var HeaderAuthProvider = class _HeaderAuthProvider {
|
|
3503
3544
|
constructor(options) {
|
|
3504
3545
|
this.options = options;
|
|
@@ -3519,7 +3560,7 @@ var Deepgram = (() => {
|
|
|
3519
3560
|
});
|
|
3520
3561
|
}
|
|
3521
3562
|
return {
|
|
3522
|
-
headers: { [HEADER_NAME]: headerValue }
|
|
3563
|
+
headers: { [HEADER_NAME]: `${HEADER_PREFIX}${headerValue}` }
|
|
3523
3564
|
};
|
|
3524
3565
|
});
|
|
3525
3566
|
}
|
|
@@ -3557,14 +3598,17 @@ var Deepgram = (() => {
|
|
|
3557
3598
|
return result;
|
|
3558
3599
|
}
|
|
3559
3600
|
|
|
3601
|
+
// src/version.ts
|
|
3602
|
+
var SDK_VERSION = "5.5.0";
|
|
3603
|
+
|
|
3560
3604
|
// src/BaseClient.ts
|
|
3561
3605
|
function normalizeClientOptions(options) {
|
|
3562
3606
|
const headers = mergeHeaders(
|
|
3563
3607
|
{
|
|
3564
3608
|
"X-Fern-Language": "JavaScript",
|
|
3565
3609
|
"X-Fern-SDK-Name": "@deepgram/sdk",
|
|
3566
|
-
"X-Fern-SDK-Version":
|
|
3567
|
-
"User-Agent":
|
|
3610
|
+
"X-Fern-SDK-Version": SDK_VERSION,
|
|
3611
|
+
"User-Agent": `@deepgram/sdk/${SDK_VERSION}`,
|
|
3568
3612
|
"X-Fern-Runtime": RUNTIME.type,
|
|
3569
3613
|
"X-Fern-Runtime-Version": RUNTIME.version
|
|
3570
3614
|
},
|
|
@@ -3578,6 +3622,21 @@ var Deepgram = (() => {
|
|
|
3578
3622
|
function normalizeClientOptionsWithAuth(options) {
|
|
3579
3623
|
var _a;
|
|
3580
3624
|
const normalized = normalizeClientOptions(options);
|
|
3625
|
+
if (options.auth === false) {
|
|
3626
|
+
normalized.authProvider = new NoOpAuthProvider();
|
|
3627
|
+
return normalized;
|
|
3628
|
+
}
|
|
3629
|
+
if (options.auth != null) {
|
|
3630
|
+
if (typeof options.auth === "function") {
|
|
3631
|
+
normalized.authProvider = { getAuthRequest: options.auth };
|
|
3632
|
+
return normalized;
|
|
3633
|
+
}
|
|
3634
|
+
if (isAuthProvider(options.auth)) {
|
|
3635
|
+
normalized.authProvider = options.auth;
|
|
3636
|
+
return normalized;
|
|
3637
|
+
}
|
|
3638
|
+
Object.assign(normalized, options.auth);
|
|
3639
|
+
}
|
|
3581
3640
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
3582
3641
|
(_a = normalized.authProvider) != null ? _a : normalized.authProvider = new HeaderAuthProvider(normalizedWithNoOpAuthProvider);
|
|
3583
3642
|
return normalized;
|
|
@@ -4445,6 +4504,7 @@ var Deepgram = (() => {
|
|
|
4445
4504
|
channels,
|
|
4446
4505
|
detect_entities: detectEntities,
|
|
4447
4506
|
diarize,
|
|
4507
|
+
diarize_model: diarizeModel,
|
|
4448
4508
|
dictation,
|
|
4449
4509
|
encoding,
|
|
4450
4510
|
endpointing,
|
|
@@ -4482,6 +4542,7 @@ var Deepgram = (() => {
|
|
|
4482
4542
|
channels: channels != null ? typeof channels === "string" ? channels : toJson(channels) : void 0,
|
|
4483
4543
|
detect_entities: detectEntities != null ? detectEntities : void 0,
|
|
4484
4544
|
diarize: diarize != null ? diarize : void 0,
|
|
4545
|
+
diarize_model: diarizeModel != null ? diarizeModel : void 0,
|
|
4485
4546
|
dictation: dictation != null ? dictation : void 0,
|
|
4486
4547
|
encoding: encoding != null ? encoding : void 0,
|
|
4487
4548
|
endpointing: endpointing != null ? typeof endpointing === "string" ? endpointing : toJson(endpointing) : void 0,
|
|
@@ -4659,6 +4720,7 @@ var Deepgram = (() => {
|
|
|
4659
4720
|
eot_timeout_ms: eotTimeoutMs,
|
|
4660
4721
|
keyterm,
|
|
4661
4722
|
language_hint: languageHint,
|
|
4723
|
+
profanity_filter: profanityFilter,
|
|
4662
4724
|
mip_opt_out: mipOptOut,
|
|
4663
4725
|
tag,
|
|
4664
4726
|
protocols,
|
|
@@ -4678,6 +4740,7 @@ var Deepgram = (() => {
|
|
|
4678
4740
|
eot_timeout_ms: eotTimeoutMs != null ? typeof eotTimeoutMs === "string" ? eotTimeoutMs : toJson(eotTimeoutMs) : void 0,
|
|
4679
4741
|
keyterm: Array.isArray(keyterm) ? keyterm.map((item) => typeof item === "string" ? item : toJson(item)) : keyterm != null ? typeof keyterm === "string" ? keyterm : toJson(keyterm) : void 0,
|
|
4680
4742
|
language_hint: Array.isArray(languageHint) ? languageHint.map((item) => typeof item === "string" ? item : toJson(item)) : languageHint != null ? typeof languageHint === "string" ? languageHint : toJson(languageHint) : void 0,
|
|
4743
|
+
profanity_filter: profanityFilter != null ? profanityFilter : void 0,
|
|
4681
4744
|
mip_opt_out: mipOptOut != null ? typeof mipOptOut === "string" ? mipOptOut : toJson(mipOptOut) : void 0,
|
|
4682
4745
|
tag: tag != null ? typeof tag === "string" ? tag : toJson(tag) : void 0
|
|
4683
4746
|
};
|
|
@@ -8612,6 +8675,7 @@ var Deepgram = (() => {
|
|
|
8612
8675
|
var WEBSOCKET_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
8613
8676
|
"Authorization",
|
|
8614
8677
|
"headers",
|
|
8678
|
+
"protocols",
|
|
8615
8679
|
"debug",
|
|
8616
8680
|
"reconnectAttempts",
|
|
8617
8681
|
"connectionTimeoutInSeconds",
|
|
@@ -8698,14 +8762,18 @@ var Deepgram = (() => {
|
|
|
8698
8762
|
};
|
|
8699
8763
|
var CustomDeepgramClient = class extends DeepgramClient {
|
|
8700
8764
|
constructor(options = {}) {
|
|
8765
|
+
var _a;
|
|
8701
8766
|
const sessionId = generateUUID();
|
|
8767
|
+
const reconnect = (_a = options.reconnect) != null ? _a : options.transportFactory == null;
|
|
8702
8768
|
const optionsWithSessionId = __spreadProps(__spreadValues({}, options), {
|
|
8769
|
+
reconnect,
|
|
8703
8770
|
headers: __spreadProps(__spreadValues({}, options.headers), {
|
|
8704
8771
|
"x-deepgram-session-id": sessionId
|
|
8705
8772
|
})
|
|
8706
8773
|
});
|
|
8707
8774
|
super(optionsWithSessionId);
|
|
8708
8775
|
this._sessionId = sessionId;
|
|
8776
|
+
this._reconnect = reconnect;
|
|
8709
8777
|
this._options.authProvider = new ApiKeyAuthProviderWrapper(this._options.authProvider);
|
|
8710
8778
|
if (options.accessToken != null) {
|
|
8711
8779
|
this._options.authProvider = new AccessTokenAuthProviderWrapper(
|
|
@@ -8720,6 +8788,16 @@ var Deepgram = (() => {
|
|
|
8720
8788
|
get sessionId() {
|
|
8721
8789
|
return this._sessionId;
|
|
8722
8790
|
}
|
|
8791
|
+
/**
|
|
8792
|
+
* Whether the SDK will retry streaming connections at the wrapper level
|
|
8793
|
+
* after a transport-side failure. Returns `false` when a `transportFactory`
|
|
8794
|
+
* was supplied without an explicit `reconnect: true` override, signalling
|
|
8795
|
+
* that the custom transport is expected to manage its own reconnect
|
|
8796
|
+
* lifecycle.
|
|
8797
|
+
*/
|
|
8798
|
+
get reconnect() {
|
|
8799
|
+
return this._reconnect;
|
|
8800
|
+
}
|
|
8723
8801
|
/**
|
|
8724
8802
|
* Override the agent getter to return a wrapped client that ensures
|
|
8725
8803
|
* the custom websocket implementation is used.
|
|
@@ -8796,13 +8874,353 @@ var Deepgram = (() => {
|
|
|
8796
8874
|
}
|
|
8797
8875
|
return result;
|
|
8798
8876
|
}
|
|
8799
|
-
function
|
|
8877
|
+
function normalizeProtocols(protocols) {
|
|
8878
|
+
if (protocols == null) {
|
|
8879
|
+
return [];
|
|
8880
|
+
}
|
|
8881
|
+
return Array.isArray(protocols) ? protocols : [protocols];
|
|
8882
|
+
}
|
|
8883
|
+
function stringifyHeaders(headers) {
|
|
8884
|
+
const result = {};
|
|
8885
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8886
|
+
result[key] = String(value);
|
|
8887
|
+
}
|
|
8888
|
+
return result;
|
|
8889
|
+
}
|
|
8890
|
+
function buildWebSocketUrl(url, queryParams) {
|
|
8891
|
+
const queryString = url_exports.toQueryString(queryParams, { arrayFormat: "repeat" });
|
|
8892
|
+
return queryString ? `${url}?${queryString}` : url;
|
|
8893
|
+
}
|
|
8894
|
+
function getTransportFactory(options) {
|
|
8895
|
+
return options.transportFactory;
|
|
8896
|
+
}
|
|
8897
|
+
function getReconnect(options) {
|
|
8898
|
+
return options.reconnect !== false;
|
|
8899
|
+
}
|
|
8900
|
+
var TransportWebSocketAdapter = class {
|
|
8901
|
+
constructor(args) {
|
|
8902
|
+
this._listeners = {
|
|
8903
|
+
error: [],
|
|
8904
|
+
message: [],
|
|
8905
|
+
open: [],
|
|
8906
|
+
close: []
|
|
8907
|
+
};
|
|
8908
|
+
this._retryCount = -1;
|
|
8909
|
+
this._shouldReconnect = true;
|
|
8910
|
+
this._connectLock = false;
|
|
8911
|
+
this._binaryType = "blob";
|
|
8912
|
+
this._closeCalled = false;
|
|
8913
|
+
this._messageQueue = [];
|
|
8914
|
+
this.CONNECTING = ReconnectingWebSocket.CONNECTING;
|
|
8915
|
+
this.OPEN = ReconnectingWebSocket.OPEN;
|
|
8916
|
+
this.CLOSING = ReconnectingWebSocket.CLOSING;
|
|
8917
|
+
this.CLOSED = ReconnectingWebSocket.CLOSED;
|
|
8918
|
+
this.onclose = null;
|
|
8919
|
+
this.onerror = null;
|
|
8920
|
+
this.onmessage = null;
|
|
8921
|
+
this.onopen = null;
|
|
8922
|
+
this._handleAbort = () => {
|
|
8923
|
+
if (this._closeCalled) {
|
|
8924
|
+
return;
|
|
8925
|
+
}
|
|
8926
|
+
this._debug("abort signal fired");
|
|
8927
|
+
this._closeCalled = true;
|
|
8928
|
+
this._shouldReconnect = false;
|
|
8929
|
+
this._clearConnectTimeout();
|
|
8930
|
+
const transport = this._transport;
|
|
8931
|
+
this._transport = void 0;
|
|
8932
|
+
this._setTransportHandle(void 0);
|
|
8933
|
+
if (transport) {
|
|
8934
|
+
void transport.close(1e3, "aborted");
|
|
8935
|
+
}
|
|
8936
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSED;
|
|
8937
|
+
this._emitClose(1e3, "aborted");
|
|
8938
|
+
};
|
|
8939
|
+
this._factory = args.factory;
|
|
8940
|
+
this._request = args.request;
|
|
8941
|
+
this._reconnect = args.reconnect !== false;
|
|
8942
|
+
this._readyState = args.startClosed ? ReconnectingWebSocket.ReadyState.CLOSED : ReconnectingWebSocket.ReadyState.CONNECTING;
|
|
8943
|
+
if (this._request.abortSignal) {
|
|
8944
|
+
this._request.abortSignal.addEventListener("abort", this._handleAbort, { once: true });
|
|
8945
|
+
}
|
|
8946
|
+
if (!args.startClosed) {
|
|
8947
|
+
void this._connect();
|
|
8948
|
+
}
|
|
8949
|
+
}
|
|
8950
|
+
get binaryType() {
|
|
8951
|
+
return this._binaryType;
|
|
8952
|
+
}
|
|
8953
|
+
set binaryType(value) {
|
|
8954
|
+
this._binaryType = value;
|
|
8955
|
+
}
|
|
8956
|
+
get retryCount() {
|
|
8957
|
+
return Math.max(this._retryCount, 0);
|
|
8958
|
+
}
|
|
8959
|
+
get bufferedAmount() {
|
|
8960
|
+
return this._messageQueue.reduce((acc, message) => {
|
|
8961
|
+
if (typeof message === "string") {
|
|
8962
|
+
return acc + message.length;
|
|
8963
|
+
}
|
|
8964
|
+
if (message instanceof Blob) {
|
|
8965
|
+
return acc + message.size;
|
|
8966
|
+
}
|
|
8967
|
+
return acc + message.byteLength;
|
|
8968
|
+
}, 0);
|
|
8969
|
+
}
|
|
8970
|
+
get extensions() {
|
|
8971
|
+
return "";
|
|
8972
|
+
}
|
|
8973
|
+
get protocol() {
|
|
8974
|
+
var _a;
|
|
8975
|
+
return (_a = this._request.protocols[0]) != null ? _a : "";
|
|
8976
|
+
}
|
|
8977
|
+
get readyState() {
|
|
8978
|
+
return this._readyState;
|
|
8979
|
+
}
|
|
8980
|
+
get url() {
|
|
8981
|
+
return this._request.url;
|
|
8982
|
+
}
|
|
8983
|
+
close(code = 1e3, reason) {
|
|
8984
|
+
this._closeCalled = true;
|
|
8985
|
+
this._shouldReconnect = false;
|
|
8986
|
+
this._clearConnectTimeout();
|
|
8987
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSING;
|
|
8988
|
+
const transport = this._transport;
|
|
8989
|
+
this._transport = void 0;
|
|
8990
|
+
this._setTransportHandle(void 0);
|
|
8991
|
+
if (!transport) {
|
|
8992
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSED;
|
|
8993
|
+
return;
|
|
8994
|
+
}
|
|
8995
|
+
void transport.close(code, reason);
|
|
8996
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSED;
|
|
8997
|
+
}
|
|
8998
|
+
reconnect(code, reason) {
|
|
8999
|
+
this._shouldReconnect = true;
|
|
9000
|
+
this._closeCalled = false;
|
|
9001
|
+
this._retryCount = -1;
|
|
9002
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CONNECTING;
|
|
9003
|
+
const transport = this._transport;
|
|
9004
|
+
this._transport = void 0;
|
|
9005
|
+
this._setTransportHandle(void 0);
|
|
9006
|
+
if (transport) {
|
|
9007
|
+
void transport.close(code, reason);
|
|
9008
|
+
}
|
|
9009
|
+
void this._connect();
|
|
9010
|
+
}
|
|
9011
|
+
send(data) {
|
|
9012
|
+
var _a;
|
|
9013
|
+
if ((_a = this._transport) == null ? void 0 : _a.isOpen()) {
|
|
9014
|
+
void this._transport.send(data);
|
|
9015
|
+
return;
|
|
9016
|
+
}
|
|
9017
|
+
this._messageQueue.push(data);
|
|
9018
|
+
}
|
|
9019
|
+
addEventListener(type, listener) {
|
|
9020
|
+
if (this._listeners[type]) {
|
|
9021
|
+
this._listeners[type].push(listener);
|
|
9022
|
+
}
|
|
9023
|
+
}
|
|
9024
|
+
dispatchEvent(event) {
|
|
9025
|
+
const listeners = this._listeners[event.type];
|
|
9026
|
+
if (listeners) {
|
|
9027
|
+
for (const listener of listeners) {
|
|
9028
|
+
this._callEventListener(event, listener);
|
|
9029
|
+
}
|
|
9030
|
+
}
|
|
9031
|
+
return true;
|
|
9032
|
+
}
|
|
9033
|
+
removeEventListener(type, listener) {
|
|
9034
|
+
if (this._listeners[type]) {
|
|
9035
|
+
this._listeners[type] = this._listeners[type].filter((registered) => registered !== listener);
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
_debug(...args) {
|
|
9039
|
+
if (this._request.debug) {
|
|
9040
|
+
console.log.apply(console, ["DG-TRANSPORT>", ...args]);
|
|
9041
|
+
}
|
|
9042
|
+
}
|
|
9043
|
+
_connect() {
|
|
9044
|
+
return __async(this, null, function* () {
|
|
9045
|
+
var _a, _b;
|
|
9046
|
+
if (this._connectLock || !this._shouldReconnect || ((_a = this._request.abortSignal) == null ? void 0 : _a.aborted)) {
|
|
9047
|
+
return;
|
|
9048
|
+
}
|
|
9049
|
+
if (!this._reconnect && this._retryCount >= 0) {
|
|
9050
|
+
this._debug("reconnect disabled, skipping retry");
|
|
9051
|
+
return;
|
|
9052
|
+
}
|
|
9053
|
+
if (this._retryCount >= this._request.reconnectAttempts) {
|
|
9054
|
+
this._debug("max retries reached", this._retryCount, ">=", this._request.reconnectAttempts);
|
|
9055
|
+
return;
|
|
9056
|
+
}
|
|
9057
|
+
this._connectLock = true;
|
|
9058
|
+
this._retryCount++;
|
|
9059
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CONNECTING;
|
|
9060
|
+
this._clearConnectTimeout();
|
|
9061
|
+
try {
|
|
9062
|
+
const transport = yield this._factory(this._request.url, this._request.headers, this._request);
|
|
9063
|
+
if (this._closeCalled || ((_b = this._request.abortSignal) == null ? void 0 : _b.aborted)) {
|
|
9064
|
+
this._connectLock = false;
|
|
9065
|
+
yield transport.close(1e3, "aborted");
|
|
9066
|
+
return;
|
|
9067
|
+
}
|
|
9068
|
+
this._transport = transport;
|
|
9069
|
+
this._setTransportHandle(transport);
|
|
9070
|
+
this._bindTransport(transport);
|
|
9071
|
+
this._armConnectTimeout();
|
|
9072
|
+
this._connectLock = false;
|
|
9073
|
+
if (transport.isOpen()) {
|
|
9074
|
+
this._handleOpen(transport);
|
|
9075
|
+
}
|
|
9076
|
+
} catch (error) {
|
|
9077
|
+
this._connectLock = false;
|
|
9078
|
+
this._handleError(error instanceof Error ? error : new Error(String(error)));
|
|
9079
|
+
}
|
|
9080
|
+
});
|
|
9081
|
+
}
|
|
9082
|
+
_bindTransport(transport) {
|
|
9083
|
+
transport.onOpen(() => {
|
|
9084
|
+
if (this._transport !== transport) {
|
|
9085
|
+
return;
|
|
9086
|
+
}
|
|
9087
|
+
this._handleOpen(transport);
|
|
9088
|
+
});
|
|
9089
|
+
transport.onMessage((message) => {
|
|
9090
|
+
if (this._transport !== transport) {
|
|
9091
|
+
return;
|
|
9092
|
+
}
|
|
9093
|
+
this._handleMessage(message);
|
|
9094
|
+
});
|
|
9095
|
+
transport.onError((error) => {
|
|
9096
|
+
if (this._transport !== transport) {
|
|
9097
|
+
return;
|
|
9098
|
+
}
|
|
9099
|
+
this._handleError(error);
|
|
9100
|
+
});
|
|
9101
|
+
transport.onClose((event) => {
|
|
9102
|
+
var _a, _b;
|
|
9103
|
+
if (this._transport !== transport) {
|
|
9104
|
+
return;
|
|
9105
|
+
}
|
|
9106
|
+
this._handleClose((_a = event.code) != null ? _a : 1e3, (_b = event.reason) != null ? _b : "");
|
|
9107
|
+
});
|
|
9108
|
+
}
|
|
9109
|
+
_armConnectTimeout() {
|
|
9110
|
+
const timeoutMs = this._request.connectionTimeoutInSeconds != null ? this._request.connectionTimeoutInSeconds * 1e3 : DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
9111
|
+
this._connectTimeout = setTimeout(() => {
|
|
9112
|
+
this._handleError(new Error("TIMEOUT"));
|
|
9113
|
+
}, timeoutMs);
|
|
9114
|
+
}
|
|
9115
|
+
_clearConnectTimeout() {
|
|
9116
|
+
if (this._connectTimeout != null) {
|
|
9117
|
+
clearTimeout(this._connectTimeout);
|
|
9118
|
+
this._connectTimeout = void 0;
|
|
9119
|
+
}
|
|
9120
|
+
}
|
|
9121
|
+
_handleOpen(transport) {
|
|
9122
|
+
if (this._transport !== transport || this._readyState === ReconnectingWebSocket.ReadyState.OPEN) {
|
|
9123
|
+
return;
|
|
9124
|
+
}
|
|
9125
|
+
this._debug("open event");
|
|
9126
|
+
this._clearConnectTimeout();
|
|
9127
|
+
this._readyState = ReconnectingWebSocket.ReadyState.OPEN;
|
|
9128
|
+
const queued = [...this._messageQueue];
|
|
9129
|
+
this._messageQueue = [];
|
|
9130
|
+
for (const message of queued) {
|
|
9131
|
+
void transport.send(message);
|
|
9132
|
+
}
|
|
9133
|
+
const event = new Event("open", this);
|
|
9134
|
+
if (this.onopen) {
|
|
9135
|
+
this.onopen(event);
|
|
9136
|
+
}
|
|
9137
|
+
this._listeners.open.forEach((listener) => this._callEventListener(event, listener));
|
|
9138
|
+
}
|
|
9139
|
+
_handleMessage(message) {
|
|
9140
|
+
const event = { type: "message", data: message, target: this };
|
|
9141
|
+
if (this.onmessage) {
|
|
9142
|
+
this.onmessage(event);
|
|
9143
|
+
}
|
|
9144
|
+
this._listeners.message.forEach((listener) => this._callEventListener(event, listener));
|
|
9145
|
+
}
|
|
9146
|
+
_handleError(error) {
|
|
9147
|
+
this._debug("error event", error.message);
|
|
9148
|
+
this._clearConnectTimeout();
|
|
9149
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSED;
|
|
9150
|
+
const event = new ErrorEvent(error, this);
|
|
9151
|
+
if (this.onerror) {
|
|
9152
|
+
this.onerror(event);
|
|
9153
|
+
}
|
|
9154
|
+
this._listeners.error.forEach((listener) => this._callEventListener(event, listener));
|
|
9155
|
+
const transport = this._transport;
|
|
9156
|
+
this._transport = void 0;
|
|
9157
|
+
this._setTransportHandle(void 0);
|
|
9158
|
+
if (transport) {
|
|
9159
|
+
void transport.close(1011, error.message);
|
|
9160
|
+
}
|
|
9161
|
+
if (this._shouldReconnect && !this._closeCalled) {
|
|
9162
|
+
void this._connect();
|
|
9163
|
+
}
|
|
9164
|
+
}
|
|
9165
|
+
_handleClose(code, reason) {
|
|
9166
|
+
this._debug("close event", code, reason);
|
|
9167
|
+
this._clearConnectTimeout();
|
|
9168
|
+
this._transport = void 0;
|
|
9169
|
+
this._readyState = ReconnectingWebSocket.ReadyState.CLOSED;
|
|
9170
|
+
this._setTransportHandle(void 0);
|
|
9171
|
+
if (code === 1e3) {
|
|
9172
|
+
this._shouldReconnect = false;
|
|
9173
|
+
}
|
|
9174
|
+
this._emitClose(code, reason);
|
|
9175
|
+
if (this._shouldReconnect && !this._closeCalled) {
|
|
9176
|
+
void this._connect();
|
|
9177
|
+
}
|
|
9178
|
+
}
|
|
9179
|
+
_emitClose(code, reason) {
|
|
9180
|
+
const event = new CloseEvent(code, reason, this);
|
|
9181
|
+
if (this.onclose) {
|
|
9182
|
+
this.onclose(event);
|
|
9183
|
+
}
|
|
9184
|
+
this._listeners.close.forEach((listener) => this._callEventListener(event, listener));
|
|
9185
|
+
}
|
|
9186
|
+
_setTransportHandle(transport) {
|
|
9187
|
+
if (!transport) {
|
|
9188
|
+
this._ws = void 0;
|
|
9189
|
+
return;
|
|
9190
|
+
}
|
|
9191
|
+
this._ws = {
|
|
9192
|
+
OPEN: this.OPEN,
|
|
9193
|
+
get readyState() {
|
|
9194
|
+
return transport.isOpen() ? ReconnectingWebSocket.ReadyState.OPEN : ReconnectingWebSocket.ReadyState.CLOSED;
|
|
9195
|
+
},
|
|
9196
|
+
ping: transport.ping ? (data) => {
|
|
9197
|
+
var _a;
|
|
9198
|
+
void ((_a = transport.ping) == null ? void 0 : _a.call(transport, data));
|
|
9199
|
+
} : void 0
|
|
9200
|
+
};
|
|
9201
|
+
}
|
|
9202
|
+
_callEventListener(event, listener) {
|
|
9203
|
+
if (typeof listener === "object" && listener && "handleEvent" in listener) {
|
|
9204
|
+
listener.handleEvent(event);
|
|
9205
|
+
} else {
|
|
9206
|
+
listener(event);
|
|
9207
|
+
}
|
|
9208
|
+
}
|
|
9209
|
+
};
|
|
9210
|
+
TransportWebSocketAdapter.CONNECTING = ReconnectingWebSocket.CONNECTING;
|
|
9211
|
+
TransportWebSocketAdapter.OPEN = ReconnectingWebSocket.OPEN;
|
|
9212
|
+
TransportWebSocketAdapter.CLOSING = ReconnectingWebSocket.CLOSING;
|
|
9213
|
+
TransportWebSocketAdapter.CLOSED = ReconnectingWebSocket.CLOSED;
|
|
9214
|
+
function getWebSocketOptions(headers, requestedProtocols) {
|
|
8800
9215
|
const options = {};
|
|
8801
9216
|
const isBrowser = RUNTIME.type === "browser" || RUNTIME.type === "web-worker";
|
|
8802
9217
|
const sessionIdHeader = headers["x-deepgram-session-id"] || headers["X-Deepgram-Session-Id"];
|
|
8803
9218
|
if (RUNTIME.type === "node" && NodeWebSocket2) {
|
|
8804
9219
|
options.WebSocket = NodeWebSocket2;
|
|
8805
9220
|
options.headers = headers;
|
|
9221
|
+
if (requestedProtocols.length > 0) {
|
|
9222
|
+
options.protocols = requestedProtocols;
|
|
9223
|
+
}
|
|
8806
9224
|
} else if (isBrowser) {
|
|
8807
9225
|
const authHeader = headers.Authorization || headers.authorization;
|
|
8808
9226
|
const browserHeaders = __spreadValues({}, headers);
|
|
@@ -8811,7 +9229,7 @@ var Deepgram = (() => {
|
|
|
8811
9229
|
delete browserHeaders["x-deepgram-session-id"];
|
|
8812
9230
|
delete browserHeaders["X-Deepgram-Session-Id"];
|
|
8813
9231
|
options.headers = browserHeaders;
|
|
8814
|
-
const protocols = [];
|
|
9232
|
+
const protocols = [...requestedProtocols];
|
|
8815
9233
|
if (authHeader && typeof authHeader === "string") {
|
|
8816
9234
|
if (authHeader.startsWith("Token ")) {
|
|
8817
9235
|
const apiKey = authHeader.substring(6);
|
|
@@ -8831,6 +9249,9 @@ var Deepgram = (() => {
|
|
|
8831
9249
|
}
|
|
8832
9250
|
} else {
|
|
8833
9251
|
options.headers = headers;
|
|
9252
|
+
if (requestedProtocols.length > 0) {
|
|
9253
|
+
options.protocols = requestedProtocols;
|
|
9254
|
+
}
|
|
8834
9255
|
}
|
|
8835
9256
|
return options;
|
|
8836
9257
|
}
|
|
@@ -8884,6 +9305,8 @@ var Deepgram = (() => {
|
|
|
8884
9305
|
urlPath,
|
|
8885
9306
|
environmentKey,
|
|
8886
9307
|
queryParams,
|
|
9308
|
+
protocols,
|
|
9309
|
+
service,
|
|
8887
9310
|
headers,
|
|
8888
9311
|
debug,
|
|
8889
9312
|
reconnectAttempts,
|
|
@@ -8895,10 +9318,35 @@ var Deepgram = (() => {
|
|
|
8895
9318
|
const authRequest = yield (_a = options.authProvider) == null ? void 0 : _a.getAuthRequest();
|
|
8896
9319
|
const mergedHeaders = mergeHeaders((_b = options.headers) != null ? _b : {}, (_c = authRequest == null ? void 0 : authRequest.headers) != null ? _c : {}, headers);
|
|
8897
9320
|
const _headers = yield resolveHeaders(mergedHeaders);
|
|
8898
|
-
const
|
|
9321
|
+
const normalizedProtocols = normalizeProtocols(protocols);
|
|
8899
9322
|
const baseUrl = (_e = yield Supplier.get(options.baseUrl)) != null ? _e : ((_d = yield Supplier.get(options.environment)) != null ? _d : DeepgramEnvironment.Production)[environmentKey];
|
|
9323
|
+
const url = url_exports.join(baseUrl, urlPath);
|
|
9324
|
+
const fullUrl = buildWebSocketUrl(url, queryParams);
|
|
9325
|
+
const transportFactory = getTransportFactory(options);
|
|
9326
|
+
const reconnect = getReconnect(options);
|
|
9327
|
+
if (transportFactory) {
|
|
9328
|
+
const request = {
|
|
9329
|
+
url: fullUrl,
|
|
9330
|
+
headers: stringifyHeaders(_headers),
|
|
9331
|
+
protocols: normalizedProtocols,
|
|
9332
|
+
path: urlPath,
|
|
9333
|
+
service,
|
|
9334
|
+
queryParams,
|
|
9335
|
+
debug: debug != null ? debug : false,
|
|
9336
|
+
reconnectAttempts: reconnectAttempts != null ? reconnectAttempts : 30,
|
|
9337
|
+
connectionTimeoutInSeconds,
|
|
9338
|
+
abortSignal
|
|
9339
|
+
};
|
|
9340
|
+
return new TransportWebSocketAdapter({
|
|
9341
|
+
factory: transportFactory,
|
|
9342
|
+
request,
|
|
9343
|
+
startClosed: true,
|
|
9344
|
+
reconnect
|
|
9345
|
+
});
|
|
9346
|
+
}
|
|
9347
|
+
const wsOptions = getWebSocketOptions(_headers, normalizedProtocols);
|
|
8900
9348
|
return new ReconnectingWebSocket({
|
|
8901
|
-
url
|
|
9349
|
+
url,
|
|
8902
9350
|
protocols: (_f = wsOptions.protocols) != null ? _f : [],
|
|
8903
9351
|
queryParameters: queryParams,
|
|
8904
9352
|
headers: wsOptions.headers,
|
|
@@ -8916,12 +9364,14 @@ var Deepgram = (() => {
|
|
|
8916
9364
|
var WrappedAgentV1Client = class extends V1Client {
|
|
8917
9365
|
connect() {
|
|
8918
9366
|
return __async(this, arguments, function* (args = {}) {
|
|
8919
|
-
const { headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9367
|
+
const { headers, protocols, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
8920
9368
|
const socket = yield createWebSocketConnection({
|
|
8921
9369
|
options: this._options,
|
|
8922
9370
|
urlPath: "/v1/agent/converse",
|
|
8923
9371
|
environmentKey: "agent",
|
|
8924
9372
|
queryParams: buildQueryParams(args),
|
|
9373
|
+
protocols,
|
|
9374
|
+
service: "agent.v1",
|
|
8925
9375
|
headers,
|
|
8926
9376
|
debug,
|
|
8927
9377
|
reconnectAttempts,
|
|
@@ -8975,12 +9425,14 @@ var Deepgram = (() => {
|
|
|
8975
9425
|
var WrappedListenV1Client = class extends V1Client3 {
|
|
8976
9426
|
connect(args) {
|
|
8977
9427
|
return __async(this, null, function* () {
|
|
8978
|
-
const { headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9428
|
+
const { headers, protocols, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
8979
9429
|
const socket = yield createWebSocketConnection({
|
|
8980
9430
|
options: this._options,
|
|
8981
9431
|
urlPath: "/v1/listen",
|
|
8982
9432
|
environmentKey: "production",
|
|
8983
9433
|
queryParams: buildQueryParams(args),
|
|
9434
|
+
protocols,
|
|
9435
|
+
service: "listen.v1",
|
|
8984
9436
|
headers,
|
|
8985
9437
|
debug,
|
|
8986
9438
|
reconnectAttempts,
|
|
@@ -9034,12 +9486,14 @@ var Deepgram = (() => {
|
|
|
9034
9486
|
var WrappedListenV2Client = class extends V2Client {
|
|
9035
9487
|
connect(args) {
|
|
9036
9488
|
return __async(this, null, function* () {
|
|
9037
|
-
const { headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9489
|
+
const { headers, protocols, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9038
9490
|
const socket = yield createWebSocketConnection({
|
|
9039
9491
|
options: this._options,
|
|
9040
9492
|
urlPath: "/v2/listen",
|
|
9041
9493
|
environmentKey: "production",
|
|
9042
9494
|
queryParams: buildQueryParams(args),
|
|
9495
|
+
protocols,
|
|
9496
|
+
service: "listen.v2",
|
|
9043
9497
|
headers,
|
|
9044
9498
|
debug,
|
|
9045
9499
|
reconnectAttempts,
|
|
@@ -9119,12 +9573,14 @@ var Deepgram = (() => {
|
|
|
9119
9573
|
var WrappedSpeakV1Client = class extends V1Client7 {
|
|
9120
9574
|
connect(args) {
|
|
9121
9575
|
return __async(this, null, function* () {
|
|
9122
|
-
const { headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9576
|
+
const { headers, protocols, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal } = args;
|
|
9123
9577
|
const socket = yield createWebSocketConnection({
|
|
9124
9578
|
options: this._options,
|
|
9125
9579
|
urlPath: "/v1/speak",
|
|
9126
9580
|
environmentKey: "production",
|
|
9127
9581
|
queryParams: buildQueryParams(args),
|
|
9582
|
+
protocols,
|
|
9583
|
+
service: "speak.v1",
|
|
9128
9584
|
headers,
|
|
9129
9585
|
debug,
|
|
9130
9586
|
reconnectAttempts,
|