@serkonda7/unifi-api 0.0.0-stage → 0.1.1

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.
Files changed (31) hide show
  1. package/README.md +149 -2
  2. package/dist/generated/client/client.gen.d.ts +2 -0
  3. package/dist/generated/client/index.d.ts +10 -0
  4. package/dist/generated/client/types.gen.d.ts +120 -0
  5. package/dist/generated/client/utils.gen.d.ts +37 -0
  6. package/dist/generated/client.gen.d.ts +12 -0
  7. package/dist/generated/core/auth.gen.d.ts +25 -0
  8. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  9. package/dist/generated/core/params.gen.d.ts +43 -0
  10. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  11. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  12. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  13. package/dist/generated/core/types.gen.d.ts +83 -0
  14. package/dist/generated/core/utils.gen.d.ts +19 -0
  15. package/dist/generated/index.d.ts +2 -0
  16. package/dist/generated/sdk.gen.d.ts +99 -0
  17. package/dist/generated/types.gen.d.ts +2718 -0
  18. package/dist/index.d.ts +6 -0
  19. package/dist/index.js +6 -0
  20. package/dist/shared/client.d.ts +26 -0
  21. package/dist/shared/errors.d.ts +47 -0
  22. package/dist/shared/pagination.d.ts +18 -0
  23. package/dist/site-manager/client.d.ts +32 -0
  24. package/dist/site-manager/index.d.ts +64 -0
  25. package/dist/site-manager/resources/connector.d.ts +107 -0
  26. package/dist/site-manager/resources/devices.d.ts +36 -0
  27. package/dist/site-manager/resources/hosts.d.ts +41 -0
  28. package/dist/site-manager/resources/ispMetrics.d.ts +48 -0
  29. package/dist/site-manager/resources/sdWan.d.ts +27 -0
  30. package/dist/site-manager/resources/sites.d.ts +34 -0
  31. package/package.json +52 -4
@@ -0,0 +1,6 @@
1
+ export * from './generated';
2
+ export { client } from './generated/client.gen';
3
+ export { UnifiApiError } from './shared/errors';
4
+ export type { Page } from './shared/pagination';
5
+ export type { ConnectorMethod, ConnectorRequestOptions, ConnectorResource, CreateUnifiClientOptions, Device, DevicesResource, GetIspMetricsOptions, Host, HostDetails, HostDevices, HostsResource, IspMetrics, IspMetricsDuration, IspMetricsInterval, IspMetricsQueryResult, IspMetricsResource, ListDevicesOptions, ListHostsOptions, ListSitesOptions, QueryIspMetricsSite, SdWanConfig, SdWanConfigStatus, SdWanConfigSummary, SdWanResource, Site, SitesResource, } from './site-manager/index';
6
+ export { createUnifiClient, UnifiClient } from './site-manager/index';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ var U={bodySerializer:(e)=>JSON.stringify(e,(t,r)=>typeof r==="bigint"?r.toString():r)};var qe={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},Ye=Object.entries(qe);function le({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:s,sseDefaultRetryDelay:u,sseMaxRetryAttempts:a,sseMaxRetryDelay:c,sseSleepFn:o,url:l,...p}){let i,f=o??((d)=>new Promise((m)=>setTimeout(m,d)));return{stream:async function*(){let d=u??3000,m=0,C=p.signal??new AbortController().signal;while(!0){if(C.aborted)break;m++;let z=p.headers instanceof Headers?p.headers:new Headers(p.headers);if(i!==void 0)z.set("Last-Event-ID",i);try{let E={redirect:"follow",...p,body:p.serializedBody,headers:z,signal:C},w=new Request(l,E);if(e)w=await e(l,E);let h=await(p.fetch??globalThis.fetch)(w);if(!h.ok)throw Error(`SSE failed: ${h.status} ${h.statusText}`);if(!h.body)throw Error("No body in SSE response");let b=h.body.pipeThrough(new TextDecoderStream).getReader(),S="",ie=()=>{try{b.cancel()}catch{}};C.addEventListener("abort",ie);try{while(!0){let{done:we,value:Ie}=await b.read();if(we)break;S+=Ie,S=S.replace(/\r\n?/g,`
2
+ `);let ae=S.split(`
3
+
4
+ `);S=ae.pop()??"";for(let De of ae){let Pe=De.split(`
5
+ `),M=[],ce;for(let O of Pe)if(O.startsWith("data:"))M.push(O.replace(/^data:\s*/,""));else if(O.startsWith("event:"))ce=O.replace(/^event:\s*/,"");else if(O.startsWith("id:"))i=O.replace(/^id:\s*/,"");else if(O.startsWith("retry:")){let ue=Number.parseInt(O.replace(/^retry:\s*/,""),10);if(!Number.isNaN(ue))d=ue}let I,pe=!1;if(M.length){let O=M.join(`
6
+ `);try{I=JSON.parse(O),pe=!0}catch{I=O}}if(pe){if(s)await s(I);if(n)I=await n(I)}if(r?.({data:I,event:ce,id:i,retry:d}),M.length)yield I}}}finally{C.removeEventListener("abort",ie),b.releaseLock()}break}catch(E){if(t?.(E),a!==void 0&&m>=a)break;let w=Math.min(d*2**(m-1),c??30000);await f(w)}}}()}}var ke=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},Ae=(e)=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},ze=(e)=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},v=({allowReserved:e,explode:t,name:r,style:n,value:s})=>{if(!t){let c=(e?s:s.map((o)=>encodeURIComponent(o))).join(Ae(n));switch(n){case"label":return`.${c}`;case"matrix":return`;${r}=${c}`;case"simple":return c;default:return`${r}=${c}`}}let u=ke(n),a=s.map((c)=>{if(n==="label"||n==="simple")return e?c:encodeURIComponent(c);return D({allowReserved:e,name:r,value:c})}).join(u);return n==="label"||n==="matrix"?u+a:a},D=({allowReserved:e,name:t,value:r})=>{if(r===void 0||r===null)return"";if(typeof r==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?r:encodeURIComponent(r)}`},W=({allowReserved:e,explode:t,name:r,style:n,value:s,valueOnly:u})=>{if(s instanceof Date)return u?s.toISOString():`${r}=${s.toISOString()}`;if(n!=="deepObject"&&!t){let o=[];Object.entries(s).forEach(([p,i])=>{o=[...o,p,e?i:encodeURIComponent(i)]});let l=o.join(",");switch(n){case"form":return`${r}=${l}`;case"label":return`.${l}`;case"matrix":return`;${r}=${l}`;default:return l}}let a=ze(n),c=Object.entries(s).map(([o,l])=>D({allowReserved:e,name:n==="deepObject"?`${r}[${o}]`:o,value:l})).join(a);return n==="label"||n==="matrix"?a+c:c};var Me=/\{[^{}]+\}/g,ve=({path:e,url:t})=>{let r=t,n=t.match(Me);if(n)for(let s of n){let u=!1,a=s.substring(1,s.length-1),c="simple";if(a.endsWith("*"))u=!0,a=a.substring(0,a.length-1);if(a.startsWith("."))a=a.substring(1),c="label";else if(a.startsWith(";"))a=a.substring(1),c="matrix";let o=e[a];if(o===void 0||o===null)continue;if(Array.isArray(o)){r=r.replace(s,v({explode:u,name:a,style:c,value:o}));continue}if(typeof o==="object"){r=r.replace(s,W({explode:u,name:a,style:c,value:o,valueOnly:!0}));continue}if(c==="matrix"){r=r.replace(s,`;${D({name:a,value:o})}`);continue}let l=encodeURIComponent(c==="label"?`.${o}`:o);r=r.replace(s,l)}return r},de=({baseUrl:e,path:t,query:r,querySerializer:n,url:s})=>{let u=s.startsWith("/")?s:`/${s}`,a=(e??"")+u;if(t)a=ve({path:t,url:a});let c=r?n(r):"";if(c.startsWith("?"))c=c.substring(1);if(c)a+=`?${c}`;return a};function N(e){let t=e.body!==void 0;if(t&&e.bodySerializer){if("serializedBody"in e)return e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null;return e.body!==""?e.body:null}if(t)return e.body;return}var fe=async(e,t)=>{let r=typeof t==="function"?await t(e):t;if(!r)return;if(e.scheme==="bearer")return`Bearer ${r}`;if(e.scheme==="basic")return`Basic ${btoa(r)}`;return r};var ye=({parameters:e={},...t}={})=>(n)=>{let s=[];if(n&&typeof n==="object")for(let u in n){let a=n[u];if(a===void 0||a===null)continue;let c=e[u]||t;if(Array.isArray(a)){let o=v({allowReserved:c.allowReserved,explode:!0,name:u,style:"form",value:a,...c.array});if(o)s.push(o)}else if(typeof a==="object"){let o=W({allowReserved:c.allowReserved,explode:!0,name:u,style:"deepObject",value:a,...c.object});if(o)s.push(o)}else{let o=D({allowReserved:c.allowReserved,name:u,value:a});if(o)s.push(o)}}return s.join("&")},ge=(e)=>{if(!e)return"stream";let t=e.split(";")[0]?.trim();if(!t)return;if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((r)=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text";return},We=(e,t)=>{if(!t)return!1;if(e.headers.has(t)||e.query?.[t]||e.headers.get("Cookie")?.includes(`${t}=`))return!0;return!1};async function me(e){for(let t of e.security??[]){if(We(e,t.name))continue;let r=await fe(t,e.auth);if(!r)continue;let n=t.name??"Authorization";switch(t.in){case"query":if(!e.query)e.query={};e.query[n]=r;break;case"cookie":e.headers.append("Cookie",`${n}=${r}`);break;case"header":default:e.headers.set(n,r);break}}}var K=(e)=>de({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==="function"?e.querySerializer:ye(e.querySerializer),url:e.url}),Q=(e,t)=>{let r={...e,...t};if(r.baseUrl?.endsWith("/"))r.baseUrl=r.baseUrl.substring(0,r.baseUrl.length-1);return r.headers=H(e.headers,t.headers),r},Le=(e)=>{let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t},H=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?Le(r):Object.entries(r);for(let[s,u]of n)if(u===null)t.delete(s);else if(Array.isArray(u))for(let a of u)t.append(s,a);else if(u!==void 0)t.set(s,typeof u==="object"?JSON.stringify(u):u)}return t};class L{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);if(this.fns[t])this.fns[t]=null}exists(e){let t=this.getInterceptorIndex(e);return Boolean(this.fns[t])}getInterceptorIndex(e){if(typeof e==="number")return this.fns[e]?e:-1;return this.fns.indexOf(e)}update(e,t){let r=this.getInterceptorIndex(e);if(this.fns[r])return this.fns[r]=t,e;return!1}use(e){return this.fns.push(e),this.fns.length-1}}var he=()=>({error:new L,request:new L,response:new L}),He=ye({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Ge={"Content-Type":"application/json"},k=(e={})=>({...U,headers:Ge,parseAs:"auto",querySerializer:He,...e});var A=(e={})=>{let t=Q(k(),e),r=()=>({...t}),n=(p)=>(t=Q(t,p),r()),s=he(),u=async(p)=>{let i={...t,...p,fetch:p.fetch??t.fetch??globalThis.fetch,headers:H(t.headers,p.headers),serializedBody:void 0};if(i.security)await me(i);if(i.requestValidator)await i.requestValidator(i);if(i.body!==void 0&&i.bodySerializer)i.serializedBody=i.bodySerializer(i.body);if(i.body===void 0||i.serializedBody==="")i.headers.delete("Content-Type");let f=i,y=K(f);return{opts:f,url:y}},a=async(p)=>{let i=p.throwOnError??t.throwOnError,f=p.responseStyle??t.responseStyle,y,g;try{let{opts:d,url:m}=await u(p),C={redirect:"follow",...d,body:N(d)};y=new Request(m,C);for(let h of s.request.fns)if(h)y=await h(y,d);let z=d.fetch;g=await z(y);for(let h of s.response.fns)if(h)g=await h(g,y,d);let E={request:y,response:g};if(g.ok){let h=(d.parseAs==="auto"?ge(g.headers.get("Content-Type")):d.parseAs)??"json";if(g.status===204||g.headers.get("Content-Length")==="0"){let S;switch(h){case"arrayBuffer":case"blob":case"text":S=await g[h]();break;case"formData":S=new FormData;break;case"stream":S=g.body;break;case"json":default:S={};break}return d.responseStyle==="data"?S:{data:S,...E}}let b;switch(h){case"arrayBuffer":case"blob":case"formData":case"text":b=await g[h]();break;case"json":{let S=await g.text();b=S?JSON.parse(S):{};break}case"stream":return d.responseStyle==="data"?g.body:{data:g.body,...E}}if(h==="json"){if(d.responseValidator)await d.responseValidator(b);if(d.responseTransformer)b=await d.responseTransformer(b)}return d.responseStyle==="data"?b:{data:b,...E}}let w=await g.text(),B;try{B=JSON.parse(w)}catch{}throw B??w}catch(d){let m=d;for(let C of s.error.fns)if(C)m=await C(m,g,y,p);if(m=m||{},i)throw m;return f==="data"?void 0:{error:m,request:y,response:g}}},c=(p)=>(i)=>a({...i,method:p}),o=(p)=>async(i)=>{let{opts:f,url:y}=await u(i);return le({...f,body:f.body,method:p,onRequest:async(g,d)=>{let m=new Request(g,d);for(let C of s.request.fns)if(C)m=await C(m,f);return m},serializedBody:N(f),url:y})};return{buildUrl:(p)=>K({...t,...p}),connect:c("CONNECT"),delete:c("DELETE"),get:c("GET"),getConfig:r,head:c("HEAD"),interceptors:s,options:c("OPTIONS"),patch:c("PATCH"),post:c("POST"),put:c("PUT"),request:a,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:c("TRACE")}};var R=A(k({baseUrl:"https://api.ui.com"}));var je=(e)=>(e.client??R).delete({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/connector/consoles/{id}/*path",...e}),Be=(e)=>(e.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/connector/consoles/{id}/*path",...e}),Ue=(e)=>(e.client??R).patch({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/connector/consoles/{id}/*path",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ne=(e)=>(e.client??R).post({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/connector/consoles/{id}/*path",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ke=(e)=>(e.client??R).put({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/connector/consoles/{id}/*path",...e,headers:{"Content-Type":"application/json",...e.headers}}),V=(e)=>(e?.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/devices",...e}),F=(e)=>(e?.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/hosts",...e}),J=(e)=>(e.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/hosts/{id}",...e}),X=(e)=>(e.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/isp-metrics/{type}",...e}),_=(e)=>(e.client??R).post({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/isp-metrics/{type}/query",...e,headers:{"Content-Type":"application/json",...e.headers}}),Y=(e)=>(e?.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/sd-wan-configs",...e}),Z=(e)=>(e.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/sd-wan-configs/{id}",...e}),ee=(e)=>(e.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/sd-wan-configs/{id}/status",...e}),te=(e)=>(e?.client??R).get({security:[{name:"X-API-Key",type:"apiKey"}],url:"/v1/sites",...e});function re(e,t){if(typeof e==="object"&&e!==null&&t in e)return e[t];return}function $e(e,t,r){if(t===void 0)return`${e} failed`;let n=re(r,"message");return typeof n==="string"?`${e} failed with status ${t}: ${n}`:`${e} failed with status ${t}`}class G extends Error{status;body;request;response;code;traceId;retryAfter;constructor(e,t){super($e(e,t.status,t.body));this.name="UnifiApiError",this.status=t.status,this.body=t.body,this.request=t.request,this.response=t.response;let r=re(t.body,"code");if(r!==void 0)this.code=String(r);let n=re(t.body,"traceId");if(typeof n==="string")this.traceId=n;let s=t.response?.headers.get("Retry-After");if(s!==null&&s!==void 0){let u=Number(s);if(!Number.isNaN(u))this.retryAfter=u}}}function T(e,t){if(e.error!==void 0){let r=e.response?.status;throw new G(t,{status:r,body:e.error,request:e.request,response:e.response})}return e.data}function x(e,t){return T(e,t).data}var Qe="https://api.ui.com";function Re(e){let{apiKey:t,baseUrl:r=Qe,fetch:n,config:s}=e;return A({...s,baseUrl:r,auth:t,...n!==void 0?{fetch:n}:{}})}function Se(e,t){e.setConfig({auth:t})}function ne(e){return Re(e)}function se(e,t){Se(e,t)}function Ve(e,t){let r=e.replace(/\/+$/,""),n=t.replace(/^\/+/,"");if(r==="")return n;return n===""?r:`${r}/${n}`}async function Fe(e,t,r,n,s={}){let u=`/v1/connector/consoles/${encodeURIComponent(r)}/${n.replace(/^\/+/,"")}`,a={...s.headers};if(s.body!==void 0&&!Object.keys(a).some((c)=>c.toLowerCase()==="content-type"))a["Content-Type"]="application/json";return T(await e.request({method:t,url:u,query:s.query,body:s.body,headers:a,security:[{name:"X-API-Key",type:"apiKey"}]}),`connector.${t.toLowerCase()}`)}function Ce(e){function t(o,l,p,i){return Fe(e,o,l,p,i)}function r(o,l,p){return t("GET",o,l,p)}function n(o,l,p,i){return t("POST",o,l,p===void 0?i:{...i,body:p})}function s(o,l,p,i){return t("PUT",o,l,p===void 0?i:{...i,body:p})}function u(o,l,p,i){return t("PATCH",o,l,p===void 0?i:{...i,body:p})}function a(o,l,p){return t("DELETE",o,l,p)}function c(o,l=""){let p=(i)=>Ve(l,i);return{request(i,f,y){return t(i,o,p(f),y)},get(i,f){return r(o,p(i),f)},post(i,f,y){return n(o,p(i),f,y)},put(i,f,y){return s(o,p(i),f,y)},patch(i,f,y){return u(o,p(i),f,y)},delete(i,f){return a(o,p(i),f)}}}return{request:t,get:r,post:n,put:s,patch:u,delete:a,forConsole:c,network(o){return c(o,"network/integration")},protect(o){return c(o,"protect/integration")}}}async function*P(e){let t;while(!0){let r=await e(t);for(let s of r.data)yield s;let n=r.nextToken;if(n===void 0||n===""||n===t)return;t=n}}async function q(e){let t=[];for await(let r of e)t.push(r);return t}function be(e){async function t(n={}){let s=T(await V({query:{...n.hostIds!==void 0?{"hostIds[]":n.hostIds}:{},...n.time!==void 0?{time:n.time instanceof Date?n.time.toISOString():n.time}:{},...n.pageSize!==void 0?{pageSize:String(n.pageSize)}:{},...n.nextToken!==void 0?{nextToken:n.nextToken}:{}},client:e}),"devices.list");return{data:(s.data??[]).filter((u)=>u!==null),nextToken:s.nextToken||void 0}}function r(n={}){return P(async(s)=>t({...n,nextToken:s}))}return{list:t,iterate:r,async listAll(n={}){return q(r(n))}}}function Oe(e){async function t(n={}){let s=T(await F({query:{...n.pageSize!==void 0?{pageSize:String(n.pageSize)}:{},...n.nextToken!==void 0?{nextToken:n.nextToken}:{}},client:e}),"hosts.list");return{data:(s.data??[]).filter((u)=>u!==null),nextToken:s.nextToken||void 0}}function r(n={}){return P(async(s)=>t({...n,nextToken:s}))}return{list:t,iterate:r,async listAll(n={}){return q(r(n))},async get(n){return x(await J({path:{id:n},client:e}),"hosts.get")}}}function j(e){return e instanceof Date?e.toISOString():e}function Je(e){if("duration"in e)return{duration:e.duration};return{...e.beginTimestamp!==void 0?{beginTimestamp:j(e.beginTimestamp)}:{},...e.endTimestamp!==void 0?{endTimestamp:j(e.endTimestamp)}:{}}}function Te(e){return{async get(t,r){return x(await X({path:{type:t},query:r===void 0?void 0:Je(r),client:e}),"ispMetrics.get")},async query(t,r){return x(await _({path:{type:t},body:{sites:r.map(({hostId:n,siteId:s,beginTimestamp:u,endTimestamp:a})=>({hostId:n,siteId:s,...u!==void 0?{beginTimestamp:j(u)}:{},...a!==void 0?{endTimestamp:j(a)}:{}}))},client:e}),"ispMetrics.query")}}}function xe(e){return{async list(){return x(await Y({client:e}),"sdWan.list")},async get(t){return x(await Z({path:{id:t},client:e}),"sdWan.get")},async status(t){return x(await ee({path:{id:t},client:e}),"sdWan.status")}}}function Ee(e){async function t(n={}){let s=T(await te({query:{...n.pageSize!==void 0?{pageSize:String(n.pageSize)}:{},...n.nextToken!==void 0?{nextToken:n.nextToken}:{}},client:e}),"sites.list");return{data:(s.data??[]).filter((u)=>u!==null),nextToken:s.nextToken||void 0}}function r(n={}){return P(async(s)=>t({...n,nextToken:s}))}return{list:t,iterate:r,async listAll(n={}){return q(r(n))}}}class oe{hosts;sites;devices;ispMetrics;sdWan;connector;instance;constructor(e){this.instance=e,this.hosts=Oe(e),this.sites=Ee(e),this.devices=be(e),this.ispMetrics=Te(e),this.sdWan=xe(e),this.connector=Ce(e)}setApiKey(e){se(this.instance,e)}}function Xe(e){return new oe(ne(e))}export{G as UnifiApiError,oe as UnifiClient,R as client,je as connectorDelete,Be as connectorGet,Ue as connectorPatch,Ne as connectorPost,Ke as connectorPut,Xe as createUnifiClient,J as getHostById,X as getIspMetrics,Z as getSdWanConfigById,ee as getSdWanConfigStatus,V as listDevices,F as listHosts,Y as listSdWanConfigs,te as listSites,_ as queryIspMetrics};
@@ -0,0 +1,26 @@
1
+ import type { Client, Config } from '../generated/client/types.gen';
2
+ /** Base URL of the UniFi Site Manager API. */
3
+ export declare const DEFAULT_BASE_URL = "https://api.ui.com";
4
+ /** Options used to build an isolated hey-api client instance. */
5
+ export interface ClientInstanceOptions {
6
+ /** API key sent in the `X-API-Key` header. */
7
+ apiKey: string;
8
+ /** Override the API base URL. Defaults to {@link DEFAULT_BASE_URL}. */
9
+ baseUrl?: string;
10
+ /** Custom fetch implementation. Defaults to `globalThis.fetch`. */
11
+ fetch?: typeof fetch;
12
+ /** Extra hey-api client config merged over the defaults. */
13
+ config?: Omit<Config, 'baseUrl' | 'auth' | 'fetch'>;
14
+ }
15
+ /**
16
+ * Create an isolated hey-api client instance.
17
+ *
18
+ * Unlike the generated `client` singleton, the returned instance is not
19
+ * shared with other API areas, so `setConfig` calls elsewhere cannot leak an
20
+ * API key into its requests (or vice versa).
21
+ */
22
+ export declare function createClientInstance(options: ClientInstanceOptions): Client;
23
+ /**
24
+ * Update the API key of a client instance (e.g. after rotation).
25
+ */
26
+ export declare function setClientApiKey(client: Client, apiKey: string): void;
@@ -0,0 +1,47 @@
1
+ /** Context captured when an API response turns out to be an error. */
2
+ export interface UnifiApiErrorDetails {
3
+ status?: number;
4
+ body: unknown;
5
+ request?: Request;
6
+ response?: Response;
7
+ }
8
+ /**
9
+ * Error thrown by the client facades (`UnifiClient` and its resources) when
10
+ * the Site Manager API answers with a non-2xx status.
11
+ *
12
+ * The generated SDK returns `{ data } | { error }` unions; the facades turn
13
+ * the error branch into this exception so callers can use plain `try/catch`
14
+ * instead of checking every response. `code`, `traceId` and `retryAfter` are
15
+ * lifted out of the standardized UniFi error body / response headers for
16
+ * convenient access.
17
+ */
18
+ export declare class UnifiApiError extends Error {
19
+ readonly status?: number;
20
+ readonly body: unknown;
21
+ readonly request?: Request;
22
+ readonly response?: Response;
23
+ readonly code?: string;
24
+ readonly traceId?: string;
25
+ readonly retryAfter?: number;
26
+ constructor(context: string, details: UnifiApiErrorDetails);
27
+ }
28
+ type ApiResult<TData, TError> = {
29
+ data: TData | undefined;
30
+ error: TError | undefined;
31
+ request?: Request;
32
+ response?: Response;
33
+ };
34
+ /**
35
+ * Unwrap a generated-SDK result: return `data` on success, throw an
36
+ * `UnifiApiError` (with HTTP status when available) otherwise.
37
+ */
38
+ export declare function ensureData<TData, TError>(result: ApiResult<TData, TError>, context: string): TData;
39
+ /**
40
+ * Unwrap a Site Manager envelope and return its `data` field (the part that
41
+ * actually carries the endpoint payload). Throws an `UnifiApiError` on a
42
+ * non-2xx response, just like {@link ensureData}.
43
+ */
44
+ export declare function ensureEnvelopeData<TData extends {
45
+ data?: unknown;
46
+ }, TError>(result: ApiResult<TData, TError>, context: string): NonNullable<TData['data']>;
47
+ export {};
@@ -0,0 +1,18 @@
1
+ /** One page of a token-paginated Site Manager endpoint. */
2
+ export interface Page<T> {
3
+ /** Items contained in this page. */
4
+ data: T[];
5
+ /** Token to pass to the next request, if more results are available. */
6
+ nextToken?: string;
7
+ }
8
+ /**
9
+ * Yield every item of a token-paginated endpoint, following `nextToken`
10
+ * until the server stops returning one.
11
+ *
12
+ * An empty token, a missing token, or a token identical to the one just sent
13
+ * ends the iteration; the last case guards against servers that echo the
14
+ * token back forever and would otherwise cause an infinite loop.
15
+ */
16
+ export declare function paginate<T>(fetchPage: (nextToken: string | undefined) => Promise<Page<T>>): AsyncGenerator<T, void, undefined>;
17
+ /** Collect an async iterable (for example {@link paginate}) into an array. */
18
+ export declare function collect<T>(iterable: AsyncIterable<T>): Promise<T[]>;
@@ -0,0 +1,32 @@
1
+ import type { Client, Config } from '../generated/client/types.gen';
2
+ /** Options for creating a UniFi Site Manager client. */
3
+ export interface CreateUnifiClientOptions {
4
+ /**
5
+ * API key created in unifi.ui.com under **API** and sent in the
6
+ * `X-API-Key` header.
7
+ *
8
+ * An organization key can access every console in the organization;
9
+ * a personal key can only access consoles owned by the key's account.
10
+ */
11
+ apiKey: string;
12
+ /**
13
+ * Override the API base URL. Defaults to `https://api.ui.com`.
14
+ */
15
+ baseUrl?: string;
16
+ /**
17
+ * Custom fetch implementation. Defaults to `globalThis.fetch`.
18
+ */
19
+ fetch?: typeof fetch;
20
+ /**
21
+ * Extra hey-api client config merged over the defaults.
22
+ */
23
+ config?: Omit<Config, 'baseUrl' | 'auth' | 'fetch'>;
24
+ }
25
+ /**
26
+ * Create an isolated hey-api client pre-configured for the Site Manager API.
27
+ */
28
+ export declare function createUnifiClientInstance(options: CreateUnifiClientOptions): Client;
29
+ /**
30
+ * Update the API key of a Site Manager client instance (e.g. after rotation).
31
+ */
32
+ export declare function setUnifiClientApiKey(client: Client, apiKey: string): void;
@@ -0,0 +1,64 @@
1
+ import type { Client } from '../generated/client/types.gen';
2
+ import { type CreateUnifiClientOptions } from './client';
3
+ import { type ConnectorResource } from './resources/connector';
4
+ import { type DevicesResource } from './resources/devices';
5
+ import { type HostsResource } from './resources/hosts';
6
+ import { type IspMetricsResource } from './resources/ispMetrics';
7
+ import { type SdWanResource } from './resources/sdWan';
8
+ import { type SitesResource } from './resources/sites';
9
+ export { UnifiApiError } from '../shared/errors';
10
+ export type { CreateUnifiClientOptions } from './client';
11
+ export { createUnifiClientInstance, setUnifiClientApiKey } from './client';
12
+ export type { ConnectorMethod, ConnectorRequestOptions, ConnectorResource, } from './resources/connector';
13
+ export type { Device, DevicesResource, HostDevices, ListDevicesOptions, } from './resources/devices';
14
+ export type { Host, HostDetails, HostsResource, ListHostsOptions } from './resources/hosts';
15
+ export type { GetIspMetricsOptions, IspMetrics, IspMetricsDuration, IspMetricsInterval, IspMetricsQueryResult, IspMetricsResource, QueryIspMetricsSite, } from './resources/ispMetrics';
16
+ export type { SdWanConfig, SdWanConfigStatus, SdWanConfigSummary, SdWanResource, } from './resources/sdWan';
17
+ export type { ListSitesOptions, Site, SitesResource } from './resources/sites';
18
+ /**
19
+ * Namespaced facade over the UniFi Site Manager API (`https://api.ui.com`).
20
+ *
21
+ * Obtain an instance via `createUnifiClient({ apiKey })`. All resource methods
22
+ * return the payload from the response envelope directly and throw a
23
+ * `UnifiApiError` on non-2xx responses — no `{ data, error }` union handling
24
+ * required. The connector resource is the exception: it returns the raw
25
+ * upstream response of the proxied UniFi application.
26
+ *
27
+ * ```ts
28
+ * import { createUnifiClient } from '@serkonda7/unifi-api'
29
+ *
30
+ * const unifi = createUnifiClient({ apiKey: process.env.UNIFI_API_KEY! })
31
+ *
32
+ * const hosts = await unifi.hosts.listAll()
33
+ * const sites = await unifi.sites.list()
34
+ * const networkSites = await unifi.connector.network(hosts[0].id!).get('/v1/sites')
35
+ * ```
36
+ */
37
+ export declare class UnifiClient {
38
+ /** Hosts (consoles and network servers) registered with the account. */
39
+ readonly hosts: HostsResource;
40
+ /** Sites managed by those hosts. */
41
+ readonly sites: SitesResource;
42
+ /** Devices grouped per host. */
43
+ readonly devices: DevicesResource;
44
+ /** ISP/WAN metrics. */
45
+ readonly ispMetrics: IspMetricsResource;
46
+ /** SD-WAN configurations and their status. */
47
+ readonly sdWan: SdWanResource;
48
+ /** Proxy to Network/Protect/InnerSpace APIs running on a console. */
49
+ readonly connector: ConnectorResource;
50
+ /**
51
+ * The underlying isolated hey-api client. Useful for interceptors or for
52
+ * escaping to raw generated SDK functions via `{ client }`.
53
+ */
54
+ readonly instance: Client;
55
+ constructor(client: Client);
56
+ /**
57
+ * Update the API key (e.g. after rotation) without rebuilding the client.
58
+ */
59
+ setApiKey(apiKey: string): void;
60
+ }
61
+ /**
62
+ * Create a {@link UnifiClient} with its own isolated hey-api instance.
63
+ */
64
+ export declare function createUnifiClient(options: CreateUnifiClientOptions): UnifiClient;
@@ -0,0 +1,107 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ /** HTTP methods supported by the connector proxy. */
3
+ export type ConnectorMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4
+ /** Per-request options for a connector call. */
5
+ export interface ConnectorRequestOptions {
6
+ /** Query parameters appended to the upstream path. */
7
+ query?: Record<string, unknown>;
8
+ /** Request body; objects are JSON-serialized by the client. */
9
+ body?: unknown;
10
+ /** Extra headers; `Content-Type` defaults to `application/json` with a body. */
11
+ headers?: Record<string, string>;
12
+ }
13
+ /**
14
+ * Proxy arbitrary HTTP requests to Network, Protect or InnerSpace APIs on a
15
+ * console. The upstream response is passed through as-is: it is NOT wrapped
16
+ * in a Site Manager envelope.
17
+ *
18
+ * The generated connector helpers cannot be used because their URL is the
19
+ * literal `/v1/connector/consoles/{id}/*path` and they do not allow query
20
+ * parameters, so this resource calls `client.request()` directly.
21
+ *
22
+ * Requirements and limits of the upstream proxy:
23
+ * - Console firmware must be >= 5.0.3.
24
+ * - 100 requests per minute per console.
25
+ * - 25 second timeout for each proxied request.
26
+ * - 10 MB maximum response body.
27
+ *
28
+ * API documentation: https://developer.ui.com/network and
29
+ * https://developer.ui.com/protect.
30
+ *
31
+ * ```ts
32
+ * await unifi.connector.network(hostId).get('/v1/sites')
33
+ * // GET /v1/connector/consoles/{hostId}/network/integration/v1/sites
34
+ * ```
35
+ */
36
+ export declare function createConnectorResource(client: Client): {
37
+ /** Send an arbitrary HTTP method through the connector proxy. */
38
+ request: <T>(method: ConnectorMethod, consoleId: string, path: string, options?: ConnectorRequestOptions) => Promise<T>;
39
+ /** GET an arbitrary upstream path on a console. */
40
+ get: <T>(consoleId: string, path: string, options?: ConnectorRequestOptions) => Promise<T>;
41
+ /** POST a JSON body to an arbitrary upstream path on a console. */
42
+ post: <T>(consoleId: string, path: string, body?: unknown, options?: ConnectorRequestOptions) => Promise<T>;
43
+ /** PUT a JSON body to an arbitrary upstream path on a console. */
44
+ put: <T>(consoleId: string, path: string, body?: unknown, options?: ConnectorRequestOptions) => Promise<T>;
45
+ /** PATCH a JSON body on an arbitrary upstream path on a console. */
46
+ patch: <T>(consoleId: string, path: string, body?: unknown, options?: ConnectorRequestOptions) => Promise<T>;
47
+ /** DELETE an arbitrary upstream path on a console. */
48
+ delete: <T>(consoleId: string, path: string, options?: ConnectorRequestOptions) => Promise<T>;
49
+ /**
50
+ * Bind all connector methods to one console and prepend `prefix` to
51
+ * every path (joined with a single `/`).
52
+ */
53
+ forConsole: (consoleId: string, prefix?: string) => {
54
+ /** Send an arbitrary method to this console under `prefix`. */
55
+ request<T>(method: ConnectorMethod, path: string, options?: ConnectorRequestOptions): Promise<T>;
56
+ /** GET a path on this console under `prefix`. */
57
+ get<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
58
+ /** POST a body to a path on this console under `prefix`. */
59
+ post<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
60
+ /** PUT a body to a path on this console under `prefix`. */
61
+ put<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
62
+ /** PATCH a body on this console under `prefix`. */
63
+ patch<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
64
+ /** DELETE a path on this console under `prefix`. */
65
+ delete<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
66
+ };
67
+ /**
68
+ * Connector scoped to the Network integration API of a console.
69
+ *
70
+ * ```ts
71
+ * await unifi.connector.network(hostId).get('/v1/sites')
72
+ * // GET /v1/connector/consoles/{hostId}/network/integration/v1/sites
73
+ * ```
74
+ */
75
+ network(consoleId: string): {
76
+ /** Send an arbitrary method to this console under `prefix`. */
77
+ request<T>(method: ConnectorMethod, path: string, options?: ConnectorRequestOptions): Promise<T>;
78
+ /** GET a path on this console under `prefix`. */
79
+ get<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
80
+ /** POST a body to a path on this console under `prefix`. */
81
+ post<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
82
+ /** PUT a body to a path on this console under `prefix`. */
83
+ put<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
84
+ /** PATCH a body on this console under `prefix`. */
85
+ patch<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
86
+ /** DELETE a path on this console under `prefix`. */
87
+ delete<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
88
+ };
89
+ /**
90
+ * Connector scoped to the Protect integration API of a console.
91
+ */
92
+ protect(consoleId: string): {
93
+ /** Send an arbitrary method to this console under `prefix`. */
94
+ request<T>(method: ConnectorMethod, path: string, options?: ConnectorRequestOptions): Promise<T>;
95
+ /** GET a path on this console under `prefix`. */
96
+ get<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
97
+ /** POST a body to a path on this console under `prefix`. */
98
+ post<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
99
+ /** PUT a body to a path on this console under `prefix`. */
100
+ put<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
101
+ /** PATCH a body on this console under `prefix`. */
102
+ patch<T>(path: string, body?: unknown, options?: ConnectorRequestOptions): Promise<T>;
103
+ /** DELETE a path on this console under `prefix`. */
104
+ delete<T>(path: string, options?: ConnectorRequestOptions): Promise<T>;
105
+ };
106
+ };
107
+ export type ConnectorResource = ReturnType<typeof createConnectorResource>;
@@ -0,0 +1,36 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ import type { ListDevicesResponse } from '../../generated/types.gen';
3
+ import { type Page } from '../../shared/pagination';
4
+ /** Devices grouped per host in a `GET /v1/devices` response. */
5
+ export type HostDevices = NonNullable<NonNullable<ListDevicesResponse['data']>[number]>;
6
+ /** A single UniFi device managed by a host. */
7
+ export type Device = NonNullable<NonNullable<HostDevices['devices']>[number]>;
8
+ /** Options accepted by {@link DevicesResource.list}. */
9
+ export interface ListDevicesOptions {
10
+ /** Restrict the result to these host IDs. */
11
+ hostIds?: string[];
12
+ /** Last processed device timestamp; `Date` values are sent as ISO strings. */
13
+ time?: string | Date;
14
+ /** Number of items to return per page. */
15
+ pageSize?: number;
16
+ /** Token of the page to fetch. */
17
+ nextToken?: string;
18
+ }
19
+ /**
20
+ * Devices managed by the hosts visible to the API key, grouped per host.
21
+ */
22
+ export declare function createDevicesResource(client: Client): {
23
+ /**
24
+ * Fetch one page of per-host device groups. Pass `nextToken` to continue.
25
+ */
26
+ list: (options?: ListDevicesOptions) => Promise<Page<HostDevices>>;
27
+ /**
28
+ * Lazily yield per-host device groups across all pages.
29
+ */
30
+ iterate: (options?: Omit<ListDevicesOptions, 'nextToken'>) => AsyncGenerator<HostDevices>;
31
+ /**
32
+ * Fetch every per-host device group by following all pagination tokens.
33
+ */
34
+ listAll(options?: Omit<ListDevicesOptions, 'nextToken'>): Promise<HostDevices[]>;
35
+ };
36
+ export type DevicesResource = ReturnType<typeof createDevicesResource>;
@@ -0,0 +1,41 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ import type { GetHostByIdResponse, ListHostsResponse } from '../../generated/types.gen';
3
+ import { type Page } from '../../shared/pagination';
4
+ /** A host (console or network server) as returned by the Site Manager. */
5
+ export type Host = NonNullable<NonNullable<ListHostsResponse['data']>[number]>;
6
+ /** Detailed information about a single host. */
7
+ export type HostDetails = NonNullable<GetHostByIdResponse['data']>;
8
+ /** Options accepted by {@link HostsResource.list}. */
9
+ export interface ListHostsOptions {
10
+ /** Number of items to return per page. */
11
+ pageSize?: number;
12
+ /** Token of the page to fetch. */
13
+ nextToken?: string;
14
+ }
15
+ /**
16
+ * Hosts registered with the UI account: consoles and network servers that
17
+ * the API key can see.
18
+ */
19
+ export declare function createHostsResource(client: Client): {
20
+ /**
21
+ * Fetch one page of hosts. Pass `nextToken` to continue a previous page.
22
+ */
23
+ list: (options?: ListHostsOptions) => Promise<Page<Host>>;
24
+ /**
25
+ * Lazily yield hosts across all pages, fetching pages on demand.
26
+ */
27
+ iterate: (options?: {
28
+ pageSize?: number;
29
+ }) => AsyncGenerator<Host>;
30
+ /**
31
+ * Fetch every host by following all pagination tokens.
32
+ */
33
+ listAll(options?: {
34
+ pageSize?: number;
35
+ }): Promise<Host[]>;
36
+ /**
37
+ * Fetch detailed information for the host identified by `id`.
38
+ */
39
+ get(id: string): Promise<HostDetails>;
40
+ };
41
+ export type HostsResource = ReturnType<typeof createHostsResource>;
@@ -0,0 +1,48 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ import type { GetIspMetricsResponse, QueryIspMetricsResponse } from '../../generated/types.gen';
3
+ /** Interval granularity accepted by the ISP metrics endpoints. */
4
+ export type IspMetricsInterval = '5m' | '1h';
5
+ /** Relative time range accepted by `get`. */
6
+ export type IspMetricsDuration = '24h' | '7d' | '30d';
7
+ /**
8
+ * Either a relative `duration` or an absolute timestamp range; the API does
9
+ * not allow combining the two.
10
+ */
11
+ export type GetIspMetricsOptions = {
12
+ duration: IspMetricsDuration;
13
+ } | {
14
+ beginTimestamp?: string | Date;
15
+ endTimestamp?: string | Date;
16
+ };
17
+ /** One site to include in an ISP metrics query. */
18
+ export interface QueryIspMetricsSite {
19
+ /** Host managing the site. */
20
+ hostId: string;
21
+ /** Site identifier. */
22
+ siteId: string;
23
+ /** Start of the range; `Date` values are sent as ISO strings. */
24
+ beginTimestamp?: string | Date;
25
+ /** End of the range; `Date` values are sent as ISO strings. */
26
+ endTimestamp?: string | Date;
27
+ }
28
+ /** Per-site ISP metrics returned by {@link IspMetricsResource.get}. */
29
+ export type IspMetrics = NonNullable<GetIspMetricsResponse['data']>;
30
+ /** Result returned by {@link IspMetricsResource.query}. */
31
+ export type IspMetricsQueryResult = NonNullable<QueryIspMetricsResponse['data']>;
32
+ /**
33
+ * ISP (WAN) metrics for the sites visible to the API key, either for all
34
+ * sites in a relative window or for an explicit set of sites.
35
+ */
36
+ export declare function createIspMetricsResource(client: Client): {
37
+ /**
38
+ * Get metrics for every site using `5m` or `1h` intervals. Use either
39
+ * a relative `duration` or absolute `beginTimestamp`/`endTimestamp`.
40
+ */
41
+ get(type: IspMetricsInterval, options?: GetIspMetricsOptions): Promise<IspMetrics>;
42
+ /**
43
+ * Query metrics for specific sites, optionally overriding the time
44
+ * range per site. The upstream response is returned unchanged.
45
+ */
46
+ query(type: IspMetricsInterval, sites: QueryIspMetricsSite[]): Promise<IspMetricsQueryResult>;
47
+ };
48
+ export type IspMetricsResource = ReturnType<typeof createIspMetricsResource>;
@@ -0,0 +1,27 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ import type { GetSdWanConfigByIdResponse, GetSdWanConfigStatusResponse, ListSdWanConfigsResponse } from '../../generated/types.gen';
3
+ /** Compact SD-WAN configuration entry from the list endpoint. */
4
+ export type SdWanConfigSummary = NonNullable<NonNullable<ListSdWanConfigsResponse['data']>[number]>;
5
+ /** Full SD-WAN configuration returned by `get`. */
6
+ export type SdWanConfig = NonNullable<GetSdWanConfigByIdResponse['data']>;
7
+ /** Deployment status of an SD-WAN configuration. */
8
+ export type SdWanConfigStatus = NonNullable<GetSdWanConfigStatusResponse['data']>;
9
+ /**
10
+ * SD-WAN configurations associated with the UI account and their deployment
11
+ * status.
12
+ */
13
+ export declare function createSdWanResource(client: Client): {
14
+ /**
15
+ * List all SD-WAN configurations visible to the API key.
16
+ */
17
+ list(): Promise<SdWanConfigSummary[]>;
18
+ /**
19
+ * Fetch the full SD-WAN configuration identified by `id`.
20
+ */
21
+ get(id: string): Promise<SdWanConfig>;
22
+ /**
23
+ * Fetch the deployment status (hubs, spokes, errors) of config `id`.
24
+ */
25
+ status(id: string): Promise<SdWanConfigStatus>;
26
+ };
27
+ export type SdWanResource = ReturnType<typeof createSdWanResource>;
@@ -0,0 +1,34 @@
1
+ import type { Client } from '../../generated/client/types.gen';
2
+ import type { ListSitesResponse } from '../../generated/types.gen';
3
+ import { type Page } from '../../shared/pagination';
4
+ /** A UniFi site managed by a host. */
5
+ export type Site = NonNullable<NonNullable<ListSitesResponse['data']>[number]>;
6
+ /** Options accepted by {@link SitesResource.list}. */
7
+ export interface ListSitesOptions {
8
+ /** Number of items to return per page. */
9
+ pageSize?: number;
10
+ /** Token of the page to fetch. */
11
+ nextToken?: string;
12
+ }
13
+ /**
14
+ * Sites managed by the hosts visible to the API key.
15
+ */
16
+ export declare function createSitesResource(client: Client): {
17
+ /**
18
+ * Fetch one page of sites. Pass `nextToken` to continue a previous page.
19
+ */
20
+ list: (options?: ListSitesOptions) => Promise<Page<Site>>;
21
+ /**
22
+ * Lazily yield sites across all pages, fetching pages on demand.
23
+ */
24
+ iterate: (options?: {
25
+ pageSize?: number;
26
+ }) => AsyncGenerator<Site>;
27
+ /**
28
+ * Fetch every site by following all pagination tokens.
29
+ */
30
+ listAll(options?: {
31
+ pageSize?: number;
32
+ }): Promise<Site[]>;
33
+ };
34
+ export type SitesResource = ReturnType<typeof createSitesResource>;
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@serkonda7/unifi-api",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "TypeScript client for the UniFi Site Manager API",
4
+ "version": "0.1.1",
5
+ "keywords": [
6
+ "unifi",
7
+ "ubiquiti",
8
+ "site-manager",
9
+ "api",
10
+ "client"
11
+ ],
12
+ "homepage": "https://github.com/serkonda7/unifi-api",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/serkonda7/unifi-api"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/serkonda7/unifi-api/issues"
19
+ },
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "generate": "openapi-ts -i ./openapi/site-manager-1.0.0.json -o ./src/generated",
35
+ "lint": "biome check --write",
36
+ "lint:ci": "biome ci",
37
+ "check": "tsc --noEmit",
38
+ "test": "bun test",
39
+ "docs": "bun run scripts/generate-docs.ts",
40
+ "build": "tsc -p tsconfig.build.json && bun run scripts/build.ts",
41
+ "prepack": "bun run generate && bun run build",
42
+ "pack": "bun pm pack --filename unifi-api.tgz"
43
+ },
44
+ "engines": {
45
+ "node": ">=24"
46
+ },
47
+ "packageManager": "bun@1.4.4",
48
+ "devDependencies": {
49
+ "@biomejs/biome": "2.5.14",
50
+ "@hey-api/openapi-ts": "~0.0.0-next-20260824173136",
51
+ "@types/bun": "~1.4.4",
52
+ "typescript": "~7.0.2"
53
+ }
54
+ }