@swishapp/api-client 0.13.4 → 0.14.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/README.md +2 -2
- package/dist/client.d.ts +16 -106
- package/dist/index.js +1 -1
- package/dist/openapi/types.gen.d.ts +2 -2
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ npm install @swishapp/api-client
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { createApiClient } from "@swishapp/api-client";
|
|
15
15
|
|
|
16
|
-
const swish =
|
|
16
|
+
const swish = createApiClient({
|
|
17
17
|
authToken: "swish-api-token",
|
|
18
18
|
profile: "gid://shopify/Customer/12345",
|
|
19
19
|
});
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SwishClientConfig, SwishClientOptions,
|
|
1
|
+
import type { SwishClientConfig, SwishClientOptions, ApiResponse } from "./types";
|
|
2
2
|
import type * as types from "./openapi/types.gen";
|
|
3
3
|
export declare const createApiClient: (options: SwishClientOptions) => SwishClient;
|
|
4
4
|
export type { SwishClient };
|
|
@@ -12,115 +12,25 @@ declare class SwishClient {
|
|
|
12
12
|
setConfig(config: SwishClientConfig): void;
|
|
13
13
|
requestInterceptor(request: Request): Request;
|
|
14
14
|
readonly items: {
|
|
15
|
-
list: (query?: types.ItemControllerFindData["query"]) => Promise<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}>;
|
|
22
|
-
create: (items: types.CreateItemInput) => Promise<{
|
|
23
|
-
data: null;
|
|
24
|
-
error: ApiError;
|
|
25
|
-
} | {
|
|
26
|
-
data: types.Item;
|
|
27
|
-
error: null;
|
|
28
|
-
}>;
|
|
29
|
-
delete: (itemIds: types.DeleteItemsInput["itemIds"]) => Promise<{
|
|
30
|
-
data: null;
|
|
31
|
-
error: ApiError;
|
|
32
|
-
} | {
|
|
33
|
-
data: unknown;
|
|
34
|
-
error: null;
|
|
35
|
-
}>;
|
|
36
|
-
findById: (itemId: string) => Promise<{
|
|
37
|
-
data: null;
|
|
38
|
-
error: ApiError;
|
|
39
|
-
} | {
|
|
40
|
-
data: types.ItemDetail;
|
|
41
|
-
error: null;
|
|
42
|
-
}>;
|
|
43
|
-
updateById: (itemId: string, body: types.UpdateItemInput) => Promise<{
|
|
44
|
-
data: null;
|
|
45
|
-
error: ApiError;
|
|
46
|
-
} | {
|
|
47
|
-
data: types.Item;
|
|
48
|
-
error: null;
|
|
49
|
-
}>;
|
|
50
|
-
deleteById: (itemId: string) => Promise<{
|
|
51
|
-
data: null;
|
|
52
|
-
error: ApiError;
|
|
53
|
-
} | {
|
|
54
|
-
data: unknown;
|
|
55
|
-
error: null;
|
|
56
|
-
}>;
|
|
15
|
+
list: (query?: types.ItemControllerFindData["query"]) => Promise<ApiResponse<types.Item[]>>;
|
|
16
|
+
create: (items: types.CreateItemInput) => Promise<ApiResponse<types.Item>>;
|
|
17
|
+
delete: (itemIds: types.DeleteItemsInput["itemIds"]) => Promise<ApiResponse<unknown>>;
|
|
18
|
+
findById: (itemId: string) => Promise<ApiResponse<types.ItemDetail>>;
|
|
19
|
+
updateById: (itemId: string, body: types.UpdateItemInput) => Promise<ApiResponse<types.Item>>;
|
|
20
|
+
deleteById: (itemId: string) => Promise<ApiResponse<unknown>>;
|
|
57
21
|
};
|
|
58
22
|
readonly lists: {
|
|
59
|
-
list: (query?: types.ListControllerFindData["query"]) => Promise<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}>;
|
|
66
|
-
create: (list: types.CreateListInput) => Promise<{
|
|
67
|
-
data: null;
|
|
68
|
-
error: ApiError;
|
|
69
|
-
} | {
|
|
70
|
-
data: types.List;
|
|
71
|
-
error: null;
|
|
72
|
-
}>;
|
|
73
|
-
findById: (listId: string, query?: types.ListControllerFindByIdData["query"]) => Promise<{
|
|
74
|
-
data: null;
|
|
75
|
-
error: ApiError;
|
|
76
|
-
} | {
|
|
77
|
-
data: types.ListDetail;
|
|
78
|
-
error: null;
|
|
79
|
-
}>;
|
|
80
|
-
updateById: (listId: string, body: types.UpdateListInput) => Promise<{
|
|
81
|
-
data: null;
|
|
82
|
-
error: ApiError;
|
|
83
|
-
} | {
|
|
84
|
-
data: types.List;
|
|
85
|
-
error: null;
|
|
86
|
-
}>;
|
|
87
|
-
deleteById: (listId: string) => Promise<{
|
|
88
|
-
data: null;
|
|
89
|
-
error: ApiError;
|
|
90
|
-
} | {
|
|
91
|
-
data: unknown;
|
|
92
|
-
error: null;
|
|
93
|
-
}>;
|
|
94
|
-
orderItems: (listId: string, itemIds: types.SetListItemsOrderInput["itemIds"]) => Promise<{
|
|
95
|
-
data: null;
|
|
96
|
-
error: ApiError;
|
|
97
|
-
} | {
|
|
98
|
-
data: types.List;
|
|
99
|
-
error: null;
|
|
100
|
-
}>;
|
|
23
|
+
list: (query?: types.ListControllerFindData["query"]) => Promise<ApiResponse<types.List[]>>;
|
|
24
|
+
create: (list: types.CreateListInput) => Promise<ApiResponse<types.List>>;
|
|
25
|
+
findById: (listId: string, query?: types.ListControllerFindByIdData["query"]) => Promise<ApiResponse<types.ListDetail>>;
|
|
26
|
+
updateById: (listId: string, body: types.UpdateListInput) => Promise<ApiResponse<types.List>>;
|
|
27
|
+
deleteById: (listId: string) => Promise<ApiResponse<unknown>>;
|
|
28
|
+
orderItems: (listId: string, itemIds: types.SetListItemsOrderInput["itemIds"]) => Promise<ApiResponse<types.List>>;
|
|
101
29
|
};
|
|
102
30
|
readonly profiles: {
|
|
103
|
-
customerAccountsVersion: () => Promise<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
} | {
|
|
107
|
-
data: types.AccountsVersionResult;
|
|
108
|
-
error: null;
|
|
109
|
-
}>;
|
|
110
|
-
createToken: (body?: types.CreateProfileTokenInput) => Promise<{
|
|
111
|
-
data: null;
|
|
112
|
-
error: ApiError;
|
|
113
|
-
} | {
|
|
114
|
-
data: types.CreateProfileTokenResult;
|
|
115
|
-
error: null;
|
|
116
|
-
}>;
|
|
117
|
-
identify: (body: types.IdentifyProfileInput) => Promise<{
|
|
118
|
-
data: null;
|
|
119
|
-
error: ApiError;
|
|
120
|
-
} | {
|
|
121
|
-
data: types.IdentifyProfileResult;
|
|
122
|
-
error: null;
|
|
123
|
-
}>;
|
|
31
|
+
customerAccountsVersion: () => Promise<ApiResponse<types.AccountsVersionResult>>;
|
|
32
|
+
createToken: (body?: types.CreateProfileTokenInput) => Promise<ApiResponse<types.CreateProfileTokenResult>>;
|
|
33
|
+
identify: (body: types.IdentifyProfileInput) => Promise<ApiResponse<types.IdentifyProfileResult>>;
|
|
124
34
|
};
|
|
125
35
|
private readonly handleRequest;
|
|
126
36
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Q=Object.defineProperty;var o=(e,r)=>Q(e,"name",{value:r,configurable:!0});var K=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 M={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var X=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),Y=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),Z=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(Y(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=X(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,h])=>{l=[...l,f,e?h:encodeURIComponent(h)]});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=Z(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"),ee=/\{[^{}]+\}/g,re=o(({path:e,url:r})=>{let t=r,s=r.match(ee);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"),te=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"),oe=o(async({security:e,...r})=>{for(let t of e){let s=await K(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=>ne({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:S(e.querySerializer),url:e.url}),"S"),ne=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=re({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),le=o(()=>({error:new b,request:new b,response:new b}),"T"),se=S({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),ie={"Content-Type":"application/json"},m=o((e={})=>({...M,headers:ie,parseAs:"auto",querySerializer:se,...e}),"w"),E=o((e={})=>{let r=R(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=R(r,n),t()),"a"),i=le(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers)};l.security&&await oe({...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},h=new Request(d,f);for(let c of i.request._fns)h=await c(h,l);let G=l.fetch,u=await G(h);for(let c of i.response._fns)u=await c(u,h,l);let I={request:h,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return{data:{},...I};let c=(l.parseAs==="auto"?te(u.headers.get("Content-Type")):l.parseAs)??"json";if(c==="stream")return{data:u.body,...I};let T=await u[c]();return c==="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 c of i.error._fns)y=await c(O,u,h,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 k=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"),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"),A=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"),_=o(e=>(e.client??p).delete({url:"/items/{itemId}",...e}),"itemControllerDeleteById"),V=o(e=>(e.client??p).get({url:"/items/{itemId}",...e}),"itemControllerFindById"),W=o(e=>(e.client??p).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById");var N=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),J=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),H=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Te=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($({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(V({path:{itemId:r},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(W({body:t,path:{itemId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(_({path:{itemId:r},client:this.client})),"deleteById")};this.lists={list:o(r=>this.handleRequest(k({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(j({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"),orderItems:o((r,t)=>this.handleRequest(A({body:{itemIds:t},path:{listId:r},client:this.client})),"orderItems")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(N({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(H({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(J({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{Te as createApiClient};
|
|
1
|
+
var Q=Object.defineProperty;var o=(e,r)=>Q(e,"name",{value:r,configurable:!0});var K=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 M={bodySerializer:o(e=>JSON.stringify(e,(r,t)=>typeof t=="bigint"?t.toString():t),"bodySerializer")};var X=o(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),Y=o(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),Z=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:i})=>{if(!r){let l=(e?i:i.map(d=>encodeURIComponent(d))).join(Y(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${t}=${l}`;case"simple":return l;default:return`${t}=${l}`}}let a=X(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(([C,h])=>{l=[...l,C,e?h:encodeURIComponent(h)]});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=Z(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"),ee=/\{[^{}]+\}/g,re=o(({path:e,url:r})=>{let t=r,s=r.match(ee);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,B({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 C=encodeURIComponent(l==="label"?`.${d}`:d);t=t.replace(i,C)}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,B({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"),te=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"),oe=o(async({security:e,...r})=>{for(let t of e){let s=await K(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"),g=o(e=>ne({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:S(e.querySerializer),url:e.url}),"S"),ne=o(({baseUrl:e,path:r,query:t,querySerializer:s,url:i})=>{let a=i.startsWith("/")?i:`/${i}`,n=(e??"")+a;r&&(n=re({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=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"),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),le=o(()=>({error:new b,request:new b,response:new b}),"T"),se=S({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),ie={"Content-Type":"application/json"},m=o((e={})=>({...M,headers:ie,parseAs:"auto",querySerializer:se,...e}),"w"),E=o((e={})=>{let r=x(m(),e),t=o(()=>({...r}),"e"),s=o(n=>(r=x(r,n),t()),"a"),i=le(),a=o(async n=>{let l={...r,...n,fetch:n.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,n.headers)};l.security&&await oe({...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},h=new Request(d,C);for(let c of i.request._fns)h=await c(h,l);let G=l.fetch,u=await G(h);for(let c of i.response._fns)u=await c(u,h,l);let I={request:h,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return{data:{},...I};let c=(l.parseAs==="auto"?te(u.headers.get("Content-Type")):l.parseAs)??"json";if(c==="stream")return{data:u.body,...I};let T=await u[c]();return c==="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 c of i.error._fns)y=await c(O,u,h,l);if(y=y||{},l.throwOnError)throw y;return{error:y,...I}},"o");return{buildUrl:g,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 k=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"),A=o(e=>(e.client??p).delete({url:"/lists/{listId}",...e}),"listControllerDeleteById"),F=o(e=>(e.client??p).get({url:"/lists/{listId}",...e}),"listControllerFindById"),U=o(e=>(e.client??p).patch({url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"listControllerUpdateById"),v=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"),_=o(e=>(e.client??p).delete({url:"/items/{itemId}",...e}),"itemControllerDeleteById"),V=o(e=>(e.client??p).get({url:"/items/{itemId}",...e}),"itemControllerFindById"),W=o(e=>(e.client??p).patch({url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"itemControllerUpdateById");var N=o(e=>((e==null?void 0:e.client)??p).get({url:"/profiles/accounts-version",...e}),"profileControllerCustomerAccountsVersion"),J=o(e=>(e.client??p).post({url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerIdentify"),H=o(e=>(e.client??p).post({url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),"profileControllerCreateToken");var Te=o(e=>new D(e),"createApiClient"),R=class R{constructor(r){this.client=E(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(V({path:{itemId:r},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(W({body:t,path:{itemId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(_({path:{itemId:r},client:this.client})),"deleteById")};this.lists={list:o(r=>this.handleRequest(k({query:r,client:this.client})),"list"),create:o(r=>this.handleRequest(j({body:r,client:this.client})),"create"),findById:o((r,t)=>this.handleRequest(F({path:{listId:r},query:t??{sort:"recently_saved"},client:this.client})),"findById"),updateById:o((r,t)=>this.handleRequest(U({body:t,path:{listId:r},client:this.client})),"updateById"),deleteById:o(r=>this.handleRequest(A({path:{listId:r},client:this.client})),"deleteById"),orderItems:o((r,t)=>this.handleRequest(v({body:{itemIds:t},path:{listId:r},client:this.client})),"orderItems")};this.profiles={customerAccountsVersion:o(()=>this.handleRequest(N({client:this.client})),"customerAccountsVersion"),createToken:o((r={})=>this.handleRequest(H({body:r,client:this.client})),"createToken"),identify:o(r=>this.handleRequest(J({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(R,"SwishClient");var D=R;export{Te as createApiClient};
|
|
@@ -408,11 +408,11 @@ export type ListControllerFindByIdData = {
|
|
|
408
408
|
*/
|
|
409
409
|
listId: string;
|
|
410
410
|
};
|
|
411
|
-
query
|
|
411
|
+
query?: {
|
|
412
412
|
/**
|
|
413
413
|
* The sort order of the items in the list
|
|
414
414
|
*/
|
|
415
|
-
sort
|
|
415
|
+
sort?: 'recently_saved' | 'custom';
|
|
416
416
|
};
|
|
417
417
|
url: '/lists/{listId}';
|
|
418
418
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClientOptions, Config } from "@hey-api/client-fetch";
|
|
2
2
|
import type { SwishClient } from "./client";
|
|
3
|
+
import { PageInfo } from "./openapi/types.gen";
|
|
3
4
|
export type { SwishClient };
|
|
4
5
|
export interface SwishClientOptions {
|
|
5
6
|
authToken?: string;
|
|
@@ -30,3 +31,8 @@ export interface ApiError {
|
|
|
30
31
|
requestId: string;
|
|
31
32
|
statusCode: number;
|
|
32
33
|
}
|
|
34
|
+
export type ApiResponse<TData> = {
|
|
35
|
+
data: TData | null;
|
|
36
|
+
error: ApiError | null;
|
|
37
|
+
pageInfo?: PageInfo;
|
|
38
|
+
};
|