@deepgram/sdk
Advanced tools
Comparing version 3.0.0-alpha.8 to 3.0.0-alpha.9
@@ -1,2 +0,2 @@ | ||
export declare const version = "3.0.0-alpha.8"; | ||
export declare const version = "3.0.0-alpha.9"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "3.0.0-alpha.8"; | ||
exports.version = "3.0.0-alpha.9"; | ||
//# sourceMappingURL=version.js.map |
@@ -47,3 +47,3 @@ "use strict"; | ||
} | ||
params.headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers); | ||
params.headers = Object.assign({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers); | ||
params.body = body; | ||
@@ -50,0 +50,0 @@ return Object.assign(Object.assign(Object.assign({}, params), parameters), { duplex: "half" }); |
@@ -20,3 +20,2 @@ "use strict"; | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -82,3 +81,2 @@ if ((0, helpers_1.isUrlSource)(source)) { | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -85,0 +83,0 @@ if ((0, helpers_1.isUrlSource)(source)) { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "3.0.0-alpha.8"; | ||
export declare const version = "3.0.0-alpha.9"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "3.0.0-alpha.8"; | ||
export const version = "3.0.0-alpha.9"; | ||
//# sourceMappingURL=version.js.map |
@@ -44,3 +44,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
params.headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers); | ||
params.headers = Object.assign({ "Content-Type": "application/json" }, options === null || options === void 0 ? void 0 : options.headers); | ||
params.body = body; | ||
@@ -47,0 +47,0 @@ return Object.assign(Object.assign(Object.assign({}, params), parameters), { duplex: "half" }); |
@@ -17,3 +17,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -79,3 +78,2 @@ if (isUrlSource(source)) { | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -82,0 +80,0 @@ if (isUrlSource(source)) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepgram=t():e.deepgram=t()}(self,(()=>(()=>{var e={98:function(e,t){var r="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function f(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=f(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&s&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=f(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=u(e),t=h(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[u(e)]},d.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},d.prototype.set=function(e,t){this.map[u(e)]=h(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),l(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),l(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(e,t){var r,n,s=(t=t||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),b.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},m.call(g.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var j=[301,302,303,307,308];_.redirect=function(e,t){if(-1===j.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function E(e,r){return new Promise((function(n,i){var o=new g(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var s="response"in a?a.response:a.responseText;n(new _(s,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}E.polyfill=!0,e.fetch||(e.fetch=E,e.Headers=d,e.Request=g,e.Response=_),t.Headers=d,t.Request=g,t.Response=_,t.fetch=E,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=n;(t=s.fetch).default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,e.exports=t},187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function s(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}v(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&v(e,"error",t,{once:!0})}(e,s)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var s,i,o,u;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=h.bind(n);return s.listener=r,n.wrapFn=s,s}function d(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):f(s,s.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function v(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(i){n.once&&e.removeEventListener(t,s),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,i=this._events;if(void 0!==i)s=s&&void 0===i.error;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,h=f(c,u);for(r=0;r<u;++r)n(h[r],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,s,i,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(s=i[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},198:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});const n=WebSocket},274:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(610),s=r(678),i=r(685),o=r(412),a=r(581);t.default=class{constructor(e,t=s.DEFAULT_OPTIONS){var r,i;if(this.apiKey=e,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key&&!e)throw new Error("A deepgram API key is required");const o=(0,n.applySettingDefaults)(t,s.DEFAULT_OPTIONS);if(!o.global.url)throw new Error(`An API URL is required. It should be set to ${s.DEFAULT_URL} by default. No idea what happened!`);let a=o.global.url;/^https?:\/\//i.test(a)||(a="https://"+a),this.baseUrl=new URL((0,n.stripTrailingSlash)(a)),this.headers=null!==(i=null===(r=o.global)||void 0===r?void 0:r.headers)&&void 0!==i?i:{}}get listen(){return new i.ListenClient(this.baseUrl,this.headers,this.key)}get manage(){return new o.ManageClient(this.baseUrl,this.headers,this.key)}get onprem(){return new a.OnPremClient(this.baseUrl,this.headers,this.key)}}},341:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramClient=t.createClient=void 0;const o=i(r(274));t.DeepgramClient=o.default,t.createClient=(e,t)=>new o.default(e,t),s(r(475),t),s(r(57),t),s(r(678),t),s(r(752),t)},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_URL=t.DEFAULT_HEADERS=void 0;const n=r(610),s=r(506);t.DEFAULT_HEADERS={"X-Client-Info":`@deepgram/sdk; ${(0,n.isBrowser)()?"browser":"server"}; v${s.version}`,"User-Agent":`@deepgram/sdk/${s.version}`},t.DEFAULT_URL="api.deepgram.com",t.DEFAULT_GLOBAL_OPTIONS={url:t.DEFAULT_URL,headers:t.DEFAULT_HEADERS},t.DEFAULT_OPTIONS={global:t.DEFAULT_GLOBAL_OPTIONS}},615:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveConnectionState=void 0,(r=t.LiveConnectionState||(t.LiveConnectionState={}))[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSING=2]="CLOSING",r[r.CLOSED=3]="CLOSED"},178:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=void 0,(r=t.LiveTranscriptionEvents||(t.LiveTranscriptionEvents={})).Open="open",r.Close="close",r.Transcript="Results",r.Metadata="Metadata",r.Error="error",r.Warning="warning"},57:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=t.LiveConnectionState=void 0;var n=r(615);Object.defineProperty(t,"LiveConnectionState",{enumerable:!0,get:function(){return n.LiveConnectionState}});var s=r(178);Object.defineProperty(t,"LiveTranscriptionEvents",{enumerable:!0,get:function(){return s.LiveTranscriptionEvents}})},752:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramUnknownError=t.DeepgramApiError=t.isDeepgramError=t.DeepgramError=void 0;class r extends Error{constructor(e){super(e),this.__dgError=!0,this.name="DeepgramError"}}t.DeepgramError=r,t.isDeepgramError=function(e){return"object"==typeof e&&null!==e&&"__dgError"in e},t.DeepgramApiError=class extends r{constructor(e,t){super(e),this.name="DeepgramApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},t.DeepgramUnknownError=class extends r{constructor(e,t){super(e),this.name="DeepgramUnknownError",this.originalError=t}}},716:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveResponse=t.fetchWithAuth=t.resolveFetch=void 0;const c=a(r(98)),u=r(610);t.resolveFetch=()=>{let e;return e="undefined"==typeof fetch?c.default:fetch,(...t)=>e(...t)},t.fetchWithAuth=e=>{const r=(0,t.resolveFetch)(),n=(0,u.resolveHeadersConstructor)();return(t,s)=>o(void 0,void 0,void 0,(function*(){let i=new n(null==s?void 0:s.headers);return i.has("Authorization")||i.set("Authorization",`Token ${e}`),r(t,Object.assign(Object.assign({},s),{headers:i}))}))},t.resolveResponse=()=>o(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>i(r(98))))).Response:Response}))},610:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackUrl=t.isFileSource=t.isUrlSource=t.resolveHeadersConstructor=t.appendSearchParams=t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=void 0;const n=r(98);t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){const{global:r}=e,{global:n}=t;return{global:Object.assign(Object.assign({},n),r)}},t.appendSearchParams=function(e,t){Object.keys(t).forEach((r=>{Array.isArray(t[r])?t[r].forEach((t=>{e.append(r,String(t))})):e.append(r,String(t[r]))}))},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?n.Headers:Headers,t.isUrlSource=e=>!!e.url,t.isFileSource=e=>!(!i(e)&&!s(e));const s=e=>!!e,i=e=>!!e;class o extends URL{constructor(){super(...arguments),this.callbackUrl=!0}}t.CallbackUrl=o},475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},207:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractRestfulClient=void 0;const s=r(752),i=r(716);t.AbstractRestfulClient=class{constructor(e,t,r){this.baseUrl=e,this.headers=t,this.fetch=(0,i.fetchWithAuth)(r)}_getErrorMessage(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)}handleError(e,t){return n(this,void 0,void 0,(function*(){const r=yield(0,i.resolveResponse)();e instanceof r?e.json().then((r=>{t(new s.DeepgramApiError(this._getErrorMessage(r),e.status||500))})).catch((e=>{t(new s.DeepgramUnknownError(this._getErrorMessage(e),e))})):t(new s.DeepgramUnknownError(this._getErrorMessage(e),e))}))}_getRequestParams(e,t,r,n){const s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({},null==t?void 0:t.headers),s.body=n,Object.assign(Object.assign(Object.assign({},s),r),{duplex:"half"}))}_handleRequest(e,t,r,s,i,o){return n(this,void 0,void 0,(function*(){return new Promise(((n,a)=>{e(r,this._getRequestParams(t,s,i,o)).then((e=>{if(!e.ok)throw e;return(null==s?void 0:s.noResolveJson)?e:e.json()})).then((e=>n(e))).catch((e=>this.handleError(e,a)))}))}))}get(e,t,r,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"GET",t,r,s)}))}post(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"POST",t,s,i,r)}))}put(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PUT",t,s,i,r)}))}patch(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PATCH",t,s,i,r)}))}delete(e,t,r,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"DELETE",t,r,s)}))}}},685:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListenClient=void 0;const n=r(524),s=r(118);t.ListenClient=class{constructor(e,t,r){this.baseUrl=e,this.headers=t,this.key=r}get prerecorded(){return new n.PrerecordedClient(this.baseUrl,this.headers,this.key)}live(e,t="v1/listen"){return new s.LiveClient(this.baseUrl,this.key,e,t)}}},118:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LiveClient=void 0;const s=r(187),i=r(610),o=n(r(198)),a=r(57),c=r(678);class u extends s.EventEmitter{constructor(e,t,r,n="v1/listen"){super();const s=Object.assign({},r),u=new URL(n,e);u.protocol=u.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2"),(0,i.appendSearchParams)(u.searchParams,s),(0,i.isBrowser)()?this._socket=new o.default(u.toString(),["token",t]):this._socket=new o.default(u.toString(),{headers:Object.assign({Authorization:`token ${t}`},c.DEFAULT_HEADERS)}),this._socket.onopen=()=>{this.emit(a.LiveTranscriptionEvents.Open,this)},this._socket.onclose=e=>{const t=e.target;if(t._req){const r=t._req.res.rawHeaders.indexOf("dg-error");e.reason=t._req.res.rawHeaders[r+1]}this.emit(a.LiveTranscriptionEvents.Close,e)},this._socket.onerror=e=>{this.emit(a.LiveTranscriptionEvents.Error,e)},this._socket.onmessage=e=>{try{const t=JSON.parse(e.data.toString());t.type===a.LiveTranscriptionEvents.Metadata&&this.emit(a.LiveTranscriptionEvents.Metadata,t),t.type===a.LiveTranscriptionEvents.Transcript&&this.emit(a.LiveTranscriptionEvents.Transcript,t)}catch(t){this.emit(a.LiveTranscriptionEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:t})}}}configure(e){this._socket.send(JSON.stringify({type:"Configure",processors:e}))}keepAlive(){this._socket.send(JSON.stringify({type:"KeepAlive"}))}getReadyState(){return this._socket.readyState}send(e){this._socket.readyState===a.LiveConnectionState.OPEN?"string"==typeof e||e.byteLength>0?this._socket.send(e):this.emit(a.LiveTranscriptionEvents.Warning,"Zero-byte detected, skipping. Send `CloseStream` if trying to close the connection."):this.emit(a.LiveTranscriptionEvents.Error,"Could not send. Connection not open.")}finish(){this._socket.send(JSON.stringify({type:"CloseStream"})),this._socket.readyState===a.LiveConnectionState.OPEN&&this._socket.close()}}t.LiveClient=u},412:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ManageClient=void 0;const s=r(207),i=r(752),o=r(610);class a extends s.AbstractRestfulClient{getProjects(e="v1/projects"){return n(this,void 0,void 0,(function*(){try{const t=new URL(this.baseUrl);return t.pathname=e,{result:yield this.get(this.fetch,t,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProject(e,t,r="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.patch(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),yield this.delete(this.fetch,r,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectKeys(e,t="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createProjectKey(e,t,r="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMembers(e,t="v1/projects/:projectId/members"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}removeProjectMember(e,t,r="v1/projects/:projectId/members/:memberId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMemberScopes(e,t,r="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProjectMemberScope(e,t,r,s="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=s.replace(/:projectId/,e).replace(/:memberId/,t);const i=JSON.stringify(r);return{result:yield this.put(this.fetch,n,i,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectInvites(e,t="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}sendProjectInvite(e,t,r="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectInvite(e,t,r="v1/projects/:projectId/invites/:email"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:email/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}leaveProject(e,t="v1/projects/:projectId/leave"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.delete(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequests(e,t,r="v1/projects/:projectId/requests"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequest(e,t,r="v1/projects/:projectId/requests/:requestId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:requestId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageSummary(e,t,r="v1/projects/:projectId/usage"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageFields(e,t,r="v1/projects/:projectId/usage/fields"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalances(e,t="v1/projects/:projectId/balances"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalance(e,t,r="v1/projects/:projectId/balances/:balanceId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:balanceId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ManageClient=a},581:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OnPremClient=void 0;const s=r(207),i=r(752);class o extends s.AbstractRestfulClient{listCredentials(e,t="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.delete(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.OnPremClient=o},524:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=void 0;const s=r(207),i=r(610),o=r(752);class a extends s.AbstractRestfulClient{transcribeUrl(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="application/json",!(0,i.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const s=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,i.appendSearchParams)(a.searchParams,s),{result:yield this.post(this.fetch,a,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFile(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="deepgram/audio+video",!(0,i.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=e,void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const s=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,i.appendSearchParams)(a.searchParams,s),{result:yield this.post(this.fetch,a,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeUrlCallback(e,t,r,s="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="application/json",!(0,i.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=JSON.stringify(e);const a=Object.assign(Object.assign({},r),{callback:t.toString()}),c=new URL(s,this.baseUrl);return(0,i.appendSearchParams)(c.searchParams,a),{result:yield this.post(this.fetch,c,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFileCallback(e,t,r,s="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="deepgram/audio+video",!(0,i.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=e;const a=Object.assign(Object.assign({},r),{callback:t.toString()}),c=new URL(s,this.baseUrl);return(0,i.appendSearchParams)(c.searchParams,a),{result:yield this.post(this.fetch,c,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.PrerecordedClient=a}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(341)})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepgram=t():e.deepgram=t()}(self,(()=>(()=>{var e={98:function(e,t){var r="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function f(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=f(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&s&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=f(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=u(e),t=h(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[u(e)]},d.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},d.prototype.set=function(e,t){this.map[u(e)]=h(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),l(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),l(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),l(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(e,t){var r,n,s=(t=t||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),b.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},m.call(g.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var j=[301,302,303,307,308];_.redirect=function(e,t){if(-1===j.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function E(e,r){return new Promise((function(n,i){var o=new g(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var s="response"in a?a.response:a.responseText;n(new _(s,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}E.polyfill=!0,e.fetch||(e.fetch=E,e.Headers=d,e.Request=g,e.Response=_),t.Headers=d,t.Request=g,t.Response=_,t.fetch=E,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=n;(t=s.fetch).default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,e.exports=t},187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function s(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}v(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&v(e,"error",t,{once:!0})}(e,s)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var s,i,o,u;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),o=i[t]),void 0===o)o=i[t]=r,++e._eventsCount;else if("function"==typeof o?o=i[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=c(e))>0&&o.length>s&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=h.bind(n);return s.listener=r,n.wrapFn=s,s}function d(e,t,r){var n=e._events;if(void 0===n)return[];var s=n[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):f(s,s.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function v(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(i){n.once&&e.removeEventListener(t,s),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,i=this._events;if(void 0!==i)s=s&&void 0===i.error;else if(!s)return!1;if(s){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,h=f(c,u);for(r=0;r<u;++r)n(h[r],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,s,i,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(s=i[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return d(this,e,!0)},i.prototype.rawListeners=function(e){return d(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},198:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});const n=WebSocket},274:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(610),s=r(678),i=r(685),o=r(412),a=r(581);t.default=class{constructor(e,t=s.DEFAULT_OPTIONS){var r,i;if(this.apiKey=e,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key&&!e)throw new Error("A deepgram API key is required");const o=(0,n.applySettingDefaults)(t,s.DEFAULT_OPTIONS);if(!o.global.url)throw new Error(`An API URL is required. It should be set to ${s.DEFAULT_URL} by default. No idea what happened!`);let a=o.global.url;/^https?:\/\//i.test(a)||(a="https://"+a),this.baseUrl=new URL((0,n.stripTrailingSlash)(a)),this.headers=null!==(i=null===(r=o.global)||void 0===r?void 0:r.headers)&&void 0!==i?i:{}}get listen(){return new i.ListenClient(this.baseUrl,this.headers,this.key)}get manage(){return new o.ManageClient(this.baseUrl,this.headers,this.key)}get onprem(){return new a.OnPremClient(this.baseUrl,this.headers,this.key)}}},341:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramClient=t.createClient=void 0;const o=i(r(274));t.DeepgramClient=o.default,t.createClient=(e,t)=>new o.default(e,t),s(r(475),t),s(r(57),t),s(r(678),t),s(r(752),t)},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_URL=t.DEFAULT_HEADERS=void 0;const n=r(610),s=r(506);t.DEFAULT_HEADERS={"X-Client-Info":`@deepgram/sdk; ${(0,n.isBrowser)()?"browser":"server"}; v${s.version}`,"User-Agent":`@deepgram/sdk/${s.version}`},t.DEFAULT_URL="api.deepgram.com",t.DEFAULT_GLOBAL_OPTIONS={url:t.DEFAULT_URL,headers:t.DEFAULT_HEADERS},t.DEFAULT_OPTIONS={global:t.DEFAULT_GLOBAL_OPTIONS}},615:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveConnectionState=void 0,(r=t.LiveConnectionState||(t.LiveConnectionState={}))[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSING=2]="CLOSING",r[r.CLOSED=3]="CLOSED"},178:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=void 0,(r=t.LiveTranscriptionEvents||(t.LiveTranscriptionEvents={})).Open="open",r.Close="close",r.Transcript="Results",r.Metadata="Metadata",r.Error="error",r.Warning="warning"},57:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=t.LiveConnectionState=void 0;var n=r(615);Object.defineProperty(t,"LiveConnectionState",{enumerable:!0,get:function(){return n.LiveConnectionState}});var s=r(178);Object.defineProperty(t,"LiveTranscriptionEvents",{enumerable:!0,get:function(){return s.LiveTranscriptionEvents}})},752:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramUnknownError=t.DeepgramApiError=t.isDeepgramError=t.DeepgramError=void 0;class r extends Error{constructor(e){super(e),this.__dgError=!0,this.name="DeepgramError"}}t.DeepgramError=r,t.isDeepgramError=function(e){return"object"==typeof e&&null!==e&&"__dgError"in e},t.DeepgramApiError=class extends r{constructor(e,t){super(e),this.name="DeepgramApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},t.DeepgramUnknownError=class extends r{constructor(e,t){super(e),this.name="DeepgramUnknownError",this.originalError=t}}},716:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveResponse=t.fetchWithAuth=t.resolveFetch=void 0;const c=a(r(98)),u=r(610);t.resolveFetch=()=>{let e;return e="undefined"==typeof fetch?c.default:fetch,(...t)=>e(...t)},t.fetchWithAuth=e=>{const r=(0,t.resolveFetch)(),n=(0,u.resolveHeadersConstructor)();return(t,s)=>o(void 0,void 0,void 0,(function*(){let i=new n(null==s?void 0:s.headers);return i.has("Authorization")||i.set("Authorization",`Token ${e}`),r(t,Object.assign(Object.assign({},s),{headers:i}))}))},t.resolveResponse=()=>o(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>i(r(98))))).Response:Response}))},610:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackUrl=t.isFileSource=t.isUrlSource=t.resolveHeadersConstructor=t.appendSearchParams=t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=void 0;const n=r(98);t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){const{global:r}=e,{global:n}=t;return{global:Object.assign(Object.assign({},n),r)}},t.appendSearchParams=function(e,t){Object.keys(t).forEach((r=>{Array.isArray(t[r])?t[r].forEach((t=>{e.append(r,String(t))})):e.append(r,String(t[r]))}))},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?n.Headers:Headers,t.isUrlSource=e=>!!e.url,t.isFileSource=e=>!(!i(e)&&!s(e));const s=e=>!!e,i=e=>!!e;class o extends URL{constructor(){super(...arguments),this.callbackUrl=!0}}t.CallbackUrl=o},475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},207:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractRestfulClient=void 0;const s=r(752),i=r(716);t.AbstractRestfulClient=class{constructor(e,t,r){this.baseUrl=e,this.headers=t,this.fetch=(0,i.fetchWithAuth)(r)}_getErrorMessage(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)}handleError(e,t){return n(this,void 0,void 0,(function*(){const r=yield(0,i.resolveResponse)();e instanceof r?e.json().then((r=>{t(new s.DeepgramApiError(this._getErrorMessage(r),e.status||500))})).catch((e=>{t(new s.DeepgramUnknownError(this._getErrorMessage(e),e))})):t(new s.DeepgramUnknownError(this._getErrorMessage(e),e))}))}_getRequestParams(e,t,r,n){const s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({"Content-Type":"application/json"},null==t?void 0:t.headers),s.body=n,Object.assign(Object.assign(Object.assign({},s),r),{duplex:"half"}))}_handleRequest(e,t,r,s,i,o){return n(this,void 0,void 0,(function*(){return new Promise(((n,a)=>{e(r,this._getRequestParams(t,s,i,o)).then((e=>{if(!e.ok)throw e;return(null==s?void 0:s.noResolveJson)?e:e.json()})).then((e=>n(e))).catch((e=>this.handleError(e,a)))}))}))}get(e,t,r,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"GET",t,r,s)}))}post(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"POST",t,s,i,r)}))}put(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PUT",t,s,i,r)}))}patch(e,t,r,s,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PATCH",t,s,i,r)}))}delete(e,t,r,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"DELETE",t,r,s)}))}}},685:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListenClient=void 0;const n=r(524),s=r(118);t.ListenClient=class{constructor(e,t,r){this.baseUrl=e,this.headers=t,this.key=r}get prerecorded(){return new n.PrerecordedClient(this.baseUrl,this.headers,this.key)}live(e,t="v1/listen"){return new s.LiveClient(this.baseUrl,this.key,e,t)}}},118:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LiveClient=void 0;const s=r(187),i=r(610),o=n(r(198)),a=r(57),c=r(678);class u extends s.EventEmitter{constructor(e,t,r,n="v1/listen"){super();const s=Object.assign({},r),u=new URL(n,e);u.protocol=u.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2"),(0,i.appendSearchParams)(u.searchParams,s),(0,i.isBrowser)()?this._socket=new o.default(u.toString(),["token",t]):this._socket=new o.default(u.toString(),{headers:Object.assign({Authorization:`token ${t}`},c.DEFAULT_HEADERS)}),this._socket.onopen=()=>{this.emit(a.LiveTranscriptionEvents.Open,this)},this._socket.onclose=e=>{const t=e.target;if(t._req){const r=t._req.res.rawHeaders.indexOf("dg-error");e.reason=t._req.res.rawHeaders[r+1]}this.emit(a.LiveTranscriptionEvents.Close,e)},this._socket.onerror=e=>{this.emit(a.LiveTranscriptionEvents.Error,e)},this._socket.onmessage=e=>{try{const t=JSON.parse(e.data.toString());t.type===a.LiveTranscriptionEvents.Metadata&&this.emit(a.LiveTranscriptionEvents.Metadata,t),t.type===a.LiveTranscriptionEvents.Transcript&&this.emit(a.LiveTranscriptionEvents.Transcript,t)}catch(t){this.emit(a.LiveTranscriptionEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:t})}}}configure(e){this._socket.send(JSON.stringify({type:"Configure",processors:e}))}keepAlive(){this._socket.send(JSON.stringify({type:"KeepAlive"}))}getReadyState(){return this._socket.readyState}send(e){this._socket.readyState===a.LiveConnectionState.OPEN?"string"==typeof e||e.byteLength>0?this._socket.send(e):this.emit(a.LiveTranscriptionEvents.Warning,"Zero-byte detected, skipping. Send `CloseStream` if trying to close the connection."):this.emit(a.LiveTranscriptionEvents.Error,"Could not send. Connection not open.")}finish(){this._socket.send(JSON.stringify({type:"CloseStream"})),this._socket.readyState===a.LiveConnectionState.OPEN&&this._socket.close()}}t.LiveClient=u},412:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ManageClient=void 0;const s=r(207),i=r(752),o=r(610);class a extends s.AbstractRestfulClient{getProjects(e="v1/projects"){return n(this,void 0,void 0,(function*(){try{const t=new URL(this.baseUrl);return t.pathname=e,{result:yield this.get(this.fetch,t,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProject(e,t,r="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.patch(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),yield this.delete(this.fetch,r,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectKeys(e,t="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createProjectKey(e,t,r="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMembers(e,t="v1/projects/:projectId/members"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}removeProjectMember(e,t,r="v1/projects/:projectId/members/:memberId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMemberScopes(e,t,r="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProjectMemberScope(e,t,r,s="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=s.replace(/:projectId/,e).replace(/:memberId/,t);const i=JSON.stringify(r);return{result:yield this.put(this.fetch,n,i,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectInvites(e,t="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}sendProjectInvite(e,t,r="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectInvite(e,t,r="v1/projects/:projectId/invites/:email"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:email/,t),yield this.delete(this.fetch,n,{headers:this.headers}),{error:null}}catch(e){if((0,i.isDeepgramError)(e))return{error:e};throw e}}))}leaveProject(e,t="v1/projects/:projectId/leave"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.delete(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequests(e,t,r="v1/projects/:projectId/requests"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequest(e,t,r="v1/projects/:projectId/requests/:requestId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:requestId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageSummary(e,t,r="v1/projects/:projectId/usage"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageFields(e,t,r="v1/projects/:projectId/usage/fields"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalances(e,t="v1/projects/:projectId/balances"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalance(e,t,r="v1/projects/:projectId/balances/:balanceId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:balanceId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ManageClient=a},581:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OnPremClient=void 0;const s=r(207),i=r(752);class o extends s.AbstractRestfulClient{listCredentials(e,t="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.get(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const s=JSON.stringify(t);return{result:yield this.post(this.fetch,n,s,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.delete(this.fetch,n,{headers:this.headers}),error:null}}catch(e){if((0,i.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.OnPremClient=o},524:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=void 0;const s=r(207),i=r(610),o=r(752);class a extends s.AbstractRestfulClient{transcribeUrl(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,i.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const s=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,i.appendSearchParams)(a.searchParams,s),{result:yield this.post(this.fetch,a,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFile(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="deepgram/audio+video",!(0,i.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=e,void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const s=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,i.appendSearchParams)(a.searchParams,s),{result:yield this.post(this.fetch,a,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeUrlCallback(e,t,r,s="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,i.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=JSON.stringify(e);const a=Object.assign(Object.assign({},r),{callback:t.toString()}),c=new URL(s,this.baseUrl);return(0,i.appendSearchParams)(c.searchParams,a),{result:yield this.post(this.fetch,c,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFileCallback(e,t,r,s="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(this.headers["Content-Type"]="deepgram/audio+video",!(0,i.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=e;const a=Object.assign(Object.assign({},r),{callback:t.toString()}),c=new URL(s,this.baseUrl);return(0,i.appendSearchParams)(c.searchParams,a),{result:yield this.post(this.fetch,c,n,{headers:this.headers}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.PrerecordedClient=a}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(341)})())); |
{ | ||
"name": "@deepgram/sdk", | ||
"version": "3.0.0-alpha.8", | ||
"version": "3.0.0-alpha.9", | ||
"description": "Isomorphic Javascript client for Deepgram", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,1 +0,1 @@ | ||
export const version = "3.0.0-alpha.8"; | ||
export const version = "3.0.0-alpha.9"; |
@@ -51,4 +51,5 @@ import { DeepgramApiError, DeepgramUnknownError } from "../lib/errors"; | ||
params.headers = { ...options?.headers }; | ||
params.headers = { "Content-Type": "application/json", ...options?.headers }; | ||
params.body = body; | ||
return { ...params, ...parameters, duplex: "half" }; | ||
@@ -55,0 +56,0 @@ } |
@@ -21,4 +21,2 @@ import { AbstractRestfulClient } from "./AbstractRestfulClient"; | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -106,4 +104,2 @@ | ||
try { | ||
this.headers["Content-Type"] = "application/json"; | ||
let body; | ||
@@ -110,0 +106,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
417358
6172