@api7/portal-sdk 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ "use strict";const Z=require("axios"),ee=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:s,responseValidator:i,sseDefaultRetryDelay:l,sseMaxRetryAttempts:a,sseMaxRetryDelay:n,sseSleepFn:o,url:h,...d})=>{let c;const f=o??(T=>new Promise(m=>setTimeout(m,T)));return{stream:async function*(){let T=l??3e3,m=0;const b=d.signal??new AbortController().signal;for(;!b.aborted;){m++;const $=d.headers instanceof Headers?d.headers:new Headers(d.headers);c!==void 0&&$.set("Last-Event-ID",c);try{const P={redirect:"follow",...d,body:d.serializedBody,headers:$,signal:b};let R=new Request(h,P);e&&(R=await e(h,P));const S=await(d.fetch??globalThis.fetch)(R);if(!S.ok)throw new Error(`SSE failed: ${S.status} ${S.statusText}`);if(!S.body)throw new Error("No body in SSE response");const D=S.body.pipeThrough(new TextDecoderStream).getReader();let j="";const k=()=>{try{D.cancel()}catch{}};b.addEventListener("abort",k);try{for(;;){const{done:K,value:Q}=await D.read();if(K)break;j+=Q,j=j.replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `);const O=j.split(`
4
+
5
+ `);j=O.pop()??"";for(const X of O){const Y=X.split(`
6
+ `),E=[];let U;for(const y of Y)if(y.startsWith("data:"))E.push(y.replace(/^data:\s*/,""));else if(y.startsWith("event:"))U=y.replace(/^event:\s*/,"");else if(y.startsWith("id:"))c=y.replace(/^id:\s*/,"");else if(y.startsWith("retry:")){const B=Number.parseInt(y.replace(/^retry:\s*/,""),10);Number.isNaN(B)||(T=B)}let g,q=!1;if(E.length){const y=E.join(`
7
+ `);try{g=JSON.parse(y),q=!0}catch{g=y}}q&&(i&&await i(g),s&&(g=await s(g))),r?.({data:g,event:U,id:c,retry:T}),E.length&&(yield g)}}}finally{b.removeEventListener("abort",k),D.releaseLock()}break}catch(P){if(t?.(P),a!==void 0&&m>=a)break;const R=Math.min(T*2**(m-1),n??3e4);await f(R)}}}()}},te=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},re=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},se=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},H=({allowReserved:e,explode:t,name:r,style:s,value:i})=>{if(!t){const n=(e?i:i.map(o=>encodeURIComponent(o))).join(re(s));switch(s){case"label":return`.${n}`;case"matrix":return`;${r}=${n}`;case"simple":return n;default:return`${r}=${n}`}}const l=te(s),a=i.map(n=>s==="label"||s==="simple"?e?n:encodeURIComponent(n):I({allowReserved:e,name:r,value:n})).join(l);return s==="label"||s==="matrix"?l+a:a},I=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},V=({allowReserved:e,explode:t,name:r,style:s,value:i,valueOnly:l})=>{if(i instanceof Date)return l?i.toISOString():`${r}=${i.toISOString()}`;if(s!=="deepObject"&&!t){let o=[];Object.entries(i).forEach(([d,c])=>{o=[...o,d,e?c:encodeURIComponent(c)]});const h=o.join(",");switch(s){case"form":return`${r}=${h}`;case"label":return`.${h}`;case"matrix":return`;${r}=${h}`;default:return h}}const a=se(s),n=Object.entries(i).map(([o,h])=>I({allowReserved:e,name:s==="deepObject"?`${r}[${o}]`:o,value:h})).join(a);return s==="label"||s==="matrix"?a+n:n},ie=/\{[^{}]+\}/g,ne=({path:e,url:t})=>{let r=t;const s=t.match(ie);if(s)for(const i of s){let l=!1,a=i.substring(1,i.length-1),n="simple";a.endsWith("*")&&(l=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),n="label"):a.startsWith(";")&&(a=a.substring(1),n="matrix");const o=e[a];if(o==null)continue;if(Array.isArray(o)){r=r.replace(i,H({explode:l,name:a,style:n,value:o}));continue}if(typeof o=="object"){r=r.replace(i,V({explode:l,name:a,style:n,value:o,valueOnly:!0}));continue}if(n==="matrix"){r=r.replace(i,`;${I({name:a,value:o})}`);continue}const h=encodeURIComponent(n==="label"?`.${o}`:o);r=r.replace(i,h)}return r},ae=({baseUrl:e,path:t,query:r,querySerializer:s,url:i})=>{const l=i.startsWith("/")?i:`/${i}`;let a=(e??"")+l;t&&(a=ne({path:t,url:a}));let n=r?s(r):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(a+=`?${n}`),a};function N(e){const t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}const ce=async(e,t)=>{const r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r},oe=({parameters:e={},...t}={})=>s=>{const i=[];if(s&&typeof s=="object")for(const l in s){const a=s[l];if(a==null)continue;const n=e[l]||t;if(Array.isArray(a)){const o=H({allowReserved:n.allowReserved,explode:!0,name:l,style:"form",value:a,...n.array});o&&i.push(o)}else if(typeof a=="object"){const o=V({allowReserved:n.allowReserved,explode:!0,name:l,style:"deepObject",value:a,...n.object});o&&i.push(o)}else{const o=I({allowReserved:n.allowReserved,name:l,value:a});o&&i.push(o)}}return i.join("&")},le=(e,t)=>t?t in e.headers||e.query?.[t]?!0:"Cookie"in e.headers&&e.headers.Cookie&&typeof e.headers.Cookie=="string"?e.headers.Cookie.includes(`${t}=`):!1:!1,pe=async({security:e,...t})=>{for(const r of e){if(le(t,r.name))continue;const s=await ce(r,t.auth);if(!s)continue;const i=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[i]=s;break;case"cookie":{const l=`${i}=${s}`;"Cookie"in t.headers&&t.headers.Cookie?t.headers.Cookie=`${t.headers.Cookie}; ${l}`:t.headers.Cookie=l;break}case"header":default:t.headers[i]=s;break}}},L=e=>{const t=e.axios?.defaults?.baseURL,r=e.baseURL&&typeof e.baseURL=="string"?e.baseURL:t;return ae({baseUrl:r,path:e.path,query:e.paramsSerializer?void 0:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:oe(e.querySerializer),url:e.url})},W=(e,t)=>{const r={...e,...t};return r.headers=z(e.headers,t.headers),r},ue=["common","delete","get","head","patch","post","put"],z=(...e)=>{const t={};for(const r of e){if(!r||typeof r!="object")continue;const s=Object.entries(r);for(const[i,l]of s)if(ue.includes(i)&&typeof l=="object")t[i]={...t[i],...l};else if(l===null)delete t[i];else if(Array.isArray(l))for(const a of l)t[i]=[...t[i]??[],a];else l!==void 0&&(t[i]=typeof l=="object"?JSON.stringify(l):l)}return t},M=(e={})=>({...e}),F=(e={})=>{let t=W(M(),e),r;if(t.axios&&!("Axios"in t.axios))r=t.axios;else{const{auth:d,...c}=t;r=Z.create(c)}const s=()=>({...t}),i=d=>(t=W(t,d),r.defaults={...r.defaults,...t,headers:z(r.defaults.headers,t.headers)},s()),l=async d=>{const c={...t,...d,axios:d.axios??t.axios??r,headers:z(t.headers,d.headers)};c.security&&await pe({...c,security:c.security}),c.requestValidator&&await c.requestValidator(c),c.body!==void 0&&c.bodySerializer&&(c.body=c.bodySerializer(c.body));const f=L(c);return{opts:c,url:f}},a=async d=>{const{opts:c,url:f}=await l(d);try{const A=c.axios,{auth:w,...T}=c,m=await A({...T,baseURL:"",data:N(c),headers:c.headers,params:c.paramsSerializer?c.query:void 0,url:f});let{data:b}=m;return c.responseType==="json"&&(c.responseValidator&&await c.responseValidator(b),c.responseTransformer&&(b=await c.responseTransformer(b))),{...m,data:b??{}}}catch(A){const w=A;if(c.throwOnError)throw w;return w.error=w.response?.data??{},w}},n=d=>c=>a({...c,method:d}),o=d=>async c=>{const{opts:f,url:A}=await l(c);return ee({...f,body:f.body,headers:f.headers,method:d,serializedBody:N(f),signal:f.signal,url:A})};return{buildUrl:d=>L({axios:r,...t,...d}),connect:n("CONNECT"),delete:n("DELETE"),get:n("GET"),getConfig:s,head:n("HEAD"),instance:r,options:n("OPTIONS"),patch:n("PATCH"),post:n("POST"),put:n("PUT"),request:a,setConfig:i,sse:{connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),head:o("HEAD"),options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),trace:o("TRACE")},trace:n("TRACE")}},u=F(M()),_=e=>(e=new Date(e),e),J=e=>(e.last_active_at&&(e.last_active_at=_(e.last_active_at)),e.created_at=_(e.created_at),e.updated_at=_(e.updated_at),e),de=async e=>(e.list=e.list.map(t=>J(t)),e),he=async e=>(e=J(e),e),fe=e=>(e.subscribed_at&&(e.subscribed_at=_(e.subscribed_at)),e),ye=async e=>(e.list=e.list.map(t=>fe(t)),e),G=e=>(e.created_at=_(e.created_at),e.updated_at=_(e.updated_at),e),x=e=>(e=G(e),e),be=e=>(e=x(e),e),me=async e=>(e.list=e.list.map(t=>be(t)),e),Te=async e=>(e=x(e),e),ge=async e=>(e=x(e),e),Ae=async e=>(e=x(e),e),C=e=>(e=G(e),e),we=async e=>(e.list=e.list.map(t=>C(t)),e),_e=async e=>(e=C(e),e),Ce=async e=>(e=C(e),e),Se=async e=>(e=C(e),e),je=async e=>(e=C(e),e),ve=async e=>(e.list=e.list.map(t=>C(t)),e),Pe=e=>(e?.client??u).get({responseTransformer:de,responseType:"json",url:"/api/developers",...e}),Re=e=>(e?.client??u).post({responseTransformer:he,responseType:"json",url:"/api/developers",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Ee=e=>(e.client??u).delete({url:"/api/developers/{developer_id}",...e}),Ie=e=>(e?.client??u).get({responseType:"json",url:"/api/api_products",...e}),xe=e=>(e.client??u).get({responseType:"json",url:"/api/api_products/{api_product_id}",...e}),De=e=>(e.client??u).post({url:"/api/api_products/{api_product_id}/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),ze=e=>(e?.client??u).get({responseTransformer:ye,responseType:"json",url:"/api/subscriptions",...e}),$e=e=>(e?.client??u).post({url:"/api/subscriptions",...e,headers:{"Content-Type":"application/json",...e?.headers}}),ke=e=>(e.client??u).delete({url:"/api/subscriptions/{subscription_id}",...e}),Oe=e=>(e?.client??u).get({responseTransformer:me,responseType:"json",url:"/api/applications",...e}),Ue=e=>(e?.client??u).post({responseTransformer:Te,responseType:"json",url:"/api/applications",...e,headers:{"Content-Type":"application/json",...e?.headers}}),qe=e=>(e.client??u).delete({url:"/api/applications/{application_id}",...e}),Be=e=>(e.client??u).get({responseTransformer:ge,responseType:"json",url:"/api/applications/{application_id}",...e}),Ne=e=>(e.client??u).put({responseTransformer:Ae,responseType:"json",url:"/api/applications/{application_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Le=e=>(e.client??u).get({responseTransformer:we,responseType:"json",url:"/api/applications/{application_id}/credentials",...e}),We=e=>(e.client??u).post({responseTransformer:_e,responseType:"json",url:"/api/applications/{application_id}/credentials",...e,headers:{"Content-Type":"application/json",...e.headers}}),He=e=>(e.client??u).delete({url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Ve=e=>(e.client??u).get({responseTransformer:Ce,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Me=e=>(e.client??u).put({responseTransformer:Se,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Fe=e=>(e.client??u).put({responseTransformer:je,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}/regenerate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Je=e=>(e.client??u).get({responseType:"json",url:"/api/applications/api_calls",...e}),Ge=e=>(e?.client??u).get({responseTransformer:ve,responseType:"json",url:"/api/credentials",...e}),Ke=e=>(e.client??u).get({responseType:"json",url:"/api/labels/{resource_type}",...e}),Qe=e=>(e?.client??u).get({responseType:"json",url:"/api/system_settings/public_access",...e}),Xe=e=>(e?.client??u).get({responseType:"json",url:"/api/dcr_providers",...e});class v extends Error{constructor(t,r,s,i,l){super(t),this.message=t,this.status=r,this.method=s,this.url=i,this.stack=void 0,this.#e=l}#e;static fromAxiosError=t=>{const r=t.error&&t.error.error_msg;return new v(`Request failed: ${r||(t.status?`with status code ${t.status}`:t.message)}`,t.status??0,t.config?.method?.toUpperCase()??"",t.config?.url??"",t)};static isAPIError=t=>t instanceof v;rawError(){return this.#e}}const p=e=>{if(e.error||e.status&&e.status>=400)throw v.fromAxiosError(e);return e.data};class Ye{constructor(t){this.client=t}async create(t,r){return p(await We({client:this.client,path:{application_id:t},body:r}))}async list(t,r){return p(await Le({client:this.client,path:{application_id:t},query:r}))}async get(t,r){return p(await Ve({client:this.client,path:{application_id:t,credential_id:r}}))}async update(t,r,s){return p(await Me({client:this.client,path:{application_id:t,credential_id:r},body:s}))}async delete(t,r){return p(await He({client:this.client,path:{application_id:t,credential_id:r}}))}async regenerate(t,r,s){return p(await Fe({client:this.client,path:{application_id:t,credential_id:r},body:s}))}}class Ze{constructor(t){this.client=t}async list(t){return p(await Ge({client:this.client,query:t}))}}class et{constructor(t){this.client=t,this.credential=new Ye(this.client)}credential;async create(t){return p(await Ue({client:this.client,body:t}))}async list(t){return p(await Oe({client:this.client,query:t}))}async get(t){return p(await Be({client:this.client,path:{application_id:t}}))}async update(t,r){return p(await Ne({client:this.client,path:{application_id:t},body:r}))}async delete(t){p(await qe({client:this.client,path:{application_id:t}}))}async apiCall(t){return p(await Je({client:this.client,query:t}))}}class tt{constructor(t){this.client=t}async list(t){return p(await Xe({client:this.client,query:t}))}}class rt{constructor(t){this.client=t}async getPublicAccess(){return p(await Qe({client:this.client})).portal_public_access}}class st{constructor(t){this.client=t}async listLabels(t){return p(await Ke({client:this.client,path:{resource_type:t}}))}}class it{constructor(t){this.client=t}async create(t){return p(await Re({client:this.client,body:t}))}async list(t){return p(await Pe({client:this.client,query:t}))}async delete(t){p(await Ee({client:this.client,path:{developer_id:t}}))}}class nt{constructor(t){this.client=t}async list(t){return p(await Ie({client:this.client,query:t}))}async get(t){return p(await xe({client:this.client,path:{api_product_id:t}}))}async subscribe(t,r){p(await De({client:this.client,path:{api_product_id:t},body:r}))}}class at{constructor(t){this.client=t}async list(t){return p(await ze({client:this.client,query:t}))}async bulkSubscribe(t){p(await $e({client:this.client,body:t}))}async unsubscribe(t){p(await ke({client:this.client,path:{subscription_id:t}}))}}exports.APIError=v;exports.APIProductAPI=nt;exports.ApplicationAPI=et;exports.CredentialAPI=Ze;exports.DCRProviderAPI=tt;exports.DeveloperAPI=it;exports.MiscellaneousAPI=st;exports.SubscriptionAPI=at;exports.SystemSettingAPI=rt;exports.createClient=F;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api7/portal-sdk",
3
3
  "description": "API7 Portal JavaScript SDK",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "url": "https://github.com/api7/portal-sdk-typescript",
@@ -34,10 +34,10 @@
34
34
  "!**/*.tsbuildinfo"
35
35
  ],
36
36
  "devDependencies": {
37
- "@hey-api/openapi-ts": "0.89.2"
37
+ "@hey-api/openapi-ts": "0.94.5"
38
38
  },
39
39
  "dependencies": {
40
- "axios": "^1.13.2"
40
+ "axios": "^1.14.0"
41
41
  },
42
42
  "nx": {
43
43
  "name": "portal-sdk",
@@ -1,7 +0,0 @@
1
- "use strict";const Y=require("axios"),Z=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:s,responseValidator:i,sseDefaultRetryDelay:l,sseMaxRetryAttempts:c,sseMaxRetryDelay:n,sseSleepFn:o,url:d,...a})=>{let h;const m=o??(b=>new Promise(y=>setTimeout(y,b)));return{stream:async function*(){let b=l??3e3,y=0;const j=a.signal??new AbortController().signal;for(;!j.aborted;){y++;const z=a.headers instanceof Headers?a.headers:new Headers(a.headers);h!==void 0&&z.set("Last-Event-ID",h);try{const v={redirect:"follow",...a,body:a.serializedBody,headers:z,signal:j};let P=new Request(d,v);e&&(P=await e(d,v));const _=await(a.fetch??globalThis.fetch)(P);if(!_.ok)throw new Error(`SSE failed: ${_.status} ${_.statusText}`);if(!_.body)throw new Error("No body in SSE response");const D=_.body.pipeThrough(new TextDecoderStream).getReader();let C="";const k=()=>{try{D.cancel()}catch{}};j.addEventListener("abort",k);try{for(;;){const{done:G,value:K}=await D.read();if(G)break;C+=K,C=C.replace(/\r\n/g,`
2
- `).replace(/\r/g,`
3
- `);const O=C.split(`
4
-
5
- `);C=O.pop()??"";for(const Q of O){const X=Q.split(`
6
- `),R=[];let q;for(const f of X)if(f.startsWith("data:"))R.push(f.replace(/^data:\s*/,""));else if(f.startsWith("event:"))q=f.replace(/^event:\s*/,"");else if(f.startsWith("id:"))h=f.replace(/^id:\s*/,"");else if(f.startsWith("retry:")){const B=Number.parseInt(f.replace(/^retry:\s*/,""),10);Number.isNaN(B)||(b=B)}let T,U=!1;if(R.length){const f=R.join(`
7
- `);try{T=JSON.parse(f),U=!0}catch{T=f}}U&&(i&&await i(T),s&&(T=await s(T))),r?.({data:T,event:q,id:h,retry:b}),R.length&&(yield T)}}}finally{j.removeEventListener("abort",k),D.releaseLock()}break}catch(v){if(t?.(v),c!==void 0&&y>=c)break;const P=Math.min(b*2**(y-1),n??3e4);await m(P)}}}()}},ee=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},te=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},re=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},W=({allowReserved:e,explode:t,name:r,style:s,value:i})=>{if(!t){const n=(e?i:i.map(o=>encodeURIComponent(o))).join(te(s));switch(s){case"label":return`.${n}`;case"matrix":return`;${r}=${n}`;case"simple":return n;default:return`${r}=${n}`}}const l=ee(s),c=i.map(n=>s==="label"||s==="simple"?e?n:encodeURIComponent(n):E({allowReserved:e,name:r,value:n})).join(l);return s==="label"||s==="matrix"?l+c:c},E=({allowReserved:e,name:t,value:r})=>{if(r==null)return"";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},H=({allowReserved:e,explode:t,name:r,style:s,value:i,valueOnly:l})=>{if(i instanceof Date)return l?i.toISOString():`${r}=${i.toISOString()}`;if(s!=="deepObject"&&!t){let o=[];Object.entries(i).forEach(([a,h])=>{o=[...o,a,e?h:encodeURIComponent(h)]});const d=o.join(",");switch(s){case"form":return`${r}=${d}`;case"label":return`.${d}`;case"matrix":return`;${r}=${d}`;default:return d}}const c=re(s),n=Object.entries(i).map(([o,d])=>E({allowReserved:e,name:s==="deepObject"?`${r}[${o}]`:o,value:d})).join(c);return s==="label"||s==="matrix"?c+n:n},se=/\{[^{}]+\}/g,ie=({path:e,url:t})=>{let r=t;const s=t.match(se);if(s)for(const i of s){let l=!1,c=i.substring(1,i.length-1),n="simple";c.endsWith("*")&&(l=!0,c=c.substring(0,c.length-1)),c.startsWith(".")?(c=c.substring(1),n="label"):c.startsWith(";")&&(c=c.substring(1),n="matrix");const o=e[c];if(o==null)continue;if(Array.isArray(o)){r=r.replace(i,W({explode:l,name:c,style:n,value:o}));continue}if(typeof o=="object"){r=r.replace(i,H({explode:l,name:c,style:n,value:o,valueOnly:!0}));continue}if(n==="matrix"){r=r.replace(i,`;${E({name:c,value:o})}`);continue}const d=encodeURIComponent(n==="label"?`.${o}`:o);r=r.replace(i,d)}return r},ne=({baseUrl:e,path:t,query:r,querySerializer:s,url:i})=>{const l=i.startsWith("/")?i:`/${i}`;let c=(e??"")+l;t&&(c=ie({path:t,url:c}));let n=r?s(r):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(c+=`?${n}`),c};function ae(e){const t=e.body!==void 0;if(t&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(t)return e.body}const ce=async(e,t)=>{const r=typeof t=="function"?await t(e):t;if(r)return e.scheme==="bearer"?`Bearer ${r}`:e.scheme==="basic"?`Basic ${btoa(r)}`:r},oe=({parameters:e={},...t}={})=>s=>{const i=[];if(s&&typeof s=="object")for(const l in s){const c=s[l];if(c==null)continue;const n=e[l]||t;if(Array.isArray(c)){const o=W({allowReserved:n.allowReserved,explode:!0,name:l,style:"form",value:c,...n.array});o&&i.push(o)}else if(typeof c=="object"){const o=H({allowReserved:n.allowReserved,explode:!0,name:l,style:"deepObject",value:c,...n.object});o&&i.push(o)}else{const o=E({allowReserved:n.allowReserved,name:l,value:c});o&&i.push(o)}}return i.join("&")},le=(e,t)=>t?t in e.headers||e.query?.[t]?!0:"Cookie"in e.headers&&e.headers.Cookie&&typeof e.headers.Cookie=="string"?e.headers.Cookie.includes(`${t}=`):!1:!1,pe=async({security:e,...t})=>{for(const r of e){if(le(t,r.name))continue;const s=await ce(r,t.auth);if(!s)continue;const i=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[i]=s;break;case"cookie":{const l=`${i}=${s}`;"Cookie"in t.headers&&t.headers.Cookie?t.headers.Cookie=`${t.headers.Cookie}; ${l}`:t.headers.Cookie=l;break}case"header":default:t.headers[i]=s;break}}},N=e=>{const t=e.axios?.defaults?.baseURL,r=e.baseURL&&typeof e.baseURL=="string"?e.baseURL:t;return ne({baseUrl:r,path:e.path,query:e.paramsSerializer?void 0:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:oe(e.querySerializer),url:e.url})},L=(e,t)=>{const r={...e,...t};return r.headers=x(e.headers,t.headers),r},ue=["common","delete","get","head","patch","post","put"],x=(...e)=>{const t={};for(const r of e){if(!r||typeof r!="object")continue;const s=Object.entries(r);for(const[i,l]of s)if(ue.includes(i)&&typeof l=="object")t[i]={...t[i],...l};else if(l===null)delete t[i];else if(Array.isArray(l))for(const c of l)t[i]=[...t[i]??[],c];else l!==void 0&&(t[i]=typeof l=="object"?JSON.stringify(l):l)}return t},V=(e={})=>({...e}),M=(e={})=>{let t=L(V(),e),r;if(t.axios&&!("Axios"in t.axios))r=t.axios;else{const{auth:d,...a}=t;r=Y.create(a)}const s=()=>({...t}),i=d=>(t=L(t,d),r.defaults={...r.defaults,...t,headers:x(r.defaults.headers,t.headers)},s()),l=async d=>{const a={...t,...d,axios:d.axios??t.axios??r,headers:x(t.headers,d.headers)};a.security&&await pe({...a,security:a.security}),a.requestValidator&&await a.requestValidator(a),a.body!==void 0&&a.bodySerializer&&(a.body=a.bodySerializer(a.body));const h=N(a);return{opts:a,url:h}},c=async d=>{const{opts:a,url:h}=await l(d);try{const m=a.axios,{auth:g,...$}=a,b=await m({...$,baseURL:"",data:ae(a),headers:a.headers,params:a.paramsSerializer?a.query:void 0,url:h});let{data:y}=b;return a.responseType==="json"&&(a.responseValidator&&await a.responseValidator(y),a.responseTransformer&&(y=await a.responseTransformer(y))),{...b,data:y??{}}}catch(m){const g=m;if(a.throwOnError)throw g;return g.error=g.response?.data??{},g}},n=d=>a=>c({...a,method:d}),o=d=>async a=>{const{opts:h,url:m}=await l(a);return Z({...h,body:h.body,headers:h.headers,method:d,signal:h.signal,url:m})};return{buildUrl:N,connect:n("CONNECT"),delete:n("DELETE"),get:n("GET"),getConfig:s,head:n("HEAD"),instance:r,options:n("OPTIONS"),patch:n("PATCH"),post:n("POST"),put:n("PUT"),request:c,setConfig:i,sse:{connect:o("CONNECT"),delete:o("DELETE"),get:o("GET"),head:o("HEAD"),options:o("OPTIONS"),patch:o("PATCH"),post:o("POST"),put:o("PUT"),trace:o("TRACE")},trace:n("TRACE")}},u=M(V()),A=e=>(e=new Date(e),e),F=e=>(e.last_active_at&&(e.last_active_at=A(e.last_active_at)),e.created_at=A(e.created_at),e.updated_at=A(e.updated_at),e),de=async e=>(e.list=e.list.map(t=>F(t)),e),he=async e=>(e=F(e),e),fe=e=>(e.subscribed_at=A(e.subscribed_at),e),ye=async e=>(e.list=e.list.map(t=>fe(t)),e),J=e=>(e.created_at=A(e.created_at),e.updated_at=A(e.updated_at),e),I=e=>(e=J(e),e),be=e=>(e=I(e),e),me=async e=>(e.list=e.list.map(t=>be(t)),e),Te=async e=>(e=I(e),e),ge=async e=>(e=I(e),e),Ae=async e=>(e=I(e),e),w=e=>(e=J(e),e),we=async e=>(e.list=e.list.map(t=>w(t)),e),_e=async e=>(e=w(e),e),Ce=async e=>(e=w(e),e),Se=async e=>(e=w(e),e),je=async e=>(e=w(e),e),ve=async e=>(e.list=e.list.map(t=>w(t)),e),Pe=e=>(e?.client??u).get({responseTransformer:de,responseType:"json",url:"/api/developers",...e}),Re=e=>(e?.client??u).post({responseTransformer:he,responseType:"json",url:"/api/developers",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Ee=e=>(e.client??u).delete({url:"/api/developers/{developer_id}",...e}),Ie=e=>(e?.client??u).get({responseType:"json",url:"/api/api_products",...e}),De=e=>(e.client??u).get({responseType:"json",url:"/api/api_products/{api_product_id}",...e}),xe=e=>(e.client??u).post({url:"/api/api_products/{api_product_id}/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),$e=e=>(e?.client??u).get({responseTransformer:ye,responseType:"json",url:"/api/subscriptions",...e}),ze=e=>(e?.client??u).post({url:"/api/subscriptions",...e,headers:{"Content-Type":"application/json",...e?.headers}}),ke=e=>(e.client??u).delete({url:"/api/subscriptions/{subscription_id}",...e}),Oe=e=>(e?.client??u).get({responseTransformer:me,responseType:"json",url:"/api/applications",...e}),qe=e=>(e?.client??u).post({responseTransformer:Te,responseType:"json",url:"/api/applications",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Ue=e=>(e.client??u).delete({url:"/api/applications/{application_id}",...e}),Be=e=>(e.client??u).get({responseTransformer:ge,responseType:"json",url:"/api/applications/{application_id}",...e}),Ne=e=>(e.client??u).put({responseTransformer:Ae,responseType:"json",url:"/api/applications/{application_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Le=e=>(e.client??u).get({responseTransformer:we,responseType:"json",url:"/api/applications/{application_id}/credentials",...e}),We=e=>(e.client??u).post({responseTransformer:_e,responseType:"json",url:"/api/applications/{application_id}/credentials",...e,headers:{"Content-Type":"application/json",...e.headers}}),He=e=>(e.client??u).delete({url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Ve=e=>(e.client??u).get({responseTransformer:Ce,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Me=e=>(e.client??u).put({responseTransformer:Se,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Fe=e=>(e.client??u).put({responseTransformer:je,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}/regenerate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Je=e=>(e.client??u).get({responseType:"json",url:"/api/applications/api_calls",...e}),Ge=e=>(e?.client??u).get({responseTransformer:ve,responseType:"json",url:"/api/credentials",...e}),Ke=e=>(e.client??u).get({responseType:"json",url:"/api/labels/{resource_type}",...e}),Qe=e=>(e?.client??u).get({responseType:"json",url:"/api/system_settings/public_access",...e}),Xe=e=>(e?.client??u).get({responseType:"json",url:"/api/dcr_providers",...e});class S extends Error{constructor(t,r,s,i,l){super(t),this.message=t,this.status=r,this.method=s,this.url=i,this.stack=void 0,this.#e=l}#e;static fromAxiosError=t=>{const r=t.error&&t.error.error_msg;return new S(`Request failed: ${r||(t.status?`with status code ${t.status}`:t.message)}`,t.status??0,t.config?.method?.toUpperCase()??"",t.config?.url??"",t)};static isAPIError=t=>t instanceof S;rawError(){return this.#e}}const p=e=>{if(e.error||e.status&&e.status>=400)throw S.fromAxiosError(e);return e.data};class Ye{constructor(t){this.client=t}async create(t,r){return p(await We({client:this.client,path:{application_id:t},body:r}))}async list(t,r){return p(await Le({client:this.client,path:{application_id:t},query:r}))}async get(t,r){return p(await Ve({client:this.client,path:{application_id:t,credential_id:r}}))}async update(t,r,s){return p(await Me({client:this.client,path:{application_id:t,credential_id:r},body:s}))}async delete(t,r){return p(await He({client:this.client,path:{application_id:t,credential_id:r}}))}async regenerate(t,r,s){return p(await Fe({client:this.client,path:{application_id:t,credential_id:r},body:s}))}}class Ze{constructor(t){this.client=t}async list(t){return p(await Ge({client:this.client,query:t}))}}class et{constructor(t){this.client=t,this.credential=new Ye(this.client)}credential;async create(t){return p(await qe({client:this.client,body:t}))}async list(t){return p(await Oe({client:this.client,query:t}))}async get(t){return p(await Be({client:this.client,path:{application_id:t}}))}async update(t,r){return p(await Ne({client:this.client,path:{application_id:t},body:r}))}async delete(t){p(await Ue({client:this.client,path:{application_id:t}}))}async apiCall(t){return p(await Je({client:this.client,query:t}))}}class tt{constructor(t){this.client=t}async list(t){return p(await Xe({client:this.client,query:t}))}}class rt{constructor(t){this.client=t}async getPublicAccess(){return p(await Qe({client:this.client})).portal_public_access}}class st{constructor(t){this.client=t}async listLabels(t){return p(await Ke({client:this.client,path:{resource_type:t}}))}}class it{constructor(t){this.client=t}async create(t){return p(await Re({client:this.client,body:t}))}async list(t){return p(await Pe({client:this.client,query:t}))}async delete(t){p(await Ee({client:this.client,path:{developer_id:t}}))}}class nt{constructor(t){this.client=t}async list(t){return p(await Ie({client:this.client,query:t}))}async get(t){return p(await De({client:this.client,path:{api_product_id:t}}))}async subscribe(t,r){p(await xe({client:this.client,path:{api_product_id:t},body:r}))}}class at{constructor(t){this.client=t}async list(t){return p(await $e({client:this.client,query:t}))}async bulkSubscribe(t){p(await ze({client:this.client,body:t}))}async unsubscribe(t){p(await ke({client:this.client,path:{subscription_id:t}}))}}exports.APIError=S;exports.APIProductAPI=nt;exports.ApplicationAPI=et;exports.CredentialAPI=Ze;exports.DCRProviderAPI=tt;exports.DeveloperAPI=it;exports.MiscellaneousAPI=st;exports.SubscriptionAPI=at;exports.SystemSettingAPI=rt;exports.createClient=M;