@api7/portal-sdk 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +1 -1
- package/dist/browser.js +2 -2
- package/dist/credential.d.ts +2 -2
- package/dist/credential.d.ts.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/sdk.gen.d.ts +12 -12
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/transformers.gen.d.ts +6 -7
- package/dist/generated/transformers.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +259 -171
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/subscription-CftzKQlG.cjs +7 -0
- package/dist/{subscription-DPb2gn6N.js → subscription-Dn1fYfR8.js} +185 -186
- package/dist/unstable/typing.d.ts +1 -1
- package/dist/unstable/typing.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/subscription-ukRySaBq.cjs +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type ApiProduct, type CreateApiProductSubscriptionReq, type ListApiProductsData, type ListApiProductsResponses, type CreateDeveloperApplicationReq, type DeveloperApplication, type GetApiCallsData, type GetApiCallsResponses, type ListDeveloperApplicationsData, type ListDeveloperApplicationsResponses, type ApplicationCredential, type CreateApplicationCredentialReq, type ListCredentialsData, type ListCredentialsResponses, type
|
|
1
|
+
export { type ApiProduct, type CreateApiProductSubscriptionReq, type ListApiProductsData, type ListApiProductsResponses, type ListApiProductsErrors, type CreateDeveloperApplicationReq, type DeveloperApplication, type GetApiCallsData, type GetApiCallsResponses, type GetApiCallsErrors, type ListDeveloperApplicationsData, type ListDeveloperApplicationsResponses, type ListDeveloperApplicationsErrors, type ApplicationCredential, type ApplicationCredentialBasics, type CreateApplicationCredentialReq, type UpdateApplicationCredentialReq, type ListCredentialsData, type ListCredentialsResponses, type ListCredentialsErrors, type ListApplicationCredentialsData, type ListApplicationCredentialsResponses, type ListApplicationCredentialsErrors, type RegenerateApplicationCredentialReq, type CreateDeveloperReq, type Developer, type ListDevelopersData, type ListDevelopersResponses, type ListDevelopersErrors, type AllLabels, type DeveloperPortalLabelResourceType, type ListDcrProvidersData, type ListDcrProvidersResponses, type ListDcrProvidersErrors, type CreateSubscriptionReq, type ListSubscriptionsData, type ListSubscriptionsResponses, type ListSubscriptionsErrors, } from '../generated/index.js';
|
|
2
2
|
//# sourceMappingURL=typing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typing.d.ts","sourceRoot":"","sources":["../../src/unstable/typing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,kCAAkC,EACvC,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,
|
|
1
|
+
{"version":3,"file":"typing.d.ts","sourceRoot":"","sources":["../../src/unstable/typing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,6BAA6B,EAClC,KAAK,kCAAkC,EACvC,KAAK,+BAA+B,EACpC,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,mCAAmC,EACxC,KAAK,gCAAgC,EACrC,KAAK,kCAAkC,EACvC,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";const Y=require("axios"),Z=({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:s,responseValidator:n,sseDefaultRetryDelay:l,sseMaxRetryAttempts:c,sseMaxRetryDelay:i,sseSleepFn:o,url:d,...a})=>{let h;const b=o??(m=>new Promise(y=>setTimeout(y,m)));return{stream:async function*(){let m=l??3e3,y=0;const S=a.signal??new AbortController().signal;for(;!S.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 j={redirect:"follow",...a,body:a.serializedBody,headers:z,signal:S};let P=new Request(d,j);e&&(P=await e(d,j));const A=await(a.fetch??globalThis.fetch)(P);if(!A.ok)throw new Error(`SSE failed: ${A.status} ${A.statusText}`);if(!A.body)throw new Error("No body in SSE response");const I=A.body.pipeThrough(new TextDecoderStream).getReader();let v="";const k=()=>{try{I.cancel()}catch{}};S.addEventListener("abort",k);try{for(;;){const{done:G,value:K}=await I.read();if(G)break;v+=K,v=v.replace(/\r\n/g,`
|
|
2
|
-
`).replace(/\r/g,`
|
|
3
|
-
`);const O=v.split(`
|
|
4
|
-
|
|
5
|
-
`);v=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)||(m=B)}let T,U=!1;if(R.length){const f=R.join(`
|
|
7
|
-
`);try{T=JSON.parse(f),U=!0}catch{T=f}}U&&(n&&await n(T),s&&(T=await s(T))),r?.({data:T,event:q,id:h,retry:m}),R.length&&(yield T)}}}finally{S.removeEventListener("abort",k),I.releaseLock()}break}catch(j){if(t?.(j),c!==void 0&&y>=c)break;const P=Math.min(m*2**(y-1),i??3e4);await b(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:n})=>{if(!t){const i=(e?n:n.map(o=>encodeURIComponent(o))).join(te(s));switch(s){case"label":return`.${i}`;case"matrix":return`;${r}=${i}`;case"simple":return i;default:return`${r}=${i}`}}const l=ee(s),c=n.map(i=>s==="label"||s==="simple"?e?i:encodeURIComponent(i):D({allowReserved:e,name:r,value:i})).join(l);return s==="label"||s==="matrix"?l+c:c},D=({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:n,valueOnly:l})=>{if(n instanceof Date)return l?n.toISOString():`${r}=${n.toISOString()}`;if(s!=="deepObject"&&!t){let o=[];Object.entries(n).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),i=Object.entries(n).map(([o,d])=>D({allowReserved:e,name:s==="deepObject"?`${r}[${o}]`:o,value:d})).join(c);return s==="label"||s==="matrix"?c+i:i},se=/\{[^{}]+\}/g,ne=({path:e,url:t})=>{let r=t;const s=t.match(se);if(s)for(const n of s){let l=!1,c=n.substring(1,n.length-1),i="simple";c.endsWith("*")&&(l=!0,c=c.substring(0,c.length-1)),c.startsWith(".")?(c=c.substring(1),i="label"):c.startsWith(";")&&(c=c.substring(1),i="matrix");const o=e[c];if(o==null)continue;if(Array.isArray(o)){r=r.replace(n,W({explode:l,name:c,style:i,value:o}));continue}if(typeof o=="object"){r=r.replace(n,H({explode:l,name:c,style:i,value:o,valueOnly:!0}));continue}if(i==="matrix"){r=r.replace(n,`;${D({name:c,value:o})}`);continue}const d=encodeURIComponent(i==="label"?`.${o}`:o);r=r.replace(n,d)}return r},ie=({baseUrl:e,path:t,query:r,querySerializer:s,url:n})=>{const l=n.startsWith("/")?n:`/${n}`;let c=(e??"")+l;t&&(c=ne({path:t,url:c}));let i=r?s(r):"";return i.startsWith("?")&&(i=i.substring(1)),i&&(c+=`?${i}`),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 n=[];if(s&&typeof s=="object")for(const l in s){const c=s[l];if(c==null)continue;const i=e[l]||t;if(Array.isArray(c)){const o=W({allowReserved:i.allowReserved,explode:!0,name:l,style:"form",value:c,...i.array});o&&n.push(o)}else if(typeof c=="object"){const o=H({allowReserved:i.allowReserved,explode:!0,name:l,style:"deepObject",value:c,...i.object});o&&n.push(o)}else{const o=D({allowReserved:i.allowReserved,name:l,value:c});o&&n.push(o)}}return n.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 n=r.name??"Authorization";switch(r.in){case"query":t.query||(t.query={}),t.query[n]=s;break;case"cookie":{const l=`${n}=${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[n]=s;break}}},N=e=>{const t=e.axios?.defaults?.baseURL,r=e.baseURL&&typeof e.baseURL=="string"?e.baseURL:t;return ie({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[n,l]of s)if(ue.includes(n)&&typeof l=="object")t[n]={...t[n],...l};else if(l===null)delete t[n];else if(Array.isArray(l))for(const c of l)t[n]=[...t[n]??[],c];else l!==void 0&&(t[n]=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}),n=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 b=a.axios,{auth:w,...$}=a,m=await b({...$,baseURL:"",data:ae(a),headers:a.headers,params:a.paramsSerializer?a.query:void 0,url:h});let{data:y}=m;return a.responseType==="json"&&(a.responseValidator&&await a.responseValidator(y),a.responseTransformer&&(y=await a.responseTransformer(y))),{...m,data:y??{}}}catch(b){const w=b;if(a.throwOnError)throw w;return w.error=w.response?.data??{},w}},i=d=>a=>c({...a,method:d}),o=d=>async a=>{const{opts:h,url:b}=await l(a);return Z({...h,body:h.body,headers:h.headers,method:d,signal:h.signal,url:b})};return{buildUrl:N,connect:i("CONNECT"),delete:i("DELETE"),get:i("GET"),getConfig:s,head:i("HEAD"),instance:r,options:i("OPTIONS"),patch:i("PATCH"),post:i("POST"),put:i("PUT"),request:c,setConfig:n,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:i("TRACE")}},u=M(V()),g=e=>(e=new Date(e),e),F=e=>(e.last_active_at&&(e.last_active_at=g(e.last_active_at)),e.created_at=g(e.created_at),e.updated_at=g(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=g(e.subscribed_at),e),ye=async e=>(e.list=e.list.map(t=>fe(t)),e),J=e=>(e.created_at=g(e.created_at),e.updated_at=g(e.updated_at),e),E=e=>(e=J(e),e),me=e=>(e=E(e),e),be=async e=>(e.list=e.list.map(t=>me(t)),e),Te=async e=>(e=E(e),e),ge=async e=>(e=E(e),e),we=async e=>(e=E(e),e),_=e=>(e=J(e),e),_e=async e=>(e.list=e.list.map(t=>_(t)),e),Ae=async e=>(e=_(e),e),ve=async e=>(e=_(e),e),Ce=async e=>(e=_(e),e),Se=async e=>(e=_(e),e),je=e=>(e.hour_timestamp=g(e.hour_timestamp),e),Pe=async e=>(e.list=e.list.map(t=>je(t)),e),Re=async e=>(e.list=e.list.map(t=>_(t)),e),De=e=>(e?.client??u).get({responseTransformer:de,responseType:"json",url:"/api/developers",...e}),Ee=e=>(e?.client??u).post({responseTransformer:he,responseType:"json",url:"/api/developers",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Ie=e=>(e.client??u).delete({url:"/api/developers/{developer_id}",...e}),xe=e=>(e?.client??u).get({responseType:"json",url:"/api/api_products",...e}),$e=e=>(e.client??u).get({responseType:"json",url:"/api/api_products/{api_product_id}",...e}),ze=e=>(e.client??u).post({url:"/api/api_products/{api_product_id}/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),ke=e=>(e?.client??u).get({responseTransformer:ye,responseType:"json",url:"/api/subscriptions",...e}),Oe=e=>(e?.client??u).post({url:"/api/subscriptions",...e,headers:{"Content-Type":"application/json",...e?.headers}}),qe=e=>(e.client??u).delete({url:"/api/subscriptions/{subscription_id}",...e}),Ue=e=>(e?.client??u).get({responseTransformer:be,responseType:"json",url:"/api/applications",...e}),Be=e=>(e?.client??u).post({responseTransformer:Te,responseType:"json",url:"/api/applications",...e,headers:{"Content-Type":"application/json",...e?.headers}}),Ne=e=>(e.client??u).delete({url:"/api/applications/{application_id}",...e}),Le=e=>(e.client??u).get({responseTransformer:ge,responseType:"json",url:"/api/applications/{application_id}",...e}),We=e=>(e.client??u).put({responseTransformer:we,responseType:"json",url:"/api/applications/{application_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),He=e=>(e.client??u).get({responseTransformer:_e,responseType:"json",url:"/api/applications/{application_id}/credentials",...e}),Ve=e=>(e.client??u).post({responseTransformer:Ae,responseType:"json",url:"/api/applications/{application_id}/credentials",...e,headers:{"Content-Type":"application/json",...e.headers}}),Me=e=>(e.client??u).delete({url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Fe=e=>(e.client??u).get({responseTransformer:ve,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e}),Je=e=>(e.client??u).put({responseTransformer:Ce,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ge=e=>(e.client??u).put({responseTransformer:Se,responseType:"json",url:"/api/applications/{application_id}/credentials/{credential_id}/regenerate",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ke=e=>(e.client??u).get({responseTransformer:Pe,responseType:"json",url:"/api/applications/api_calls",...e}),Qe=e=>(e?.client??u).get({responseTransformer:Re,responseType:"json",url:"/api/credentials",...e}),Xe=e=>(e.client??u).get({responseType:"json",url:"/api/labels/{resource_type}",...e}),Ye=e=>(e?.client??u).get({responseType:"json",url:"/api/system_settings/public_access",...e}),Ze=e=>(e?.client??u).get({responseType:"json",url:"/api/dcr_providers",...e});class C extends Error{constructor(t,r,s,n,l){super(t),this.message=t,this.status=r,this.method=s,this.url=n,this.stack=void 0,this.#e=l}#e;static fromAxiosError=t=>{const r=t.error&&t.error.error_msg;return new C(`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 C;rawError(){return this.#e}}const p=e=>{if(e.error||e.status&&e.status>=400)throw C.fromAxiosError(e);return e.data};class et{constructor(t){this.client=t}async create(t,r){return p(await Ve({client:this.client,path:{application_id:t},body:r}))}async list(t,r){return p(await He({client:this.client,path:{application_id:t},query:r}))}async get(t,r){return p(await Fe({client:this.client,path:{application_id:t,credential_id:r}}))}async update(t,r,s){return p(await Je({client:this.client,path:{application_id:t,credential_id:r},body:s}))}async delete(t,r){return p(await Me({client:this.client,path:{application_id:t,credential_id:r}}))}async regenerate(t,r,s){return p(await Ge({client:this.client,path:{application_id:t,credential_id:r},body:s}))}}class tt{constructor(t){this.client=t}async list(t){return p(await Qe({client:this.client,query:t}))}}class rt{constructor(t){this.client=t,this.credential=new et(this.client)}credential;async create(t){return p(await Be({client:this.client,body:t}))}async list(t){return p(await Ue({client:this.client,query:t}))}async get(t){return p(await Le({client:this.client,path:{application_id:t}}))}async update(t,r){return p(await We({client:this.client,path:{application_id:t},body:r}))}async delete(t){p(await Ne({client:this.client,path:{application_id:t}}))}async apiCall(t){return p(await Ke({client:this.client,query:t}))}}class st{constructor(t){this.client=t}async list(t){return p(await Ze({client:this.client,query:t}))}}class nt{constructor(t){this.client=t}async getPublicAccess(){return p(await Ye({client:this.client})).portal_public_access}}class it{constructor(t){this.client=t}async listLabels(t){return p(await Xe({client:this.client,path:{resource_type:t}}))}}class at{constructor(t){this.client=t}async create(t){return p(await Ee({client:this.client,body:t}))}async list(t){return p(await De({client:this.client,query:t}))}async delete(t){p(await Ie({client:this.client,path:{developer_id:t}}))}}class ct{constructor(t){this.client=t}async list(t){return p(await xe({client:this.client,query:t}))}async get(t){return p(await $e({client:this.client,path:{api_product_id:t}}))}async subscribe(t,r){p(await ze({client:this.client,path:{api_product_id:t},body:r}))}}class ot{constructor(t){this.client=t}async list(t){return p(await ke({client:this.client,query:t}))}async bulkSubscribe(t){p(await Oe({client:this.client,body:t}))}async unsubscribe(t){p(await qe({client:this.client,path:{subscription_id:t}}))}}exports.APIError=C;exports.APIProductAPI=ct;exports.ApplicationAPI=rt;exports.CredentialAPI=tt;exports.DCRProviderAPI=st;exports.DeveloperAPI=at;exports.MiscellaneousAPI=it;exports.SubscriptionAPI=ot;exports.SystemSettingAPI=nt;exports.createClient=M;
|