@deepgram/sdk 1.4.2 → 1.4.7
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/billing.d.ts +19 -0
- package/dist/browser/index.js +1 -1
- package/dist/httpRequest.d.ts +3 -0
- package/dist/index.d.ts +20 -1315
- package/dist/index.js +1 -1
- package/dist/invitation.d.ts +30 -0
- package/dist/keys.d.ts +33 -0
- package/dist/members.d.ts +19 -0
- package/dist/projects.d.ts +22 -0
- package/dist/scopes.d.ts +21 -0
- package/dist/usage.d.ts +35 -0
- package/dist/userAgent.d.ts +1 -0
- package/package.json +4 -4
- package/webpack.config.js +1 -3
- package/CHANGELOG.md +0 -203
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BalanceList, Balance, RequestFunction } from "./types";
|
|
2
|
+
export declare class Billing {
|
|
3
|
+
private _credentials;
|
|
4
|
+
private _apiUrl;
|
|
5
|
+
private _request;
|
|
6
|
+
constructor(_credentials: string, _apiUrl: string, _request: RequestFunction);
|
|
7
|
+
private apiPath;
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves list of balance info of the specified project.
|
|
10
|
+
* @param projectId Unique identifier of the project
|
|
11
|
+
*/
|
|
12
|
+
listBalances(projectId: string): Promise<BalanceList>;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves balance info of a specified balance_id in the specified project.
|
|
15
|
+
* @param projectId Unique identifier of the project
|
|
16
|
+
* @param balanceId Unique identifier of the balance
|
|
17
|
+
*/
|
|
18
|
+
getBalance(projectId: string, balanceId: string): Promise<Balance>;
|
|
19
|
+
}
|
package/dist/browser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={587:t=>{function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,i,n,r){i=i||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(i);var o=1e3;r&&"number"==typeof r.maxKeys&&(o=r.maxKeys);var c=t.length;o>0&&c>o&&(c=o);for(var h=0;h<c;++h){var u,l,p,d,v=t[h].replace(a,"%20"),f=v.indexOf(n);f>=0?(u=v.substr(0,f),l=v.substr(f+1)):(u=v,l=""),p=decodeURIComponent(u),d=decodeURIComponent(l),e(s,p)?Array.isArray(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s}},361:t=>{var e=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,i,n,r){return i=i||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(r){var s=encodeURIComponent(e(r))+n;return Array.isArray(t[r])?t[r].map((function(t){return s+encodeURIComponent(e(t))})).join(i):s+encodeURIComponent(e(t[r]))})).join(i):r?encodeURIComponent(e(r))+n+encodeURIComponent(e(t)):""}},673:(t,e,i)=>{e.decode=e.parse=i(587),e.encode=e.stringify=i(361)}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{i.d(n,{X:()=>g});var t=i(673);function e(t){return new Date(1e3*t).toISOString().substr(11,12)}class r{toWebVTT(){var t,i,n,r;if(!this.results||!this.results.utterances)throw new Error("This function requires a transcript that was generated with the utterances feature.");let s="WEBVTT\n\n";s+=`NOTE\nTranscription provided by Deepgram\nRequest Id: ${null===(t=this.metadata)||void 0===t?void 0:t.request_id}\nCreated: ${null===(i=this.metadata)||void 0===i?void 0:i.created}\nDuration: ${null===(n=this.metadata)||void 0===n?void 0:n.duration}\nChannels: ${null===(r=this.metadata)||void 0===r?void 0:r.channels}\n\n`;for(let t=0;t<this.results.utterances.length;t++){const i=this.results.utterances[t];s+=`${t+1}\n${e(i.start)} --\x3e ${e(i.end)}\n- ${i.transcript}\n\n`}return s}toSRT(){if(!this.results||!this.results.utterances)throw new Error("This function requires a transcript that was generated with the utterances feature.");let t="";for(let i=0;i<this.results.utterances.length;i++){const n=this.results.utterances[i];t+=`${i+1}\n${e(n.start).replace(".",",")} --\x3e ${e(n.end).replace(".",",")}\n${n.transcript}\n\n`}return t}}function s(){let t="@deepgram/sdk/UNKNOWN node/UNKNOWN";try{t=`@deepgram/sdk/1.4.2 node/${process.version.replace("v","")}`}catch(t){console.warn("Could not load package details")}return t}function a(t,e,i,n,r){return a=this,o=void 0,h=function*(){const a=`https://${i}${n}`;try{const i=yield fetch(a,{method:t,headers:{Authorization:`token ${e}`,"Content-Type":"application/json","X-DG-Agent":s()},body:r});return yield i.json()}catch(t){throw new Error(`DG: ${t}`)}},new((c=void 0)||(c=Promise))((function(t,e){function i(t){try{r(h.next(t))}catch(t){e(t)}}function n(t){try{r(h.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof c?r:new c((function(t){t(r)}))).then(i,n)}r((h=h.apply(a,o||[])).next())}));var a,o,c,h}class o{constructor(t,e){this._credentials=t,this._apiUrl=e}preRecorded(e,i){return n=this,s=void 0,c=function*(){return yield((e,i,n,s)=>{return o=void 0,c=void 0,u=function*(){const o=Object.assign({},s);if(!n.url)throw new Error("DG: Source must be a URL string");const c=JSON.stringify(n),h=yield a("POST",e,i,`/v1/listen?${t.stringify(o)}`,c);return Object.assign(new r,h)},new((h=void 0)||(h=Promise))((function(t,e){function i(t){try{r(u.next(t))}catch(t){e(t)}}function n(t){try{r(u.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof h?r:new h((function(t){t(r)}))).then(i,n)}r((u=u.apply(o,c||[])).next())}));var o,c,h,u})(this._credentials,this._apiUrl||"",e,i)},new((o=void 0)||(o=Promise))((function(t,e){function i(t){try{a(c.next(t))}catch(t){e(t)}}function r(t){try{a(c.throw(t))}catch(t){e(t)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(i,r)}a((c=c.apply(n,s||[])).next())}));var n,s,o,c}live(e){return new WebSocket(`wss://${this._apiUrl}/v1/listen?${t.stringify(e)}`,["token",this._credentials])}}var c=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class h{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(){return c(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,this.apiPath)}))}get(t){return c(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}`)}))}update(t,e){return c(this,void 0,void 0,(function*(){return this._request("PATCH",this._credentials,this._apiUrl,`${this.apiPath}/${t.project_id}`,JSON.stringify(e))}))}}var u=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class l{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(t){return u(this,void 0,void 0,(function*(){return{api_keys:(yield this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys`)).api_keys.map((t=>Object.assign(Object.assign({},t),t.api_key)))}}))}get(t,e){return u(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys/${e}`)}))}create(t,e,i,n){return u(this,void 0,void 0,(function*(){if(n&&void 0!==n.expirationDate&&void 0!==n.timeToLive)throw new Error("Please provide expirationDate or timeToLive or neither. Providing both is not allowed.");return this._request("POST",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys`,JSON.stringify({comment:e,scopes:i,expiration_date:n&&n.expirationDate?n.expirationDate:void 0,time_to_live_in_seconds:n&&n.timeToLive?n.timeToLive:void 0}))}))}delete(t,e){return u(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys/${e}`)}))}}var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class d{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listRequests(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/requests?${t.stringify(n)}`)}))}getRequest(t,e){return p(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/requests/${e}`)}))}getUsage(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/usage?${t.stringify(n)}`)}))}getFields(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/usage/fields?${t.stringify(n)}`)}))}}var v=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class f{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listMembers(t){return v(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members`)}))}removeMember(t,e){return v(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}`)}))}}var _=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class y{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(t){return _(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites`)}))}send(t,e){return _(this,void 0,void 0,(function*(){return this._request("POST",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites`,JSON.stringify({email:e.email,scope:e.scope}))}))}leave(t){return _(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/leave`)}))}delete(t,e){return _(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites/${e}`)}))}}var $=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class w{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listBalances(t){return $(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/balances`)}))}getBalance(t,e){return $(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/balances/${e}`)}))}}var m=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class U{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}get(t,e){return m(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}/scopes`)}))}update(t,e,i){return m(this,void 0,void 0,(function*(){return this._request("PUT",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}/scopes`,JSON.stringify({scope:i}))}))}}class g{constructor(t,e){this._apiKey=t,this._apiUrl=e||"api.deepgram.com",function(t,e){if(!t||0===t.trim().length)throw new Error("DG: API key is required");if(!e||0===e.trim().length)throw new Error("DG: API url should be a valid url or not provided")}(this._apiKey,this._apiUrl),this.transcription=new o(this._apiKey,this._apiUrl),this.projects=new h(this._apiKey,this._apiUrl,a),this.keys=new l(this._apiKey,this._apiUrl,a),this.usage=new d(this._apiKey,this._apiUrl,a),this.members=new f(this._apiKey,this._apiUrl,a),this.invitation=new y(this._apiKey,this._apiUrl,a),this.billing=new w(this._apiKey,this._apiUrl,a),this.scopes=new U(this._apiKey,this._apiUrl,a)}}})();var r=n.X;export{r as Deepgram};
|
|
1
|
+
var t={587:t=>{function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,i,n,r){i=i||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(i);var o=1e3;r&&"number"==typeof r.maxKeys&&(o=r.maxKeys);var c=t.length;o>0&&c>o&&(c=o);for(var h=0;h<c;++h){var u,l,p,d,v=t[h].replace(a,"%20"),f=v.indexOf(n);f>=0?(u=v.substr(0,f),l=v.substr(f+1)):(u=v,l=""),p=decodeURIComponent(u),d=decodeURIComponent(l),e(s,p)?Array.isArray(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s}},361:t=>{var e=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,i,n,r){return i=i||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(r){var s=encodeURIComponent(e(r))+n;return Array.isArray(t[r])?t[r].map((function(t){return s+encodeURIComponent(e(t))})).join(i):s+encodeURIComponent(e(t[r]))})).join(i):r?encodeURIComponent(e(r))+n+encodeURIComponent(e(t)):""}},673:(t,e,i)=>{e.decode=e.parse=i(587),e.encode=e.stringify=i(361)}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};(()=>{i.d(n,{X:()=>g});var t=i(673);function e(t){return new Date(1e3*t).toISOString().substr(11,12)}class r{toWebVTT(){var t,i,n,r;if(!this.results||!this.results.utterances)throw new Error("This function requires a transcript that was generated with the utterances feature.");let s="WEBVTT\n\n";s+=`NOTE\nTranscription provided by Deepgram\nRequest Id: ${null===(t=this.metadata)||void 0===t?void 0:t.request_id}\nCreated: ${null===(i=this.metadata)||void 0===i?void 0:i.created}\nDuration: ${null===(n=this.metadata)||void 0===n?void 0:n.duration}\nChannels: ${null===(r=this.metadata)||void 0===r?void 0:r.channels}\n\n`;for(let t=0;t<this.results.utterances.length;t++){const i=this.results.utterances[t];s+=`${t+1}\n${e(i.start)} --\x3e ${e(i.end)}\n- ${i.transcript}\n\n`}return s}toSRT(){if(!this.results||!this.results.utterances)throw new Error("This function requires a transcript that was generated with the utterances feature.");let t="";for(let i=0;i<this.results.utterances.length;i++){const n=this.results.utterances[i];t+=`${i+1}\n${e(n.start).replace(".",",")} --\x3e ${e(n.end).replace(".",",")}\n${n.transcript}\n\n`}return t}}function s(){let t="@deepgram/sdk/UNKNOWN node/UNKNOWN";try{t=`@deepgram/sdk/1.4.7 node/${process.version.replace("v","")}`}catch(t){console.warn("Could not load package details")}return t}function a(t,e,i,n,r){return a=this,o=void 0,h=function*(){const a=`https://${i}${n}`;try{const i=yield fetch(a,{method:t,headers:{Authorization:`token ${e}`,"Content-Type":"application/json","X-DG-Agent":s()},body:r});return yield i.json()}catch(t){throw new Error(`DG: ${t}`)}},new((c=void 0)||(c=Promise))((function(t,e){function i(t){try{r(h.next(t))}catch(t){e(t)}}function n(t){try{r(h.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof c?r:new c((function(t){t(r)}))).then(i,n)}r((h=h.apply(a,o||[])).next())}));var a,o,c,h}class o{constructor(t,e){this._credentials=t,this._apiUrl=e}preRecorded(e,i){return n=this,s=void 0,c=function*(){return yield((e,i,n,s)=>{return o=void 0,c=void 0,u=function*(){const o=Object.assign({},s);if(!n.url)throw new Error("DG: Source must be a URL string");const c=JSON.stringify(n),h=yield a("POST",e,i,`/v1/listen?${t.stringify(o)}`,c);return Object.assign(new r,h)},new((h=void 0)||(h=Promise))((function(t,e){function i(t){try{r(u.next(t))}catch(t){e(t)}}function n(t){try{r(u.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof h?r:new h((function(t){t(r)}))).then(i,n)}r((u=u.apply(o,c||[])).next())}));var o,c,h,u})(this._credentials,this._apiUrl||"",e,i)},new((o=void 0)||(o=Promise))((function(t,e){function i(t){try{a(c.next(t))}catch(t){e(t)}}function r(t){try{a(c.throw(t))}catch(t){e(t)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(i,r)}a((c=c.apply(n,s||[])).next())}));var n,s,o,c}live(e){return new WebSocket(`wss://${this._apiUrl}/v1/listen?${t.stringify(e)}`,["token",this._credentials])}}var c=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class h{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(){return c(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,this.apiPath)}))}get(t){return c(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}`)}))}update(t,e){return c(this,void 0,void 0,(function*(){return this._request("PATCH",this._credentials,this._apiUrl,`${this.apiPath}/${t.project_id}`,JSON.stringify(e))}))}}var u=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class l{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(t){return u(this,void 0,void 0,(function*(){return{api_keys:(yield this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys`)).api_keys.map((t=>Object.assign(Object.assign({},t),t.api_key)))}}))}get(t,e){return u(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys/${e}`)}))}create(t,e,i,n){return u(this,void 0,void 0,(function*(){if(n&&void 0!==n.expirationDate&&void 0!==n.timeToLive)throw new Error("Please provide expirationDate or timeToLive or neither. Providing both is not allowed.");return this._request("POST",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys`,JSON.stringify({comment:e,scopes:i,expiration_date:n&&n.expirationDate?n.expirationDate:void 0,time_to_live_in_seconds:n&&n.timeToLive?n.timeToLive:void 0}))}))}delete(t,e){return u(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/keys/${e}`)}))}}var p=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class d{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listRequests(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/requests?${t.stringify(n)}`)}))}getRequest(t,e){return p(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/requests/${e}`)}))}getUsage(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/usage?${t.stringify(n)}`)}))}getFields(e,i){return p(this,void 0,void 0,(function*(){const n=Object.assign({},i);return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${e}/usage/fields?${t.stringify(n)}`)}))}}var v=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class f{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listMembers(t){return v(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members`)}))}removeMember(t,e){return v(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}`)}))}}var _=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class y{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}list(t){return _(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites`)}))}send(t,e){return _(this,void 0,void 0,(function*(){return this._request("POST",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites`,JSON.stringify({email:e.email,scope:e.scope}))}))}leave(t){return _(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/leave`)}))}delete(t,e){return _(this,void 0,void 0,(function*(){return this._request("DELETE",this._credentials,this._apiUrl,`${this.apiPath}/${t}/invites/${e}`)}))}}var $=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class w{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}listBalances(t){return $(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/balances`)}))}getBalance(t,e){return $(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/balances/${e}`)}))}}var m=function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function a(t){try{c(n.next(t))}catch(t){s(t)}}function o(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((n=n.apply(t,e||[])).next())}))};class U{constructor(t,e,i){this._credentials=t,this._apiUrl=e,this._request=i,this.apiPath="/v1/projects"}get(t,e){return m(this,void 0,void 0,(function*(){return this._request("GET",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}/scopes`)}))}update(t,e,i){return m(this,void 0,void 0,(function*(){return this._request("PUT",this._credentials,this._apiUrl,`${this.apiPath}/${t}/members/${e}/scopes`,JSON.stringify({scope:i}))}))}}class g{constructor(t,e){this._apiKey=t,this._apiUrl=e||"api.deepgram.com",function(t,e){if(!t||0===t.trim().length)throw new Error("DG: API key is required");if(!e||0===e.trim().length)throw new Error("DG: API url should be a valid url or not provided")}(this._apiKey,this._apiUrl),this.transcription=new o(this._apiKey,this._apiUrl),this.projects=new h(this._apiKey,this._apiUrl,a),this.keys=new l(this._apiKey,this._apiUrl,a),this.usage=new d(this._apiKey,this._apiUrl,a),this.members=new f(this._apiKey,this._apiUrl,a),this.invitation=new y(this._apiKey,this._apiUrl,a),this.billing=new w(this._apiKey,this._apiUrl,a),this.scopes=new U(this._apiKey,this._apiUrl,a)}}})();var r=n.X;export{r as Deepgram};
|