@swishapp/api-client 0.15.0 → 0.15.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.
package/dist/client.d.ts CHANGED
@@ -18,7 +18,7 @@ declare class SwishClient {
18
18
  findById: (itemId: string) => Promise<ApiResponse<types.ItemDetail>>;
19
19
  updateById: (itemId: string, body: types.UpdateItemInput) => Promise<ApiResponse<types.Item>>;
20
20
  deleteById: (itemId: string) => Promise<ApiResponse<unknown>>;
21
- setListsById: (itemId: string, listIds: types.SetItemListsInput["listIds"]) => Promise<ApiResponse<unknown>>;
21
+ setListsById: (itemId: string, listIds: types.SetItemListsInput["listIds"]) => Promise<ApiResponse<types.ItemDetail>>;
22
22
  };
23
23
  readonly lists: {
24
24
  list: (query?: types.ListControllerFindData["query"]) => Promise<ApiResponse<types.List[]>>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var K=Object.defineProperty;var o=(e,r)=>K(e,"name",{value:r,configurable:!0});var M=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 X={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var Y=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),Z=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),ee=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:a})=>{if(!r){let l=(e?a:a.map(d=>encodeURIComponent(d))).join(Z(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let i=Y(s),n=a.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):E({allowReserved:e,name:t,value:l})).join(i);return s==="label"||s==="matrix"?i+n:n},"O"),E=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"),B=o(({allowReserved:e,explode:r,name:t,style:s,value:a})=>{if(a instanceof Date)return`${t}=${a.toISOString()}`;if(s!=="deepObject"&&!r){let l=[];Object.entries(a).forEach(([y,u])=>{l=[...l,y,e?u:encodeURIComponent(u)]});let d=l.join(",");switch(s){case"form":return`${t}=${d}`;case"label":return`.${d}`;case"matrix":return`;${t}=${d}`;default:return d}}let i=ee(s),n=Object.entries(a).map(([l,d])=>E({allowReserved:e,name:s==="deepObject"?`${t}[${l}]`:l,value:d})).join(i);return s==="label"||s==="matrix"?i+n:n},"q"),re=/\{[^{}]+\}/g,te=o(({path:e,url:r})=>{let t=r,s=r.match(re);if(s)for(let a of s){let i=!1,n=a.substring(1,a.length-1),l="simple";n.endsWith("*")&&(i=!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(a,g({explode:i,name:n,style:l,value:d}));continue}if(typeof d=="object"){t=t.replace(a,B({explode:i,name:n,style:l,value:d}));continue}if(l==="matrix"){t=t.replace(a,`;${E({name:n,value:d})}`);continue}let y=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(a,y)}return t},"B"),S=o(({allowReserved:e,array:r,object:t}={})=>s=>{let a=[];if(s&&typeof s=="object")for(let i in s){let n=s[i];if(n!=null){if(Array.isArray(n)){a=[...a,g({allowReserved:e,explode:!0,name:i,style:"form",value:n,...r})];continue}if(typeof n=="object"){a=[...a,B({allowReserved:e,explode:!0,name:i,style:"deepObject",value:n,...t})];continue}a=[...a,E({allowReserved:e,name:i,value:n})]}}return a.join("&")},"E"),oe=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"),ne=o(async({security:e,...r})=>{for(let t of e){let s=await M(t,r.auth);if(!s)continue;let a=t.name??"Authorization";switch(t.in){case"query":r.query||(r.query={}),r.query[a]=s;break;case"header":default:r.headers.set(a,s);break}return}},"I"),R=o(e=>le({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:S(e.querySerializer),url:e.url}),"S"),le=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:a})=>{let i=a.startsWith("/")?a:`/${a}`,n=(e??"")+i;r&&(n=te({path:r,url:n}));let l=t?s(t):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(n+=`?${l}`),n},"W"),x=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=A(e.headers,r.headers),t},"C"),A=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[a,i]of s)if(i===null)r.delete(a);else if(Array.isArray(i))for(let n of i)r.append(a,n);else i!==void 0&&r.set(a,typeof i=="object"?JSON.stringify(i):i)}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),se=o(()=>({error:new b,request:new b,response:new b}),"T"),ae=S({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),ie={"Content-Type":"application/json"},m=o((e={})=>({...X,headers:ie,parseAs:"auto",querySerializer:ae,...e}),"w"),T=o((e={})=>{let r=x(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=x(r,n),t()),"a"),a=se(),i=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:A(r.headers,n.headers)};l.security&&await ne({...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=R(l),y={redirect:"follow",...l},u=new Request(d,y);for(let h of a.request._fns)u=await h(u,l);let Q=l.fetch,c=await Q(u);for(let h of a.response._fns)c=await h(c,u,l);let I={request:u,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return{data:{},...I};let h=(l.parseAs==="auto"?oe(c.headers.get("Content-Type")):l.parseAs)??"json";if(h==="stream")return{data:c.body,...I};let w=await c[h]();return h==="json"&&(l.responseValidator&&await l.responseValidator(w),l.responseTransformer&&(w=await l.responseTransformer(w))),{data:w,...I}}let O=await c.text();try{O=JSON.parse(O)}catch{}let f=O;for(let h of a.error._fns)f=await h(O,c,u,l);if(f=f||{},l.throwOnError)throw f;return{error:f,...I}},"o");return{buildUrl:R,connect:o(n=>i({...n,method:"CONNECT"}),"connect"),delete:o(n=>i({...n,method:"DELETE"}),"delete"),get:o(n=>i({...n,method:"GET"}),"get"),getConfig:t,head:o(n=>i({...n,method:"HEAD"}),"head"),interceptors:a,options:o(n=>i({...n,method:"OPTIONS"}),"options"),patch:o(n=>i({...n,method:"PATCH"}),"patch"),post:o(n=>i({...n,method:"POST"}),"post"),put:o(n=>i({...n,method:"PUT"}),"put"),request:i,setConfig:s,trace:o(n=>i({...n,method:"TRACE"}),"trace")}},"J");var p=T(m({baseUrl:"https://swish.app/api/2025-04"}));var q=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"),v=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),j=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),F=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),U=o(e=>(e.client??p).put({url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerSetListItemsOrder"),P=o(e=>(e.client??p).delete({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerDelete"),$=o(e=>((e==null?void 0:e.client)??p).get({url:"/items",...e}),"itemControllerFind"),z=o(e=>(e.client??p).post({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerCreate"),N=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"),W=o(e=>(e.client??p).put({url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerSetListsById"),J=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),H=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),G=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Ee=o(e=>new D(e),"createApiClient"),L=class L{constructor(r){this.client=T(m({baseUrl:"https://swish.app/api/2025-04"}));this.items={list:o(r=>this.handleRequest($({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(z({body:r,client:this.client})),"create"),delete:o(r=>this.handleRequest(P({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(N({path:{itemId:r},client:this.client})),"deleteById"),setListsById:o((r,t)=>this.handleRequest(W({body:{listIds:t},path:{itemId:r},client:this.client})),"setListsById")};this.lists={list:o(r=>this.handleRequest(q({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(k({body:r,client:this.client})),"create"),findById:o((r,t)=>this.handleRequest(j({path:{listId:r},query:t??{sort:"recently_saved"},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(F({body:t,path:{listId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(v({path:{listId:r},client:this.client})),"deleteById"),orderItems:o((r,t)=>this.handleRequest(U({body:{itemIds:t},path:{listId:r},client:this.client})),"orderItems")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(J({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(G({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(H({body:r,client:this.client})),"identify")};this.handleRequest=o(async r=>{let{data:t,error:s}=await r;if(s!=null&&s.error)return{data:null,error:s==null?void 0:s.error};if(t!=null&&t.data){let a={data:t.data,error:null};return t.pageInfo&&(a.pageInfo=t.pageInfo),a}return{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(L,"SwishClient");var D=L;export{Ee as createApiClient};
1
+ var K=Object.defineProperty;var o=(e,r)=>K(e,"name",{value:r,configurable:!0});var M=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 X={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var Y=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),Z=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),ee=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(Z(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=Y(s),n=i.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):E({allowReserved:e,name:t,value:l})).join(a);return s==="label"||s==="matrix"?a+n:n},"O"),E=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"),B=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(([y,u])=>{l=[...l,y,e?u:encodeURIComponent(u)]});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=ee(s),n=Object.entries(i).map(([l,d])=>E({allowReserved:e,name:s==="deepObject"?`${t}[${l}]`:l,value:d})).join(a);return s==="label"||s==="matrix"?a+n:n},"q"),re=/\{[^{}]+\}/g,te=o(({path:e,url:r})=>{let t=r,s=r.match(re);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,B({explode:a,name:n,style:l,value:d}));continue}if(l==="matrix"){t=t.replace(i,`;${E({name:n,value:d})}`);continue}let y=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(i,y)}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,B({allowReserved:e,explode:!0,name:a,style:"deepObject",value:n,...t})];continue}i=[...i,E({allowReserved:e,name:a,value:n})]}}return i.join("&")},"E"),oe=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"),ne=o(async({security:e,...r})=>{for(let t of e){let s=await M(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"),R=o(e=>le({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:S(e.querySerializer),url:e.url}),"S"),le=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=te({path:r,url:n}));let l=t?s(t):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(n+=`?${l}`),n},"W"),x=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=A(e.headers,r.headers),t},"C"),A=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),se=o(()=>({error:new b,request:new b,response:new b}),"T"),ie=S({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),ae={"Content-Type":"application/json"},m=o((e={})=>({...X,headers:ae,parseAs:"auto",querySerializer:ie,...e}),"w"),T=o((e={})=>{let r=x(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=x(r,n),t()),"a"),i=se(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:A(r.headers,n.headers)};l.security&&await ne({...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=R(l),y={redirect:"follow",...l},u=new Request(d,y);for(let h of i.request._fns)u=await h(u,l);let Q=l.fetch,c=await Q(u);for(let h of i.response._fns)c=await h(c,u,l);let I={request:u,response:c};if(c.ok){if(c.status===204||c.headers.get("Content-Length")==="0")return{data:{},...I};let h=(l.parseAs==="auto"?oe(c.headers.get("Content-Type")):l.parseAs)??"json";if(h==="stream")return{data:c.body,...I};let w=await c[h]();return h==="json"&&(l.responseValidator&&await l.responseValidator(w),l.responseTransformer&&(w=await l.responseTransformer(w))),{data:w,...I}}let O=await c.text();try{O=JSON.parse(O)}catch{}let f=O;for(let h of i.error._fns)f=await h(O,c,u,l);if(f=f||{},l.throwOnError)throw f;return{error:f,...I}},"o");return{buildUrl:R,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=T(m({baseUrl:"https://swish.app/api/2025-04"}));var q=o(e=>((e==null?void 0:e.client)??p).get({url:"/lists",...e}),"listControllerFind"),v=o(e=>(e.client??p).post({url:"/lists",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerCreate"),j=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),k=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),F=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),U=o(e=>(e.client??p).put({url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerSetListItemsOrder"),P=o(e=>(e.client??p).delete({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerDelete"),$=o(e=>((e==null?void 0:e.client)??p).get({url:"/items",...e}),"itemControllerFind"),z=o(e=>(e.client??p).post({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerCreate"),N=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"),W=o(e=>(e.client??p).put({url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerSetListsById"),J=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),H=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),G=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Ee=o(e=>new D(e),"createApiClient"),L=class L{constructor(r){this.client=T(m({baseUrl:"https://swish.app/api/2025-04"}));this.items={list:o(r=>this.handleRequest($({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(z({body:r,client:this.client})),"create"),delete:o(r=>this.handleRequest(P({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(N({path:{itemId:r},client:this.client})),"deleteById"),setListsById:o((r,t)=>this.handleRequest(W({body:{listIds:t},path:{itemId:r},client:this.client})),"setListsById")};this.lists={list:o(r=>this.handleRequest(q({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(v({body:r,client:this.client})),"create"),findById:o((r,t)=>this.handleRequest(k({path:{listId:r},query:t??{sort:"recently_saved"},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(F({body:t,path:{listId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(j({path:{listId:r},client:this.client})),"deleteById"),orderItems:o((r,t)=>this.handleRequest(U({body:{itemIds:t},path:{listId:r},client:this.client})),"orderItems")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(J({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(G({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(H({body:r,client:this.client})),"identify")};this.handleRequest=o(async r=>{let{data:t,error:s}=await r;if(s!=null&&s.error)return{data:null,error:s==null?void 0:s.error};if(t!=null&&t.data){let i={data:t.data,error:null};return t.pageInfo&&(i.pageInfo=t.pageInfo),i}return{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(L,"SwishClient");var D=L;export{Ee as createApiClient};
@@ -43,7 +43,9 @@ export declare const itemControllerFindById: <ThrowOnError extends boolean = fal
43
43
  export declare const itemControllerUpdateById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerUpdateByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
44
44
  data?: import("./types.gen").Item;
45
45
  }, ItemControllerUpdateByIdError, ThrowOnError>;
46
- export declare const itemControllerSetListsById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerSetListsByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<unknown, ItemControllerSetListsByIdError, ThrowOnError>;
46
+ export declare const itemControllerSetListsById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerSetListsByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
47
+ data?: import("./types.gen").ItemDetail;
48
+ }, ItemControllerSetListsByIdError, ThrowOnError>;
47
49
  export declare const profileControllerCustomerAccountsVersion: <ThrowOnError extends boolean = false>(options?: Options<ProfileControllerCustomerAccountsVersionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
48
50
  data?: import("./types.gen").AccountsVersionResult;
49
51
  }, ProfileControllerCustomerAccountsVersionError, ThrowOnError>;
@@ -994,8 +994,11 @@ export type ItemControllerSetListsByIdResponses = {
994
994
  /**
995
995
  * The item has been successfully been added to the lists.
996
996
  */
997
- 200: unknown;
997
+ 200: Response & {
998
+ data?: ItemDetail;
999
+ };
998
1000
  };
1001
+ export type ItemControllerSetListsByIdResponse = ItemControllerSetListsByIdResponses[keyof ItemControllerSetListsByIdResponses];
999
1002
  export type ProfileControllerCustomerAccountsVersionData = {
1000
1003
  body?: never;
1001
1004
  path?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/api-client",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "A lightweight JS client for the Swish REST API.",
5
5
  "homepage": "https://developers.swish.app/libraries/api-client",
6
6
  "type": "module",
@@ -29,6 +29,7 @@
29
29
  "test": "jest",
30
30
  "test:watch": "jest --watch",
31
31
  "build": "rimraf dist && node esbuild.js && tsc -p tsconfig.build.json",
32
+ "dev": "rimraf dist && node esbuild.js --watch && tsc -p tsconfig.build.json --watch",
32
33
  "prepublishOnly": "npm run build",
33
34
  "lint": "eslint src --ext .ts",
34
35
  "clean": "rimraf dist"