@swishapp/api-client 0.11.0 → 0.12.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/client.d.ts CHANGED
@@ -26,7 +26,7 @@ declare class SwishClient {
26
26
  data: types.Item;
27
27
  error: null;
28
28
  }>;
29
- delete: (items: types.DeleteItemsInput["items"]) => Promise<{
29
+ delete: (itemIds: types.DeleteItemsInput["itemIds"]) => Promise<{
30
30
  data: null;
31
31
  error: ApiError;
32
32
  } | {
@@ -70,7 +70,7 @@ declare class SwishClient {
70
70
  data: types.List;
71
71
  error: null;
72
72
  }>;
73
- findById: (listId: string) => Promise<{
73
+ findById: (listId: string, query?: types.ListControllerFindByIdData["query"]) => Promise<{
74
74
  data: null;
75
75
  error: ApiError;
76
76
  } | {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var G=Object.defineProperty;var o=(e,r)=>G(e,"name",{value:r,configurable:!0});var Q=o(async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t},"A");var K={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var M=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),X=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),Y=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"D"),g=o(({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let l=(e?i:i.map(d=>encodeURIComponent(d))).join(X(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=M(s),n=i.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):w({allowReserved:e,name:t,value:l})).join(a);return s==="label"||s==="matrix"?a+n:n},"O"),w=o(({allowReserved:e,name:r,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${e?t:encodeURIComponent(t)}`},"y"),q=o(({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(i instanceof Date)return`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let l=[];Object.entries(i).forEach(([C,c])=>{l=[...l,C,e?c:encodeURIComponent(c)]});let d=l.join(",");switch(s){case"form":return`${t}=${d}`;case"label":return`.${d}`;case"matrix":return`;${t}=${d}`;default:return d}}let a=Y(s),n=Object.entries(i).map(([l,d])=>w({allowReserved:e,name:s==="deepObject"?`${t}[${l}]`:l,value:d})).join(a);return s==="label"||s==="matrix"?a+n:n},"q"),Z=/\{[^{}]+\}/g,ee=o(({path:e,url:r})=>{let t=r,s=r.match(Z);if(s)for(let i of s){let a=!1,n=i.substring(1,i.length-1),l="simple";n.endsWith("*")&&(a=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),l="label"):n.startsWith(";")&&(n=n.substring(1),l="matrix");let d=e[n];if(d==null)continue;if(Array.isArray(d)){t=t.replace(i,g({explode:a,name:n,style:l,value:d}));continue}if(typeof d=="object"){t=t.replace(i,q({explode:a,name:n,style:l,value:d}));continue}if(l==="matrix"){t=t.replace(i,`;${w({name:n,value:d})}`);continue}let C=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(i,C)}return t},"B"),k=o(({allowReserved:e,array:r,object:t}={})=>s=>{let i=[];if(s&&typeof s=="object")for(let a in s){let n=s[a];if(n!=null){if(Array.isArray(n)){i=[...i,g({allowReserved:e,explode:!0,name:a,style:"form",value:n,...r})];continue}if(typeof n=="object"){i=[...i,q({allowReserved:e,explode:!0,name:a,style:"deepObject",value:n,...t})];continue}i=[...i,w({allowReserved:e,name:a,value:n})]}}return i.join("&")},"E"),re=o(e=>{var t;if(!e)return"stream";let r=(t=e.split(";")[0])==null?void 0:t.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return"json";if(r==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(s=>r.startsWith(s)))return"blob";if(r.startsWith("text/"))return"text"}},"P"),te=o(async({security:e,...r})=>{for(let t of e){let s=await Q(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case"query":r.query||(r.query={}),r.query[i]=s;break;case"header":default:r.headers.set(i,s);break}return}},"I"),B=o(e=>oe({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:k(e.querySerializer),url:e.url}),"S"),oe=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=ee({path:r,url:n}));let l=t?s(t):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(n+=`?${l}`),n},"W"),R=o((e,r)=>{var s;let t={...e,...r};return(s=t.baseUrl)!=null&&s.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=L(e.headers,r.headers),t},"C"),L=o((...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a)}return r},"x"),f,b=(f=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}exists(r){return this._fns.indexOf(r)!==-1}eject(r){let t=this._fns.indexOf(r);t!==-1&&(this._fns=[...this._fns.slice(0,t),...this._fns.slice(t+1)])}use(r){this._fns=[...this._fns,r]}},o(f,"m"),f),ne=o(()=>({error:new b,request:new b,response:new b}),"T"),le=k({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),se={"Content-Type":"application/json"},m=o((e={})=>({...K,headers:se,parseAs:"auto",querySerializer:le,...e}),"w"),E=o((e={})=>{let r=R(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=R(r,n),t()),"a"),i=ne(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:L(r.headers,n.headers)};l.security&&await te({...l,security:l.security}),l.body&&l.bodySerializer&&(l.body=l.bodySerializer(l.body)),(l.body===void 0||l.body==="")&&l.headers.delete("Content-Type");let d=B(l),C={redirect:"follow",...l},c=new Request(d,C);for(let h of i.request._fns)c=await h(c,l);let H=l.fetch,u=await H(c);for(let h of i.response._fns)u=await h(u,c,l);let I={request:c,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return{data:{},...I};let h=(l.parseAs==="auto"?re(u.headers.get("Content-Type")):l.parseAs)??"json";if(h==="stream")return{data:u.body,...I};let T=await u[h]();return h==="json"&&(l.responseValidator&&await l.responseValidator(T),l.responseTransformer&&(T=await l.responseTransformer(T))),{data:T,...I}}let O=await u.text();try{O=JSON.parse(O)}catch{}let y=O;for(let h of i.error._fns)y=await h(O,u,c,l);if(y=y||{},l.throwOnError)throw y;return{error:y,...I}},"o");return{buildUrl:B,connect:o(n=>a({...n,method:"CONNECT"}),"connect"),delete:o(n=>a({...n,method:"DELETE"}),"delete"),get:o(n=>a({...n,method:"GET"}),"get"),getConfig:t,head:o(n=>a({...n,method:"HEAD"}),"head"),interceptors:i,options:o(n=>a({...n,method:"OPTIONS"}),"options"),patch:o(n=>a({...n,method:"PATCH"}),"patch"),post:o(n=>a({...n,method:"POST"}),"post"),put:o(n=>a({...n,method:"PUT"}),"put"),request:a,setConfig:s,trace:o(n=>a({...n,method:"TRACE"}),"trace")}},"J");var p=E(m({baseUrl:"https://swish.app/api/2025-04"}));var S=o(e=>((e==null?void 0:e.client)??p).get({url:"/lists",...e}),"listControllerFind"),j=o(e=>(e.client??p).post({url:"/lists",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerCreate"),U=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),F=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),v=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),A=o(e=>(e.client??p).delete({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerDelete"),P=o(e=>((e==null?void 0:e.client)??p).get({url:"/items",...e}),"itemControllerFind"),$=o(e=>(e.client??p).post({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerCreate"),z=o(e=>(e.client??p).delete({url:"/items/{itemId}",...e}),"itemControllerDeleteById"),_=o(e=>(e.client??p).get({url:"/items/{itemId}",...e}),"itemControllerFindById"),V=o(e=>(e.client??p).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById");var W=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),N=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),J=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Oe=o(e=>new D(e),"createApiClient"),x=class x{constructor(r){this.client=E(m({baseUrl:"https://swish.app/api/2025-04"}));this.items={list:o(r=>this.handleRequest(P({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest($({body:r,client:this.client})),"create"),delete:o(r=>this.handleRequest(A({body:{items:r},client:this.client})),"delete"),findById:o(r=>this.handleRequest(_({path:{itemId:r},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(V({body:t,path:{itemId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(z({path:{itemId:r},client:this.client})),"deleteById")};this.lists={list:o(r=>this.handleRequest(S({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(j({body:r,client:this.client})),"create"),findById:o(r=>this.handleRequest(F({path:{listId:r},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(v({body:t,path:{listId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(U({path:{listId:r},client:this.client})),"deleteById")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(W({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(J({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(N({body:r,client:this.client})),"identify")};this.handleRequest=o(async r=>{let{data:t,error:s}=await r;return s!=null&&s.error?{data:null,error:s==null?void 0:s.error}:t!=null&&t.data?{data:t.data,error:null}:{data:null,error:null}},"handleRequest");this.profile=r.profile,r.authToken&&(this.authToken=r.authToken),r.config&&this.client.setConfig(r.config),this.client.interceptors.request.use(this.requestInterceptor.bind(this)),r.requestInterceptor&&this.client.interceptors.request.use(r.requestInterceptor),r.responseInterceptor&&this.client.interceptors.response.use(r.responseInterceptor)}setProfile(r){this.profile=r}setAuthToken(r){this.authToken=r}setConfig(r){this.client.setConfig(r)}requestInterceptor(r){return this.authToken&&r.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&r.headers.set("Profile",this.profile),r}};o(x,"SwishClient");var D=x;export{Oe as createApiClient};
1
+ var G=Object.defineProperty;var o=(e,r)=>G(e,"name",{value:r,configurable:!0});var Q=o(async(e,r)=>{let t=typeof r=="function"?await r(e):r;if(t)return e.scheme==="bearer"?`Bearer ${t}`:e.scheme==="basic"?`Basic ${btoa(t)}`:t},"A");var K={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var M=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),X=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),Y=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"D"),g=o(({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(!r){let l=(e?i:i.map(d=>encodeURIComponent(d))).join(X(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=M(s),n=i.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):w({allowReserved:e,name:t,value:l})).join(a);return s==="label"||s==="matrix"?a+n:n},"O"),w=o(({allowReserved:e,name:r,value:t})=>{if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${e?t:encodeURIComponent(t)}`},"y"),L=o(({allowReserved:e,explode:r,name:t,style:s,value:i})=>{if(i instanceof Date)return`${t}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let l=[];Object.entries(i).forEach(([f,c])=>{l=[...l,f,e?c:encodeURIComponent(c)]});let d=l.join(",");switch(s){case"form":return`${t}=${d}`;case"label":return`.${d}`;case"matrix":return`;${t}=${d}`;default:return d}}let a=Y(s),n=Object.entries(i).map(([l,d])=>w({allowReserved:e,name:s==="deepObject"?`${t}[${l}]`:l,value:d})).join(a);return s==="label"||s==="matrix"?a+n:n},"q"),Z=/\{[^{}]+\}/g,ee=o(({path:e,url:r})=>{let t=r,s=r.match(Z);if(s)for(let i of s){let a=!1,n=i.substring(1,i.length-1),l="simple";n.endsWith("*")&&(a=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(n=n.substring(1),l="label"):n.startsWith(";")&&(n=n.substring(1),l="matrix");let d=e[n];if(d==null)continue;if(Array.isArray(d)){t=t.replace(i,g({explode:a,name:n,style:l,value:d}));continue}if(typeof d=="object"){t=t.replace(i,L({explode:a,name:n,style:l,value:d}));continue}if(l==="matrix"){t=t.replace(i,`;${w({name:n,value:d})}`);continue}let f=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(i,f)}return t},"B"),S=o(({allowReserved:e,array:r,object:t}={})=>s=>{let i=[];if(s&&typeof s=="object")for(let a in s){let n=s[a];if(n!=null){if(Array.isArray(n)){i=[...i,g({allowReserved:e,explode:!0,name:a,style:"form",value:n,...r})];continue}if(typeof n=="object"){i=[...i,L({allowReserved:e,explode:!0,name:a,style:"deepObject",value:n,...t})];continue}i=[...i,w({allowReserved:e,name:a,value:n})]}}return i.join("&")},"E"),re=o(e=>{var t;if(!e)return"stream";let r=(t=e.split(";")[0])==null?void 0:t.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return"json";if(r==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(s=>r.startsWith(s)))return"blob";if(r.startsWith("text/"))return"text"}},"P"),te=o(async({security:e,...r})=>{for(let t of e){let s=await Q(t,r.auth);if(!s)continue;let i=t.name??"Authorization";switch(t.in){case"query":r.query||(r.query={}),r.query[i]=s;break;case"header":default:r.headers.set(i,s);break}return}},"I"),B=o(e=>oe({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:S(e.querySerializer),url:e.url}),"S"),oe=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=ee({path:r,url:n}));let l=t?s(t):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(n+=`?${l}`),n},"W"),R=o((e,r)=>{var s;let t={...e,...r};return(s=t.baseUrl)!=null&&s.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=q(e.headers,r.headers),t},"C"),q=o((...e)=>{let r=new Headers;for(let t of e){if(!t||typeof t!="object")continue;let s=t instanceof Headers?t.entries():Object.entries(t);for(let[i,a]of s)if(a===null)r.delete(i);else if(Array.isArray(a))for(let n of a)r.append(i,n);else a!==void 0&&r.set(i,typeof a=="object"?JSON.stringify(a):a)}return r},"x"),C,b=(C=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}exists(r){return this._fns.indexOf(r)!==-1}eject(r){let t=this._fns.indexOf(r);t!==-1&&(this._fns=[...this._fns.slice(0,t),...this._fns.slice(t+1)])}use(r){this._fns=[...this._fns,r]}},o(C,"m"),C),ne=o(()=>({error:new b,request:new b,response:new b}),"T"),le=S({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),se={"Content-Type":"application/json"},m=o((e={})=>({...K,headers:se,parseAs:"auto",querySerializer:le,...e}),"w"),E=o((e={})=>{let r=R(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=R(r,n),t()),"a"),i=ne(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers)};l.security&&await te({...l,security:l.security}),l.body&&l.bodySerializer&&(l.body=l.bodySerializer(l.body)),(l.body===void 0||l.body==="")&&l.headers.delete("Content-Type");let d=B(l),f={redirect:"follow",...l},c=new Request(d,f);for(let h of i.request._fns)c=await h(c,l);let H=l.fetch,u=await H(c);for(let h of i.response._fns)u=await h(u,c,l);let I={request:c,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return{data:{},...I};let h=(l.parseAs==="auto"?re(u.headers.get("Content-Type")):l.parseAs)??"json";if(h==="stream")return{data:u.body,...I};let T=await u[h]();return h==="json"&&(l.responseValidator&&await l.responseValidator(T),l.responseTransformer&&(T=await l.responseTransformer(T))),{data:T,...I}}let O=await u.text();try{O=JSON.parse(O)}catch{}let y=O;for(let h of i.error._fns)y=await h(O,u,c,l);if(y=y||{},l.throwOnError)throw y;return{error:y,...I}},"o");return{buildUrl:B,connect:o(n=>a({...n,method:"CONNECT"}),"connect"),delete:o(n=>a({...n,method:"DELETE"}),"delete"),get:o(n=>a({...n,method:"GET"}),"get"),getConfig:t,head:o(n=>a({...n,method:"HEAD"}),"head"),interceptors:i,options:o(n=>a({...n,method:"OPTIONS"}),"options"),patch:o(n=>a({...n,method:"PATCH"}),"patch"),post:o(n=>a({...n,method:"POST"}),"post"),put:o(n=>a({...n,method:"PUT"}),"put"),request:a,setConfig:s,trace:o(n=>a({...n,method:"TRACE"}),"trace")}},"J");var p=E(m({baseUrl:"https://swish.app/api/2025-04"}));var j=o(e=>((e==null?void 0:e.client)??p).get({url:"/lists",...e}),"listControllerFind"),k=o(e=>(e.client??p).post({url:"/lists",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerCreate"),F=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),U=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),v=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById");var A=o(e=>(e.client??p).delete({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerDelete"),P=o(e=>((e==null?void 0:e.client)??p).get({url:"/items",...e}),"itemControllerFind"),$=o(e=>(e.client??p).post({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerCreate"),z=o(e=>(e.client??p).delete({url:"/items/{itemId}",...e}),"itemControllerDeleteById"),_=o(e=>(e.client??p).get({url:"/items/{itemId}",...e}),"itemControllerFindById"),V=o(e=>(e.client??p).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById");var W=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),N=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),J=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Oe=o(e=>new D(e),"createApiClient"),x=class x{constructor(r){this.client=E(m({baseUrl:"https://swish.app/api/2025-04"}));this.items={list:o(r=>this.handleRequest(P({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest($({body:r,client:this.client})),"create"),delete:o(r=>this.handleRequest(A({body:{itemIds:r},client:this.client})),"delete"),findById:o(r=>this.handleRequest(_({path:{itemId:r},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(V({body:t,path:{itemId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(z({path:{itemId:r},client:this.client})),"deleteById")};this.lists={list:o(r=>this.handleRequest(j({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(k({body:r,client:this.client})),"create"),findById:o((r,t)=>this.handleRequest(U({path:{listId:r},query:t??{sort:"recently_saved"},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(v({body:t,path:{listId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(F({path:{listId:r},client:this.client})),"deleteById")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(W({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(J({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(N({body:r,client:this.client})),"identify")};this.handleRequest=o(async r=>{let{data:t,error:s}=await r;return s!=null&&s.error?{data:null,error:s==null?void 0:s.error}:t!=null&&t.data?{data:t.data,error:null}:{data:null,error:null}},"handleRequest");this.profile=r.profile,r.authToken&&(this.authToken=r.authToken),r.config&&this.client.setConfig(r.config),this.client.interceptors.request.use(this.requestInterceptor.bind(this)),r.requestInterceptor&&this.client.interceptors.request.use(r.requestInterceptor),r.responseInterceptor&&this.client.interceptors.response.use(r.responseInterceptor)}setProfile(r){this.profile=r}setAuthToken(r){this.authToken=r}setConfig(r){this.client.setConfig(r)}requestInterceptor(r){return this.authToken&&r.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&r.headers.set("Profile",this.profile),r}};o(x,"SwishClient");var D=x;export{Oe as createApiClient};
@@ -1,5 +1,5 @@
1
1
  import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
2
- import type { ListControllerFindData, ListControllerFindError, ListControllerCreateData, ListControllerCreateError, ListControllerDeleteByIdData, ListControllerDeleteByIdError, ListControllerFindByIdData, ListControllerFindByIdError, ListControllerUpdateByIdData, ListControllerUpdateByIdError, ItemControllerDeleteData, ItemControllerDeleteError, ItemControllerFindData, ItemControllerFindError, ItemControllerCreateData, ItemControllerCreateError, ItemControllerDeleteByIdData, ItemControllerDeleteByIdError, ItemControllerFindByIdData, ItemControllerFindByIdError, ItemControllerUpdateByIdData, ItemControllerUpdateByIdError, ItemControllerSetListsByIdData, ItemControllerSetListsByIdError, ProfileControllerCustomerAccountsVersionData, ProfileControllerCustomerAccountsVersionError, ProfileControllerIdentifyData, ProfileControllerIdentifyError, ProfileControllerCreateTokenData, ProfileControllerCreateTokenError } from './types.gen';
2
+ import type { ListControllerFindData, ListControllerFindError, ListControllerCreateData, ListControllerCreateError, ListControllerDeleteByIdData, ListControllerDeleteByIdError, ListControllerFindByIdData, ListControllerFindByIdError, ListControllerUpdateByIdData, ListControllerUpdateByIdError, ListControllerSetListItemsOrderData, ListControllerSetListItemsOrderError, ItemControllerDeleteData, ItemControllerDeleteError, ItemControllerFindData, ItemControllerFindError, ItemControllerCreateData, ItemControllerCreateError, ItemControllerDeleteByIdData, ItemControllerDeleteByIdError, ItemControllerFindByIdData, ItemControllerFindByIdError, ItemControllerUpdateByIdData, ItemControllerUpdateByIdError, ItemControllerSetListsByIdData, ItemControllerSetListsByIdError, ProfileControllerCustomerAccountsVersionData, ProfileControllerCustomerAccountsVersionError, ProfileControllerIdentifyData, ProfileControllerIdentifyError, ProfileControllerCreateTokenData, ProfileControllerCreateTokenError } from './types.gen';
3
3
  export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
4
4
  /**
5
5
  * You can provide a client instance returned by `createClient()` instead of
@@ -13,7 +13,7 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
13
13
  */
14
14
  meta?: Record<string, unknown>;
15
15
  };
16
- export declare const listControllerFind: <ThrowOnError extends boolean = false>(options?: Options<ListControllerFindData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").PaginatedResponse & {
16
+ export declare const listControllerFind: <ThrowOnError extends boolean = false>(options?: Options<ListControllerFindData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
17
17
  data?: Array<import("./types.gen").List>;
18
18
  }, ListControllerFindError, ThrowOnError>;
19
19
  export declare const listControllerCreate: <ThrowOnError extends boolean = false>(options: Options<ListControllerCreateData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
@@ -26,6 +26,9 @@ export declare const listControllerFindById: <ThrowOnError extends boolean = fal
26
26
  export declare const listControllerUpdateById: <ThrowOnError extends boolean = false>(options: Options<ListControllerUpdateByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
27
27
  data?: import("./types.gen").List;
28
28
  }, ListControllerUpdateByIdError, ThrowOnError>;
29
+ export declare const listControllerSetListItemsOrder: <ThrowOnError extends boolean = false>(options: Options<ListControllerSetListItemsOrderData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
30
+ data?: import("./types.gen").List;
31
+ }, ListControllerSetListItemsOrderError, ThrowOnError>;
29
32
  export declare const itemControllerDelete: <ThrowOnError extends boolean = false>(options: Options<ItemControllerDeleteData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, ItemControllerDeleteError, ThrowOnError>;
30
33
  export declare const itemControllerFind: <ThrowOnError extends boolean = false>(options?: Options<ItemControllerFindData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").PaginatedResponse & {
31
34
  data?: Array<import("./types.gen").Item>;
@@ -122,6 +122,12 @@ export type UpdateListInput = {
122
122
  */
123
123
  name: string;
124
124
  };
125
+ export type SetListItemsOrderInput = {
126
+ /**
127
+ * The list of item IDs to reorder
128
+ */
129
+ itemIds: Array<string>;
130
+ };
125
131
  export type ItemDetail = {
126
132
  /**
127
133
  * The ID of the item
@@ -175,7 +181,7 @@ export type ItemReference = {
175
181
  id: string;
176
182
  };
177
183
  export type DeleteItemsInput = {
178
- items: Array<ItemReference>;
184
+ itemIds: Array<ItemReference>;
179
185
  };
180
186
  export type UpdateItemInput = {
181
187
  /**
@@ -281,7 +287,7 @@ export type ListControllerFindResponses = {
281
287
  /**
282
288
  * Returns all lists as paginated response
283
289
  */
284
- 200: PaginatedResponse & {
290
+ 200: Response & {
285
291
  data?: Array<List>;
286
292
  };
287
293
  };
@@ -405,7 +411,12 @@ export type ListControllerFindByIdData = {
405
411
  */
406
412
  listId: string;
407
413
  };
408
- query?: never;
414
+ query: {
415
+ /**
416
+ * The sort order of the items in the list
417
+ */
418
+ sort: 'recently_saved' | 'custom';
419
+ };
409
420
  url: '/lists/{listId}';
410
421
  };
411
422
  export type ListControllerFindByIdErrors = {
@@ -515,6 +526,65 @@ export type ListControllerUpdateByIdResponses = {
515
526
  };
516
527
  };
517
528
  export type ListControllerUpdateByIdResponse = ListControllerUpdateByIdResponses[keyof ListControllerUpdateByIdResponses];
529
+ export type ListControllerSetListItemsOrderData = {
530
+ body: SetListItemsOrderInput;
531
+ path: {
532
+ /**
533
+ * The ID of the list
534
+ */
535
+ listId: string;
536
+ };
537
+ query?: never;
538
+ url: '/lists/{listId}/items/order';
539
+ };
540
+ export type ListControllerSetListItemsOrderErrors = {
541
+ /**
542
+ * Bad Request
543
+ */
544
+ 400: ErrorResponse & {
545
+ error?: {
546
+ statusCode?: number;
547
+ error?: string;
548
+ };
549
+ };
550
+ /**
551
+ * Unauthorized
552
+ */
553
+ 401: ErrorResponse & {
554
+ error?: {
555
+ statusCode?: number;
556
+ error?: string;
557
+ };
558
+ };
559
+ /**
560
+ * Forbidden
561
+ */
562
+ 403: ErrorResponse & {
563
+ error?: {
564
+ statusCode?: number;
565
+ error?: string;
566
+ };
567
+ };
568
+ /**
569
+ * Not Found
570
+ */
571
+ 404: ErrorResponse & {
572
+ error?: {
573
+ statusCode?: number;
574
+ error?: string;
575
+ };
576
+ };
577
+ };
578
+ export type ListControllerSetListItemsOrderError = ListControllerSetListItemsOrderErrors[keyof ListControllerSetListItemsOrderErrors];
579
+ export type ListControllerSetListItemsOrderResponses = {
580
+ /**
581
+ * The list items have been successfully reordered.
582
+ */
583
+ 200: Response & {
584
+ data?: List;
585
+ };
586
+ };
587
+ export type ListControllerSetListItemsOrderResponse = ListControllerSetListItemsOrderResponses[keyof ListControllerSetListItemsOrderResponses];
518
588
  export type ItemControllerDeleteData = {
519
589
  body: DeleteItemsInput;
520
590
  path?: never;
@@ -570,7 +640,20 @@ export type ItemControllerDeleteResponse = ItemControllerDeleteResponses[keyof I
570
640
  export type ItemControllerFindData = {
571
641
  body?: never;
572
642
  path?: never;
573
- query?: never;
643
+ query?: {
644
+ /**
645
+ * The page cursor
646
+ */
647
+ page?: string;
648
+ /**
649
+ * Number of lists/items to return
650
+ */
651
+ limit?: number;
652
+ /**
653
+ * Item search query
654
+ */
655
+ query?: string;
656
+ };
574
657
  url: '/items';
575
658
  };
576
659
  export type ItemControllerFindErrors = {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@swishapp/api-client",
3
- "version": "0.11.0",
4
- "description": "API client for the Swish API",
5
- "website": "https://swish.app",
3
+ "version": "0.12.0",
4
+ "description": "A lightweight JS client for the Swish REST API.",
5
+ "website": "https://docs.swish.app",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.js",