@swishapp/api-client 0.8.0 → 0.10.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 +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi/sdk.gen.d.ts +6 -2
- package/dist/openapi/types.gen.d.ts +178 -3
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SwishClientConfig, SwishClientOptions, ApiError } from "./types";
|
|
2
2
|
import type * as types from "./openapi/types.gen";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const createApiClient: (options: SwishClientOptions) => SwishClient;
|
|
4
4
|
export type { SwishClient };
|
|
5
5
|
declare class SwishClient {
|
|
6
6
|
private authToken?;
|
|
@@ -60,7 +60,7 @@ declare class SwishClient {
|
|
|
60
60
|
data: null;
|
|
61
61
|
error: ApiError;
|
|
62
62
|
} | {
|
|
63
|
-
data: types.
|
|
63
|
+
data: types.ListDetail;
|
|
64
64
|
error: null;
|
|
65
65
|
}>;
|
|
66
66
|
create: (list: types.CreateListInput) => Promise<{
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var H=Object.defineProperty;var o=(e,r)=>H(e,"name",{value:r,configurable:!0});var G=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 Q={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var K=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),M=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),X=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"D"),B=o(({allowReserved:e,explode:r,name:t,style:s,value:a})=>{if(!r){let l=(e?a:a.map(d=>encodeURIComponent(d))).join(M(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let i=K(s),n=a.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):w({allowReserved:e,name:t,value:l})).join(i);return s==="label"||s==="matrix"?i+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:a})=>{if(a instanceof Date)return`${t}=${a.toISOString()}`;if(s!=="deepObject"&&!r){let l=[];Object.entries(a).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 i=X(s),n=Object.entries(a).map(([l,d])=>w({allowReserved:e,name:s==="deepObject"?`${t}[${l}]`:l,value:d})).join(i);return s==="label"||s==="matrix"?i+n:n},"q"),Y=/\{[^{}]+\}/g,Z=o(({path:e,url:r})=>{let t=r,s=r.match(Y);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,B({explode:i,name:n,style:l,value:d}));continue}if(typeof d=="object"){t=t.replace(a,q({explode:i,name:n,style:l,value:d}));continue}if(l==="matrix"){t=t.replace(a,`;${w({name:n,value:d})}`);continue}let C=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(a,C)}return t},"B"),j=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,B({allowReserved:e,explode:!0,name:i,style:"form",value:n,...r})];continue}if(typeof n=="object"){a=[...a,q({allowReserved:e,explode:!0,name:i,style:"deepObject",value:n,...t})];continue}a=[...a,w({allowReserved:e,name:i,value:n})]}}return a.join("&")},"E"),ee=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"),re=o(async({security:e,...r})=>{for(let t of e){let s=await G(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"),g=o(e=>te({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:j(e.querySerializer),url:e.url}),"S"),te=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:a})=>{let i=a.startsWith("/")?a:`/${a}`,n=(e??"")+i;r&&(n=Z({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=k(e.headers,r.headers),t},"C"),k=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"),f,E=(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),oe=o(()=>({error:new E,request:new E,response:new E}),"T"),ne=j({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),le={"Content-Type":"application/json"},m=o((e={})=>({...Q,headers:le,parseAs:"auto",querySerializer:ne,...e}),"w"),b=o((e={})=>{let r=R(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=R(r,n),t()),"a"),a=oe(),i=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:k(r.headers,n.headers)};l.security&&await re({...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=g(l),C={redirect:"follow",...l},c=new Request(d,C);for(let h of a.request._fns)c=await h(c,l);let J=l.fetch,u=await J(c);for(let h of a.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"?ee(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 a.error._fns)y=await h(O,u,c,l);if(y=y||{},l.throwOnError)throw y;return{error:y,...I}},"o");return{buildUrl:g,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=b(m({baseUrl:"https://swish.app/api/unstable"}));var L=o(e=>((e==null?void 0:e.client)??p).get({url:"/lists",...e}),"listControllerFind"),S=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"),v=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),A=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),P=o(e=>(e.client??p).delete({url:"/items",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerDelete"),F=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).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById"),V=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),W=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),N=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Ie=o(e=>new D(e),"createClient"),x=class x{constructor(r){this.client=b(m({baseUrl:"https://swish.app/api/2025-04"}));this.items={list:o(r=>this.handleRequest(F({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest($({body:r,client:this.client})),"create"),delete:o(r=>this.handleRequest(P({body:{items:r},client:this.client})),"delete"),deleteById:o(r=>this.handleRequest(z({path:{itemId:r},client:this.client})),"deleteById"),updateById:o((r,t)=>this.handleRequest(_({body:t,path:{itemId:r},client:this.client})),"updateById")};this.lists={list:o(r=>this.handleRequest(L({query:r,client:this.client})),"list"),findById:o(r=>this.handleRequest(v({path:{listId:r},client:this.client})),"findById"),create:o(r=>this.handleRequest(S({body:r,client:this.client})),"create"),deleteById:o(r=>this.handleRequest(U({path:{listId:r},client:this.client})),"deleteById"),updateById:o((r,t)=>this.handleRequest(A({body:t,path:{listId:r},client:this.client})),"updateById")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(V({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(N({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(W({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{Ie as createClient};
|
|
1
|
+
var H=Object.defineProperty;var o=(e,r)=>H(e,"name",{value:r,configurable:!0});var G=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 Q={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var K=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),M=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),X=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(M(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=K(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=X(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"),Y=/\{[^{}]+\}/g,Z=o(({path:e,url:r})=>{let t=r,s=r.match(Y);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"),L=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"),ee=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"),re=o(async({security:e,...r})=>{for(let t of e){let s=await G(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=>te({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:L(e.querySerializer),url:e.url}),"S"),te=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=Z({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=S(e.headers,r.headers),t},"C"),S=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),oe=o(()=>({error:new b,request:new b,response:new b}),"T"),ne=L({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),le={"Content-Type":"application/json"},m=o((e={})=>({...Q,headers:le,parseAs:"auto",querySerializer:ne,...e}),"w"),E=o((e={})=>{let r=R(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=R(r,n),t()),"a"),i=oe(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:S(r.headers,n.headers)};l.security&&await re({...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 J=l.fetch,u=await J(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"?ee(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"),U=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),v=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),A=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),F=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");var _=o(e=>(e.client??p).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById");var V=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),W=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),N=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Ie=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(F({body:{items:r},client:this.client})),"delete"),deleteById:o(r=>this.handleRequest(z({path:{itemId:r},client:this.client})),"deleteById"),updateById:o((r,t)=>this.handleRequest(_({body:t,path:{itemId:r},client:this.client})),"updateById")};this.lists={list:o(r=>this.handleRequest(j({query:r,client:this.client})),"list"),findById:o(r=>this.handleRequest(v({path:{listId:r},client:this.client})),"findById"),create:o(r=>this.handleRequest(k({body:r,client:this.client})),"create"),deleteById:o(r=>this.handleRequest(U({path:{listId:r},client:this.client})),"deleteById"),updateById:o((r,t)=>this.handleRequest(A({body:t,path:{listId:r},client:this.client})),"updateById")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(V({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(N({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(W({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{Ie 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, ItemControllerUpdateByIdData, ItemControllerUpdateByIdError, ProfileControllerCustomerAccountsVersionData, ProfileControllerCustomerAccountsVersionError, ProfileControllerIdentifyData, ProfileControllerIdentifyError, ProfileControllerCreateTokenData, ProfileControllerCreateTokenError } from './types.gen';
|
|
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';
|
|
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
|
|
@@ -21,7 +21,7 @@ export declare const listControllerCreate: <ThrowOnError extends boolean = false
|
|
|
21
21
|
}, ListControllerCreateError, ThrowOnError>;
|
|
22
22
|
export declare const listControllerDeleteById: <ThrowOnError extends boolean = false>(options: Options<ListControllerDeleteByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, ListControllerDeleteByIdError, ThrowOnError>;
|
|
23
23
|
export declare const listControllerFindById: <ThrowOnError extends boolean = false>(options: Options<ListControllerFindByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
24
|
-
data?: import("./types.gen").
|
|
24
|
+
data?: import("./types.gen").ListDetail;
|
|
25
25
|
}, ListControllerFindByIdError, ThrowOnError>;
|
|
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;
|
|
@@ -34,9 +34,13 @@ export declare const itemControllerCreate: <ThrowOnError extends boolean = false
|
|
|
34
34
|
data?: import("./types.gen").Item;
|
|
35
35
|
}, ItemControllerCreateError, ThrowOnError>;
|
|
36
36
|
export declare const itemControllerDeleteById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerDeleteByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<void, ItemControllerDeleteByIdError, ThrowOnError>;
|
|
37
|
+
export declare const itemControllerFindById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerFindByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
38
|
+
data?: import("./types.gen").ItemDetail;
|
|
39
|
+
}, ItemControllerFindByIdError, ThrowOnError>;
|
|
37
40
|
export declare const itemControllerUpdateById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerUpdateByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
38
41
|
data?: import("./types.gen").Item;
|
|
39
42
|
}, ItemControllerUpdateByIdError, ThrowOnError>;
|
|
43
|
+
export declare const itemControllerSetListsById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerSetListsByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<unknown, ItemControllerSetListsByIdError, ThrowOnError>;
|
|
40
44
|
export declare const profileControllerCustomerAccountsVersion: <ThrowOnError extends boolean = false>(options?: Options<ProfileControllerCustomerAccountsVersionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
41
45
|
data?: import("./types.gen").AccountsVersionResult;
|
|
42
46
|
}, ProfileControllerCustomerAccountsVersionError, ThrowOnError>;
|
|
@@ -1,3 +1,53 @@
|
|
|
1
|
+
export type Item = {
|
|
2
|
+
/**
|
|
3
|
+
* The ID of the item
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* The Shopify ID of the product
|
|
8
|
+
*/
|
|
9
|
+
productId: number;
|
|
10
|
+
/**
|
|
11
|
+
* The Shopify ID of the variant
|
|
12
|
+
*/
|
|
13
|
+
variantId: {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* The quantity of the item in the list
|
|
18
|
+
*/
|
|
19
|
+
quantity: number;
|
|
20
|
+
/**
|
|
21
|
+
* The date and time the item was created
|
|
22
|
+
*/
|
|
23
|
+
createdAt: string;
|
|
24
|
+
/**
|
|
25
|
+
* The date and time the item was updated
|
|
26
|
+
*/
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
};
|
|
29
|
+
export type ListDetail = {
|
|
30
|
+
/**
|
|
31
|
+
* The ID of the list
|
|
32
|
+
*/
|
|
33
|
+
id: string;
|
|
34
|
+
/**
|
|
35
|
+
* The name of the list
|
|
36
|
+
*/
|
|
37
|
+
name: string;
|
|
38
|
+
/**
|
|
39
|
+
* The date and time the list was created
|
|
40
|
+
*/
|
|
41
|
+
createdAt: string;
|
|
42
|
+
/**
|
|
43
|
+
* The date and time the list was updated
|
|
44
|
+
*/
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
/**
|
|
47
|
+
* The items in the list
|
|
48
|
+
*/
|
|
49
|
+
items: Array<Item>;
|
|
50
|
+
};
|
|
1
51
|
export type List = {
|
|
2
52
|
/**
|
|
3
53
|
* The ID of the list
|
|
@@ -72,7 +122,7 @@ export type UpdateListInput = {
|
|
|
72
122
|
*/
|
|
73
123
|
name: string;
|
|
74
124
|
};
|
|
75
|
-
export type
|
|
125
|
+
export type ItemDetail = {
|
|
76
126
|
/**
|
|
77
127
|
* The ID of the item
|
|
78
128
|
*/
|
|
@@ -99,6 +149,10 @@ export type Item = {
|
|
|
99
149
|
* The date and time the item was updated
|
|
100
150
|
*/
|
|
101
151
|
updatedAt: string;
|
|
152
|
+
/**
|
|
153
|
+
* The list IDs the item is associated with
|
|
154
|
+
*/
|
|
155
|
+
listIds: Array<string>;
|
|
102
156
|
};
|
|
103
157
|
export type CreateItemInput = {
|
|
104
158
|
/**
|
|
@@ -137,6 +191,12 @@ export type UpdateItemInput = {
|
|
|
137
191
|
*/
|
|
138
192
|
quantity?: number;
|
|
139
193
|
};
|
|
194
|
+
export type SetItemListsInput = {
|
|
195
|
+
/**
|
|
196
|
+
* The ID of the item to set the lists for
|
|
197
|
+
*/
|
|
198
|
+
listIds: Array<string>;
|
|
199
|
+
};
|
|
140
200
|
export type AccountsVersionResult = {
|
|
141
201
|
customerAccountsVersion: string;
|
|
142
202
|
};
|
|
@@ -392,7 +452,7 @@ export type ListControllerFindByIdResponses = {
|
|
|
392
452
|
* The list has been successfully retrieved.
|
|
393
453
|
*/
|
|
394
454
|
200: Response & {
|
|
395
|
-
data?:
|
|
455
|
+
data?: ListDetail;
|
|
396
456
|
};
|
|
397
457
|
};
|
|
398
458
|
export type ListControllerFindByIdResponse = ListControllerFindByIdResponses[keyof ListControllerFindByIdResponses];
|
|
@@ -672,6 +732,65 @@ export type ItemControllerDeleteByIdResponses = {
|
|
|
672
732
|
204: void;
|
|
673
733
|
};
|
|
674
734
|
export type ItemControllerDeleteByIdResponse = ItemControllerDeleteByIdResponses[keyof ItemControllerDeleteByIdResponses];
|
|
735
|
+
export type ItemControllerFindByIdData = {
|
|
736
|
+
body?: never;
|
|
737
|
+
path: {
|
|
738
|
+
/**
|
|
739
|
+
* The ID of the item
|
|
740
|
+
*/
|
|
741
|
+
itemId: string;
|
|
742
|
+
};
|
|
743
|
+
query?: never;
|
|
744
|
+
url: '/items/{itemId}';
|
|
745
|
+
};
|
|
746
|
+
export type ItemControllerFindByIdErrors = {
|
|
747
|
+
/**
|
|
748
|
+
* Bad Request
|
|
749
|
+
*/
|
|
750
|
+
400: ErrorResponse & {
|
|
751
|
+
error?: {
|
|
752
|
+
statusCode?: number;
|
|
753
|
+
error?: string;
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
/**
|
|
757
|
+
* Unauthorized
|
|
758
|
+
*/
|
|
759
|
+
401: ErrorResponse & {
|
|
760
|
+
error?: {
|
|
761
|
+
statusCode?: number;
|
|
762
|
+
error?: string;
|
|
763
|
+
};
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* Forbidden
|
|
767
|
+
*/
|
|
768
|
+
403: ErrorResponse & {
|
|
769
|
+
error?: {
|
|
770
|
+
statusCode?: number;
|
|
771
|
+
error?: string;
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* Not Found
|
|
776
|
+
*/
|
|
777
|
+
404: ErrorResponse & {
|
|
778
|
+
error?: {
|
|
779
|
+
statusCode?: number;
|
|
780
|
+
error?: string;
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
export type ItemControllerFindByIdError = ItemControllerFindByIdErrors[keyof ItemControllerFindByIdErrors];
|
|
785
|
+
export type ItemControllerFindByIdResponses = {
|
|
786
|
+
/**
|
|
787
|
+
* The item has been successfully found.
|
|
788
|
+
*/
|
|
789
|
+
200: Response & {
|
|
790
|
+
data?: ItemDetail;
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
export type ItemControllerFindByIdResponse = ItemControllerFindByIdResponses[keyof ItemControllerFindByIdResponses];
|
|
675
794
|
export type ItemControllerUpdateByIdData = {
|
|
676
795
|
body: UpdateItemInput;
|
|
677
796
|
path: {
|
|
@@ -731,6 +850,62 @@ export type ItemControllerUpdateByIdResponses = {
|
|
|
731
850
|
};
|
|
732
851
|
};
|
|
733
852
|
export type ItemControllerUpdateByIdResponse = ItemControllerUpdateByIdResponses[keyof ItemControllerUpdateByIdResponses];
|
|
853
|
+
export type ItemControllerSetListsByIdData = {
|
|
854
|
+
body: SetItemListsInput;
|
|
855
|
+
path: {
|
|
856
|
+
/**
|
|
857
|
+
* The ID of the item
|
|
858
|
+
*/
|
|
859
|
+
itemId: string;
|
|
860
|
+
};
|
|
861
|
+
query?: never;
|
|
862
|
+
url: '/items/{itemId}/lists';
|
|
863
|
+
};
|
|
864
|
+
export type ItemControllerSetListsByIdErrors = {
|
|
865
|
+
/**
|
|
866
|
+
* Bad Request
|
|
867
|
+
*/
|
|
868
|
+
400: ErrorResponse & {
|
|
869
|
+
error?: {
|
|
870
|
+
statusCode?: number;
|
|
871
|
+
error?: string;
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* Unauthorized
|
|
876
|
+
*/
|
|
877
|
+
401: ErrorResponse & {
|
|
878
|
+
error?: {
|
|
879
|
+
statusCode?: number;
|
|
880
|
+
error?: string;
|
|
881
|
+
};
|
|
882
|
+
};
|
|
883
|
+
/**
|
|
884
|
+
* Forbidden
|
|
885
|
+
*/
|
|
886
|
+
403: ErrorResponse & {
|
|
887
|
+
error?: {
|
|
888
|
+
statusCode?: number;
|
|
889
|
+
error?: string;
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* Not Found
|
|
894
|
+
*/
|
|
895
|
+
404: ErrorResponse & {
|
|
896
|
+
error?: {
|
|
897
|
+
statusCode?: number;
|
|
898
|
+
error?: string;
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
};
|
|
902
|
+
export type ItemControllerSetListsByIdError = ItemControllerSetListsByIdErrors[keyof ItemControllerSetListsByIdErrors];
|
|
903
|
+
export type ItemControllerSetListsByIdResponses = {
|
|
904
|
+
/**
|
|
905
|
+
* The item has been successfully been added to the lists.
|
|
906
|
+
*/
|
|
907
|
+
200: unknown;
|
|
908
|
+
};
|
|
734
909
|
export type ProfileControllerCustomerAccountsVersionData = {
|
|
735
910
|
body?: never;
|
|
736
911
|
path?: never;
|
|
@@ -894,5 +1069,5 @@ export type ProfileControllerCreateTokenResponses = {
|
|
|
894
1069
|
};
|
|
895
1070
|
export type ProfileControllerCreateTokenResponse = ProfileControllerCreateTokenResponses[keyof ProfileControllerCreateTokenResponses];
|
|
896
1071
|
export type ClientOptions = {
|
|
897
|
-
baseUrl: 'https://swish.app/api/
|
|
1072
|
+
baseUrl: 'https://swish.app/api/2025-04' | (string & {});
|
|
898
1073
|
};
|