@swishapp/api-client 0.41.0 → 0.43.0-unstable.20260305130147
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 +55 -0
- package/dist/{client.d.ts → 2026-01/client.d.ts} +19 -8
- package/dist/2026-01/index.d.ts +3 -0
- package/dist/2026-01/index.js +7 -0
- package/dist/{openapi → 2026-01/openapi}/client/index.d.ts +2 -1
- package/dist/{openapi → 2026-01/openapi}/client/types.gen.d.ts +2 -9
- package/dist/{openapi → 2026-01/openapi}/client/utils.gen.d.ts +1 -1
- package/dist/{openapi → 2026-01/openapi}/core/bodySerializer.gen.d.ts +12 -4
- package/dist/{openapi → 2026-01/openapi}/core/params.gen.d.ts +10 -0
- package/dist/2026-01/openapi/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/2026-01/openapi/index.d.ts +2 -0
- package/dist/{openapi → 2026-01/openapi}/sdk.gen.d.ts +14 -4
- package/dist/{openapi → 2026-01/openapi}/types.gen.d.ts +775 -20
- package/dist/{types.d.ts → 2026-01/types.d.ts} +1 -2
- package/dist/2026-04/client.d.ts +143 -0
- package/dist/2026-04/index.d.ts +3 -0
- package/dist/2026-04/index.js +7 -0
- package/dist/2026-04/openapi/client/client.gen.d.ts +2 -0
- package/dist/2026-04/openapi/client/index.d.ts +8 -0
- package/dist/2026-04/openapi/client/types.gen.d.ts +117 -0
- package/dist/2026-04/openapi/client/utils.gen.d.ts +33 -0
- package/dist/2026-04/openapi/client.gen.d.ts +12 -0
- package/dist/2026-04/openapi/core/auth.gen.d.ts +18 -0
- package/dist/2026-04/openapi/core/bodySerializer.gen.d.ts +25 -0
- package/dist/2026-04/openapi/core/params.gen.d.ts +43 -0
- package/dist/2026-04/openapi/core/pathSerializer.gen.d.ts +33 -0
- package/dist/2026-04/openapi/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/2026-04/openapi/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/2026-04/openapi/core/types.gen.d.ts +78 -0
- package/dist/2026-04/openapi/core/utils.gen.d.ts +19 -0
- package/dist/2026-04/openapi/index.d.ts +2 -0
- package/dist/2026-04/openapi/sdk.gen.d.ts +279 -0
- package/dist/2026-04/openapi/types.gen.d.ts +4502 -0
- package/dist/2026-04/types.d.ts +57 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +6 -4
- package/dist/unstable/client.d.ts +143 -0
- package/dist/unstable/index.d.ts +3 -0
- package/dist/unstable/index.js +7 -0
- package/dist/unstable/openapi/client/client.gen.d.ts +2 -0
- package/dist/unstable/openapi/client/index.d.ts +8 -0
- package/dist/unstable/openapi/client/types.gen.d.ts +117 -0
- package/dist/unstable/openapi/client/utils.gen.d.ts +33 -0
- package/dist/unstable/openapi/client.gen.d.ts +12 -0
- package/dist/unstable/openapi/core/auth.gen.d.ts +18 -0
- package/dist/unstable/openapi/core/bodySerializer.gen.d.ts +25 -0
- package/dist/unstable/openapi/core/params.gen.d.ts +43 -0
- package/dist/unstable/openapi/core/pathSerializer.gen.d.ts +33 -0
- package/dist/unstable/openapi/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/unstable/openapi/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/unstable/openapi/core/types.gen.d.ts +78 -0
- package/dist/unstable/openapi/core/utils.gen.d.ts +19 -0
- package/dist/unstable/openapi/index.d.ts +2 -0
- package/dist/unstable/openapi/sdk.gen.d.ts +279 -0
- package/dist/unstable/openapi/types.gen.d.ts +4502 -0
- package/dist/unstable/types.d.ts +57 -0
- package/package.json +52 -22
- package/dist/openapi/index.d.ts +0 -2
- /package/dist/{openapi → 2026-01/openapi}/client/client.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/client.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/core/auth.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/core/pathSerializer.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/core/serverSentEvents.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/core/types.gen.d.ts +0 -0
- /package/dist/{openapi → 2026-01/openapi}/core/utils.gen.d.ts +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SwishClient } from "./client";
|
|
2
|
+
import type { Client, ClientOptions, Config } from "./openapi/client";
|
|
3
|
+
import type { PageInfo } from "./openapi/types.gen";
|
|
4
|
+
export interface SwishClientOptions {
|
|
5
|
+
authToken?: string;
|
|
6
|
+
config?: SwishClientConfig;
|
|
7
|
+
requestInterceptor?: Parameters<Client["interceptors"]["request"]["use"]>[0];
|
|
8
|
+
responseInterceptor?: Parameters<Client["interceptors"]["response"]["use"]>[0];
|
|
9
|
+
}
|
|
10
|
+
export type SwishClientConfig = Config<ClientOptions>;
|
|
11
|
+
export type ListItemsResponse = Awaited<ReturnType<SwishClient["items"]["list"]>>;
|
|
12
|
+
export type CreateItemResponse = Awaited<ReturnType<SwishClient["items"]["create"]>>;
|
|
13
|
+
export type DeleteItemsResponse = Awaited<ReturnType<SwishClient["items"]["delete"]>>;
|
|
14
|
+
export type DeleteItemByIdResponse = Awaited<ReturnType<SwishClient["items"]["deleteById"]>>;
|
|
15
|
+
export type FindItemByIdResponse = Awaited<ReturnType<SwishClient["items"]["findById"]>>;
|
|
16
|
+
export type UpdateItemByIdResponse = Awaited<ReturnType<SwishClient["items"]["updateById"]>>;
|
|
17
|
+
export type CountItemsResponse = Awaited<ReturnType<SwishClient["items"]["count"]>>;
|
|
18
|
+
export type ListListsResponse = Awaited<ReturnType<SwishClient["lists"]["list"]>>;
|
|
19
|
+
export type FindListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["findById"]>>;
|
|
20
|
+
export type CreateListResponse = Awaited<ReturnType<SwishClient["lists"]["create"]>>;
|
|
21
|
+
export type DeleteListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["deleteById"]>>;
|
|
22
|
+
export type UpdateListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["updateById"]>>;
|
|
23
|
+
export type OrderItemsResponse = Awaited<ReturnType<SwishClient["lists"]["orderItems"]>>;
|
|
24
|
+
export type AddItemsToListResponse = Awaited<ReturnType<SwishClient["lists"]["addItemsToList"]>>;
|
|
25
|
+
export type RemoveItemFromListResponse = Awaited<ReturnType<SwishClient["lists"]["removeItemFromList"]>>;
|
|
26
|
+
export type SetListsByIdResponse = Awaited<ReturnType<SwishClient["items"]["setListsById"]>>;
|
|
27
|
+
export type CreateProfileTokenResponse = Awaited<ReturnType<SwishClient["profiles"]["createToken"]>>;
|
|
28
|
+
export type IdentifyProfileResponse = Awaited<ReturnType<SwishClient["profiles"]["identify"]>>;
|
|
29
|
+
export interface ApiError {
|
|
30
|
+
error: string;
|
|
31
|
+
message: string;
|
|
32
|
+
requestId: string;
|
|
33
|
+
statusCode: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ApiErrorResponse {
|
|
36
|
+
error: ApiError;
|
|
37
|
+
}
|
|
38
|
+
export type ApiResponse<TData> = {
|
|
39
|
+
data: TData | null;
|
|
40
|
+
} | {
|
|
41
|
+
error: ApiError;
|
|
42
|
+
};
|
|
43
|
+
export type PaginatedApiResponse<TData> = {
|
|
44
|
+
data: TData[];
|
|
45
|
+
pageInfo: PageInfo;
|
|
46
|
+
} | {
|
|
47
|
+
error: ApiError;
|
|
48
|
+
};
|
|
49
|
+
export type ApiRequestResponse<TData> = Promise<{
|
|
50
|
+
data?: {
|
|
51
|
+
data?: TData;
|
|
52
|
+
pageInfo?: PageInfo;
|
|
53
|
+
} | void;
|
|
54
|
+
error?: {
|
|
55
|
+
error: ApiError;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var He=Object.defineProperty;var t=(e,r)=>He(e,"name",{value:r,configurable:!0});var ke={bodySerializer:t(e=>JSON.stringify(e,(r,o)=>typeof o=="bigint"?o.toString():o),"bodySerializer")};var Ae=t(({onRequest:e,onSseError:r,onSseEvent:o,responseTransformer:s,responseValidator:i,sseDefaultRetryDelay:c,sseMaxRetryAttempts:a,sseMaxRetryDelay:l,sseSleepFn:d,url:y,...n})=>{let f,w=d??(C=>new Promise(I=>setTimeout(I,C)));return{stream:t(async function*(){let C=c??3e3,I=0,b=n.signal??new AbortController().signal;for(;!b.aborted;){I++;let B=n.headers instanceof Headers?n.headers:new Headers(n.headers);f!==void 0&&B.set("Last-Event-ID",f);try{let L={redirect:"follow",...n,body:n.serializedBody,headers:B,signal:b},E=new Request(y,L);e&&(E=await e(y,L));let u=await(n.fetch??globalThis.fetch)(E);if(!u.ok)throw new Error(`SSE failed: ${u.status} ${u.statusText}`);if(!u.body)throw new Error("No body in SSE response");let m=u.body.pipeThrough(new TextDecoderStream).getReader(),x="",ge=t(()=>{try{m.cancel()}catch{}},"abortHandler");b.addEventListener("abort",ge);try{for(;;){let{done:je,value:Ge}=await m.read();if(je)break;x+=Ge,x=x.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`);let we=x.split(`
|
|
2
4
|
|
|
3
|
-
`);
|
|
4
|
-
`),A=[],
|
|
5
|
-
`);try{E=JSON.parse(I),G=!0}catch{E=I}}G&&(s&&await s(E),o&&(E=await o(E))),t==null||t({data:E,event:V,id:u,retry:y}),A.length&&(yield E)}}}finally{T.removeEventListener("abort",M),g.releaseLock()}break}catch(S){if(r==null||r(S),l!==void 0&&C>=l)break;let O=Math.min(y*2**(C-1),a??3e4);await L(O)}}},"createStream")()}},"createSseClient");var ve=n(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),je=n(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Ue=n(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),B=n(({allowReserved:e,explode:r,name:t,style:o,value:s})=>{if(!r){let a=(e?s:s.map(d=>encodeURIComponent(d))).join(je(o));switch(o){case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;case"simple":return a;default:return`${t}=${a}`}}let p=ve(o),l=s.map(a=>o==="label"||o==="simple"?e?a:encodeURIComponent(a):w({allowReserved:e,name:t,value:a})).join(p);return o==="label"||o==="matrix"?p+l:l},"serializeArrayParam"),w=n(({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)}`},"serializePrimitiveParam"),P=n(({allowReserved:e,explode:r,name:t,style:o,value:s,valueOnly:p})=>{if(s instanceof Date)return p?s.toISOString():`${t}=${s.toISOString()}`;if(o!=="deepObject"&&!r){let d=[];Object.entries(s).forEach(([i,u])=>{d=[...d,i,e?u:encodeURIComponent(u)]});let h=d.join(",");switch(o){case"form":return`${t}=${h}`;case"label":return`.${h}`;case"matrix":return`;${t}=${h}`;default:return h}}let l=Ue(o),a=Object.entries(s).map(([d,h])=>w({allowReserved:e,name:o==="deepObject"?`${t}[${d}]`:d,value:h})).join(l);return o==="label"||o==="matrix"?l+a:a},"serializeObjectParam");var $e=/\{[^{}]+\}/g,Ne=n(({path:e,url:r})=>{let t=r,o=r.match($e);if(o)for(let s of o){let p=!1,l=s.substring(1,s.length-1),a="simple";l.endsWith("*")&&(p=!0,l=l.substring(0,l.length-1)),l.startsWith(".")?(l=l.substring(1),a="label"):l.startsWith(";")&&(l=l.substring(1),a="matrix");let d=e[l];if(d==null)continue;if(Array.isArray(d)){t=t.replace(s,B({explode:p,name:l,style:a,value:d}));continue}if(typeof d=="object"){t=t.replace(s,P({explode:p,name:l,style:a,value:d,valueOnly:!0}));continue}if(a==="matrix"){t=t.replace(s,`;${w({name:l,value:d})}`);continue}let h=encodeURIComponent(a==="label"?`.${d}`:d);t=t.replace(s,h)}return t},"defaultPathSerializer"),_=n(({baseUrl:e,path:r,query:t,querySerializer:o,url:s})=>{let p=s.startsWith("/")?s:`/${s}`,l=(e??"")+p;r&&(l=Ne({path:r,url:l}));let a=t?o(t):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(l+=`?${a}`),l},"getUrl");function K(e){let r=e.body!==void 0;if(r&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(r)return e.body}n(K,"getValidRequestBody");var X=n(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},"getAuthToken");var Y=n(({allowReserved:e,array:r,object:t}={})=>n(s=>{let p=[];if(s&&typeof s=="object")for(let l in s){let a=s[l];if(a!=null)if(Array.isArray(a)){let d=B({allowReserved:e,explode:!0,name:l,style:"form",value:a,...r});d&&p.push(d)}else if(typeof a=="object"){let d=P({allowReserved:e,explode:!0,name:l,style:"deepObject",value:a,...t});d&&p.push(d)}else{let d=w({allowReserved:e,name:l,value:a});d&&p.push(d)}}return p.join("&")},"querySerializer"),"createQuerySerializer"),Z=n(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(o=>r.startsWith(o)))return"blob";if(r.startsWith("text/"))return"text"}},"getParseAs"),He=n((e,r)=>{var t,o;return r?!!(e.headers.has(r)||(t=e.query)!=null&&t[r]||(o=e.headers.get("Cookie"))!=null&&o.includes(`${r}=`)):!1},"checkForExistence"),ee=n(async({security:e,...r})=>{for(let t of e){if(He(r,t.name))continue;let o=await X(t,r.auth);if(!o)continue;let s=t.name??"Authorization";switch(t.in){case"query":r.query||(r.query={}),r.query[s]=o;break;case"cookie":r.headers.append("Cookie",`${s}=${o}`);break;case"header":default:r.headers.set(s,o);break}}},"setAuthParams"),j=n(e=>_({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Y(e.querySerializer),url:e.url}),"buildUrl"),U=n((e,r)=>{var o;let t={...e,...r};return(o=t.baseUrl)!=null&&o.endsWith("/")&&(t.baseUrl=t.baseUrl.substring(0,t.baseUrl.length-1)),t.headers=F(e.headers,r.headers),t},"mergeConfigs"),Me=n(e=>{let r=[];return e.forEach((t,o)=>{r.push([o,t])}),r},"headersEntries"),F=n((...e)=>{let r=new Headers;for(let t of e){if(!t)continue;let o=t instanceof Headers?Me(t):Object.entries(t);for(let[s,p]of o)if(p===null)r.delete(s);else if(Array.isArray(p))for(let l of p)r.append(s,l);else p!==void 0&&r.set(s,typeof p=="object"?JSON.stringify(p):p)}return r},"mergeHeaders"),$=class ${constructor(){this.fns=[]}clear(){this.fns=[]}eject(r){let t=this.getInterceptorIndex(r);this.fns[t]&&(this.fns[t]=null)}exists(r){let t=this.getInterceptorIndex(r);return!!this.fns[t]}getInterceptorIndex(r){return typeof r=="number"?this.fns[r]?r:-1:this.fns.indexOf(r)}update(r,t){let o=this.getInterceptorIndex(r);return this.fns[o]?(this.fns[o]=t,r):!1}use(r){return this.fns.push(r),this.fns.length-1}};n($,"Interceptors");var k=$,re=n(()=>({error:new k,request:new k,response:new k}),"createInterceptors"),We=Y({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Ve={"Content-Type":"application/json"},R=n((e={})=>({...v,headers:Ve,parseAs:"auto",querySerializer:We,...e}),"createConfig");var x=n((e={})=>{let r=U(R(),e),t=n(()=>({...r}),"getConfig"),o=n(h=>(r=U(r,h),t()),"setConfig"),s=re(),p=n(async h=>{let i={...r,...h,fetch:h.fetch??r.fetch??globalThis.fetch,headers:F(r.headers,h.headers),serializedBody:void 0};i.security&&await ee({...i,security:i.security}),i.requestValidator&&await i.requestValidator(i),i.body!==void 0&&i.bodySerializer&&(i.serializedBody=i.bodySerializer(i.body)),(i.body===void 0||i.serializedBody==="")&&i.headers.delete("Content-Type");let u=j(i);return{opts:i,url:u}},"beforeRequest"),l=n(async h=>{let{opts:i,url:u}=await p(h),L={redirect:"follow",...i,body:K(i)},b=new Request(u,L);for(let f of s.request.fns)f&&(b=await f(b,i));let q=i.fetch,y=await q(b);for(let f of s.response.fns)f&&(y=await f(y,b,i));let C={request:b,response:y};if(y.ok){let f=(i.parseAs==="auto"?Z(y.headers.get("Content-Type")):i.parseAs)??"json";if(y.status===204||y.headers.get("Content-Length")==="0"){let g;switch(f){case"arrayBuffer":case"blob":case"text":g=await y[f]();break;case"formData":g=new FormData;break;case"stream":g=y.body;break;case"json":default:g={};break}return i.responseStyle==="data"?g:{data:g,...C}}let m;switch(f){case"arrayBuffer":case"blob":case"formData":case"json":case"text":m=await y[f]();break;case"stream":return i.responseStyle==="data"?y.body:{data:y.body,...C}}return f==="json"&&(i.responseValidator&&await i.responseValidator(m),i.responseTransformer&&(m=await i.responseTransformer(m))),i.responseStyle==="data"?m:{data:m,...C}}let T=await y.text(),D;try{D=JSON.parse(T)}catch{}let S=D??T,O=S;for(let f of s.error.fns)f&&(O=await f(S,y,b,i));if(O=O||{},i.throwOnError)throw O;return i.responseStyle==="data"?void 0:{error:O,...C}},"request"),a=n(h=>i=>l({...i,method:h}),"makeMethodFn"),d=n(h=>async i=>{let{opts:u,url:L}=await p(i);return J({...u,body:u.body,headers:u.headers,method:h,onRequest:n(async(b,q)=>{let y=new Request(b,q);for(let C of s.request.fns)C&&(y=await C(y,u));return y},"onRequest"),url:L})},"makeSseFn");return{buildUrl:j,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:t,head:a("HEAD"),interceptors:s,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:l,setConfig:o,sse:{connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),head:d("HEAD"),options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),trace:d("TRACE")},trace:a("TRACE")}},"createClient");var c=x(R({baseUrl:"https://swish.app/api/2026-01"}));var te=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),ne=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),oe=n(e=>(e.client??c).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),se=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),ie=n(e=>(e.client??c).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),ae=n(e=>(e.client??c).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),le=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),de=n(e=>(e.client??c).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),pe=n(e=>(e.client??c).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),ce=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),ye=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),he=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),ue=n(e=>(e.client??c).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),fe=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),Ce=n(e=>(e.client??c).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),me=n(e=>(e.client??c).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),Ie=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),Oe=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),ge=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile");var be=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),Re=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),Te=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),Se=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/tracking",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerTrack"),Ee=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),we=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),xe=n(e=>(e.client??c).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...e}),"sharedListsControllerSave"),Le=n(e=>(e.client??c).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...e}),"sharedListsControllerDeleteById"),De=n(e=>(e.client??c).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...e}),"sharedListsControllerFindById"),ke=n(e=>((e==null?void 0:e.client)??c).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll");var Qe="2026-01",zr=n(e=>new N(e),"createApiClient"),H=class H{constructor(r){this.version=Qe;this.items={list:n(r=>this.handlePaginatedRequest(ce({query:r,client:this.directClient})),"list"),create:n(r=>this.handleRequest(ye({body:r,client:this.directClient})),"create"),delete:n(r=>this.handleRequest(pe({body:{itemIds:r},client:this.directClient})),"delete"),findById:n(r=>this.handleRequest(fe({path:{itemId:r},client:this.directClient})),"findById"),updateById:n((r,t)=>this.handleRequest(Ce({body:t,path:{itemId:r},client:this.directClient})),"updateById"),deleteById:n(r=>this.handleRequest(ue({path:{itemId:r},client:this.directClient})),"deleteById"),setListsById:n((r,t)=>this.handleRequest(me({body:{listIds:t},path:{itemId:r},client:this.directClient})),"setListsById"),count:n(()=>this.handleRequest(he({client:this.directClient})),"count")};this.lists={list:n(r=>this.handlePaginatedRequest(te({query:r,client:this.directClient})),"list"),create:n(r=>this.handleRequest(ne({body:r,client:this.directClient})),"create"),findById:n(r=>this.handleRequest(se({path:{listId:r},client:this.directClient})),"findById"),updateById:n((r,t)=>this.handleRequest(ie({body:t,path:{listId:r},client:this.directClient})),"updateById"),deleteById:n(r=>this.handleRequest(oe({path:{listId:r},client:this.directClient})),"deleteById"),orderItems:n((r,t)=>this.handleRequest(ae({body:{itemIds:t},path:{listId:r},client:this.directClient})),"orderItems"),addItemsToList:n((r,t)=>this.handleRequest(le({body:{itemIds:t},path:{listId:r},client:this.directClient})),"addItemsToList"),removeItemFromList:n((r,t)=>this.handleRequest(de({path:{listId:r,itemId:t},client:this.directClient})),"removeItemFromList")};this.profiles={createToken:n((r={})=>this.handleRequest(Oe({body:r,client:this.proxyClient??this.directClient})),"createToken"),identify:n(r=>this.handleRequest(Ie({body:r,client:this.directClient})),"identify"),getProfile:n(()=>this.handleRequest(ge({client:this.directClient})),"getProfile")};this.orders={list:n(r=>this.handlePaginatedRequest(Ee({query:r,client:this.directClient})),"list"),findById:n(r=>this.handleRequest(we({path:{orderId:r},client:this.directClient})),"findById")};this.sharedLists={list:n(r=>this.handlePaginatedRequest(ke({query:r,client:this.directClient})),"list"),save:n(r=>this.handleRequest(xe({path:{listId:r},client:this.directClient})),"save"),findById:n(r=>this.handleRequest(De({path:{listId:r},client:this.directClient})),"findById"),deleteById:n(r=>this.handleRequest(Le({path:{listId:r},client:this.directClient})),"deleteById")};this.analytics={savedItems:n(r=>this.handleRequest(be({query:r,client:this.directClient})),"savedItems"),sessions:n(r=>this.handleRequest(Re({query:r,client:this.directClient})),"sessions"),newLists:n(r=>this.handleRequest(Te({query:r,client:this.directClient})),"newLists")};this.tracking={track:n((r,t)=>this.handleRequest(Se({body:r,headers:t,client:this.directClient})),"track")};this.handleRequest=n(async r=>{let{data:t,error:o}=await r;return o!=null&&o.error?{error:o.error}:{data:t==null?void 0:t.data}},"handleRequest");this.handlePaginatedRequest=n(async r=>{var s;let{data:t,error:o}=await r;return o!=null&&o.error?{error:o.error}:{data:(t==null?void 0:t.data)??[],pageInfo:(t==null?void 0:t.pageInfo)??{next:null,previous:null,totalCount:((s=t==null?void 0:t.data)==null?void 0:s.length)??0}}},"handlePaginatedRequest");var t,o,s,p,l;(t=r.config)!=null&&t.version&&(this.version=r.config.version),this.directClient=x(R({baseUrl:`https://swish.app/api/${this.version}`,...r.config})),(o=r.config)!=null&&o.authProxy&&(this.proxyClient=x(R({...r.config,baseUrl:r.config.authProxy}))),r.authToken&&(this.authToken=r.authToken),r.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(r.requestInterceptor),this.directClient.interceptors.request.use(r.requestInterceptor)),r.responseInterceptor&&((p=this.proxyClient)==null||p.interceptors.response.use(r.responseInterceptor),this.directClient.interceptors.response.use(r.responseInterceptor)),(l=this.proxyClient)==null||l.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(r){this.authToken=r}proxyRequestInterceptor(r){return this.version&&r.headers.set("Swish-Api-Version",this.version),r}directRequestInterceptor(r){return this.authToken&&r.headers.set("Authorization",`Bearer ${this.authToken}`),r}};n(H,"SwishClient");var N=H;export{zr as createApiClient,Qe as defaultApiVersion};
|
|
5
|
+
`);x=we.pop()??"";for(let Me of we){let $e=Me.split(`
|
|
6
|
+
`),A=[],Be;for(let O of $e)if(O.startsWith("data:"))A.push(O.replace(/^data:\s*/,""));else if(O.startsWith("event:"))Be=O.replace(/^event:\s*/,"");else if(O.startsWith("id:"))f=O.replace(/^id:\s*/,"");else if(O.startsWith("retry:")){let Fe=Number.parseInt(O.replace(/^retry:\s*/,""),10);Number.isNaN(Fe)||(C=Fe)}let D,xe=!1;if(A.length){let O=A.join(`
|
|
7
|
+
`);try{D=JSON.parse(O),xe=!0}catch{D=O}}xe&&(i&&await i(D),s&&(D=await s(D))),o==null||o({data:D,event:Be,id:f,retry:C}),A.length&&(yield D)}}}finally{b.removeEventListener("abort",ge),m.releaseLock()}break}catch(L){if(r==null||r(L),a!==void 0&&I>=a)break;let E=Math.min(C*2**(I-1),l??3e4);await w(E)}}},"createStream")()}},"createSseClient");var Ve=t(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Qe=t(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),We=t(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),P=t(({allowReserved:e,explode:r,name:o,style:s,value:i})=>{if(!r){let l=(e?i:i.map(d=>encodeURIComponent(d))).join(Qe(s));switch(s){case"label":return`.${l}`;case"matrix":return`;${o}=${l}`;case"simple":return l;default:return`${o}=${l}`}}let c=Ve(s),a=i.map(l=>s==="label"||s==="simple"?e?l:encodeURIComponent(l):T({allowReserved:e,name:o,value:l})).join(c);return s==="label"||s==="matrix"?c+a:a},"serializeArrayParam"),T=t(({allowReserved:e,name:r,value:o})=>{if(o==null)return"";if(typeof o=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${e?o:encodeURIComponent(o)}`},"serializePrimitiveParam"),q=t(({allowReserved:e,explode:r,name:o,style:s,value:i,valueOnly:c})=>{if(i instanceof Date)return c?i.toISOString():`${o}=${i.toISOString()}`;if(s!=="deepObject"&&!r){let d=[];Object.entries(i).forEach(([n,f])=>{d=[...d,n,e?f:encodeURIComponent(f)]});let y=d.join(",");switch(s){case"form":return`${o}=${y}`;case"label":return`.${y}`;case"matrix":return`;${o}=${y}`;default:return y}}let a=We(s),l=Object.entries(i).map(([d,y])=>T({allowReserved:e,name:s==="deepObject"?`${o}[${d}]`:d,value:y})).join(a);return s==="label"||s==="matrix"?a+l:l},"serializeObjectParam");var Je=/\{[^{}]+\}/g,Ke=t(({path:e,url:r})=>{let o=r,s=r.match(Je);if(s)for(let i of s){let c=!1,a=i.substring(1,i.length-1),l="simple";a.endsWith("*")&&(c=!0,a=a.substring(0,a.length-1)),a.startsWith(".")?(a=a.substring(1),l="label"):a.startsWith(";")&&(a=a.substring(1),l="matrix");let d=e[a];if(d==null)continue;if(Array.isArray(d)){o=o.replace(i,P({explode:c,name:a,style:l,value:d}));continue}if(typeof d=="object"){o=o.replace(i,q({explode:c,name:a,style:l,value:d,valueOnly:!0}));continue}if(l==="matrix"){o=o.replace(i,`;${T({name:a,value:d})}`);continue}let y=encodeURIComponent(l==="label"?`.${d}`:d);o=o.replace(i,y)}return o},"defaultPathSerializer"),Pe=t(({baseUrl:e,path:r,query:o,querySerializer:s,url:i})=>{let c=i.startsWith("/")?i:`/${i}`,a=(e??"")+c;r&&(a=Ke({path:r,url:a}));let l=o?s(o):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(a+=`?${l}`),a},"getUrl");function v(e){let r=e.body!==void 0;if(r&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(r)return e.body}t(v,"getValidRequestBody");var qe=t(async(e,r)=>{let o=typeof r=="function"?await r(e):r;if(o)return e.scheme==="bearer"?`Bearer ${o}`:e.scheme==="basic"?`Basic ${btoa(o)}`:o},"getAuthToken");var Ue=t(({parameters:e={},...r}={})=>t(s=>{let i=[];if(s&&typeof s=="object")for(let c in s){let a=s[c];if(a==null)continue;let l=e[c]||r;if(Array.isArray(a)){let d=P({allowReserved:l.allowReserved,explode:!0,name:c,style:"form",value:a,...l.array});d&&i.push(d)}else if(typeof a=="object"){let d=q({allowReserved:l.allowReserved,explode:!0,name:c,style:"deepObject",value:a,...l.object});d&&i.push(d)}else{let d=T({allowReserved:l.allowReserved,name:c,value:a});d&&i.push(d)}}return i.join("&")},"querySerializer"),"createQuerySerializer"),ve=t(e=>{var o;if(!e)return"stream";let r=(o=e.split(";")[0])==null?void 0:o.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"}},"getParseAs"),_e=t((e,r)=>{var o,s;return r?!!(e.headers.has(r)||(o=e.query)!=null&&o[r]||(s=e.headers.get("Cookie"))!=null&&s.includes(`${r}=`)):!1},"checkForExistence"),ze=t(async({security:e,...r})=>{for(let o of e){if(_e(r,o.name))continue;let s=await qe(o,r.auth);if(!s)continue;let i=o.name??"Authorization";switch(o.in){case"query":r.query||(r.query={}),r.query[i]=s;break;case"cookie":r.headers.append("Cookie",`${i}=${s}`);break;default:r.headers.set(i,s);break}}},"setAuthParams"),z=t(e=>Pe({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Ue(e.querySerializer),url:e.url}),"buildUrl"),N=t((e,r)=>{var s;let o={...e,...r};return(s=o.baseUrl)!=null&&s.endsWith("/")&&(o.baseUrl=o.baseUrl.substring(0,o.baseUrl.length-1)),o.headers=U(e.headers,r.headers),o},"mergeConfigs"),Xe=t(e=>{let r=[];return e.forEach((o,s)=>{r.push([s,o])}),r},"headersEntries"),U=t((...e)=>{let r=new Headers;for(let o of e){if(!o)continue;let s=o instanceof Headers?Xe(o):Object.entries(o);for(let[i,c]of s)if(c===null)r.delete(i);else if(Array.isArray(c))for(let a of c)r.append(i,a);else c!==void 0&&r.set(i,typeof c=="object"?JSON.stringify(c):c)}return r},"mergeHeaders"),j=class j{constructor(){this.fns=[]}clear(){this.fns=[]}eject(r){let o=this.getInterceptorIndex(r);this.fns[o]&&(this.fns[o]=null)}exists(r){let o=this.getInterceptorIndex(r);return!!this.fns[o]}getInterceptorIndex(r){return typeof r=="number"?this.fns[r]?r:-1:this.fns.indexOf(r)}update(r,o){let s=this.getInterceptorIndex(r);return this.fns[s]?(this.fns[s]=o,r):!1}use(r){return this.fns.push(r),this.fns.length-1}};t(j,"Interceptors");var F=j,Ne=t(()=>({error:new F,request:new F,response:new F}),"createInterceptors"),Ye=Ue({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Ze={"Content-Type":"application/json"},S=t((e={})=>({...ke,headers:Ze,parseAs:"auto",querySerializer:Ye,...e}),"createConfig");var g=t((e={})=>{let r=N(S(),e),o=t(()=>({...r}),"getConfig"),s=t(y=>(r=N(r,y),o()),"setConfig"),i=Ne(),c=t(async y=>{let n={...r,...y,fetch:y.fetch??r.fetch??globalThis.fetch,headers:U(r.headers,y.headers),serializedBody:void 0};n.security&&await ze({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody==="")&&n.headers.delete("Content-Type");let f=z(n);return{opts:n,url:f}},"beforeRequest"),a=t(async y=>{let{opts:n,url:f}=await c(y),w={redirect:"follow",...n,body:v(n)},R=new Request(f,w);for(let h of i.request.fns)h&&(R=await h(R,n));let k=n.fetch,C;try{C=await k(R)}catch(h){let u=h;for(let m of i.error.fns)m&&(u=await m(h,void 0,R,n));if(u=u||{},n.throwOnError)throw u;return n.responseStyle==="data"?void 0:{error:u,request:R,response:void 0}}for(let h of i.response.fns)h&&(C=await h(C,R,n));let I={request:R,response:C};if(C.ok){let h=(n.parseAs==="auto"?ve(C.headers.get("Content-Type")):n.parseAs)??"json";if(C.status===204||C.headers.get("Content-Length")==="0"){let m;switch(h){case"arrayBuffer":case"blob":case"text":m=await C[h]();break;case"formData":m=new FormData;break;case"stream":m=C.body;break;default:m={};break}return n.responseStyle==="data"?m:{data:m,...I}}let u;switch(h){case"arrayBuffer":case"blob":case"formData":case"text":u=await C[h]();break;case"json":{let m=await C.text();u=m?JSON.parse(m):{};break}case"stream":return n.responseStyle==="data"?C.body:{data:C.body,...I}}return h==="json"&&(n.responseValidator&&await n.responseValidator(u),n.responseTransformer&&(u=await n.responseTransformer(u))),n.responseStyle==="data"?u:{data:u,...I}}let b=await C.text(),B;try{B=JSON.parse(b)}catch{}let L=B??b,E=L;for(let h of i.error.fns)h&&(E=await h(L,C,R,n));if(E=E||{},n.throwOnError)throw E;return n.responseStyle==="data"?void 0:{error:E,...I}},"request"),l=t(y=>n=>a({...n,method:y}),"makeMethodFn"),d=t(y=>async n=>{let{opts:f,url:w}=await c(n);return Ae({...f,body:f.body,headers:f.headers,method:y,onRequest:t(async(R,k)=>{let C=new Request(R,k);for(let I of i.request.fns)I&&(C=await I(C,f));return C},"onRequest"),serializedBody:v(f),url:w})},"makeSseFn");return{buildUrl:z,connect:l("CONNECT"),delete:l("DELETE"),get:l("GET"),getConfig:o,head:l("HEAD"),interceptors:i,options:l("OPTIONS"),patch:l("PATCH"),post:l("POST"),put:l("PUT"),request:a,setConfig:s,sse:{connect:d("CONNECT"),delete:d("DELETE"),get:d("GET"),head:d("HEAD"),options:d("OPTIONS"),patch:d("PATCH"),post:d("POST"),put:d("PUT"),trace:d("TRACE")},trace:l("TRACE")}},"createClient");var p=g(S({baseUrl:"https://swish.app/api/2026-01"}));var G=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),M=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),$=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),H=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),V=t(e=>(e.client??p).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Q=t(e=>(e.client??p).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),W=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),J=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),K=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),_=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),X=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Y=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Z=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),ee=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),re=t(e=>(e.client??p).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),te=t(e=>(e.client??p).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),oe=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),se=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),ne=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile");var ie=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),le=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),ae=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),de=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),pe=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),ce=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),Ce=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}/save",...e}),"sharedListsControllerSave"),ye=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...e}),"sharedListsControllerDeleteById"),ue=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{listId}",...e}),"sharedListsControllerFindById"),he=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),fe=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),me=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Ie=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Re=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Oe=t(e=>((e==null?void 0:e.client)??p).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),Ee=t(e=>(e.client??p).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Se=t(e=>(e.client??p).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),be=t(e=>(e.client??p).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),Le=t(e=>(e.client??p).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate");var rr="2026-01",vr=t(e=>new De(e),"createApiClient"),Te=class Te{constructor(r){this.version=rr;this.items={list:t(r=>this.handlePaginatedRequest(_({query:r,client:this.directClient})),"list"),create:t(r=>this.handleRequest(X({body:r,client:this.directClient})),"create"),delete:t(r=>this.handleRequest(K({body:{itemIds:r},client:this.directClient})),"delete"),findById:t(r=>this.handleRequest(ee({path:{itemId:r},client:this.directClient})),"findById"),updateById:t((r,o)=>this.handleRequest(re({body:o,path:{itemId:r},client:this.directClient})),"updateById"),deleteById:t(r=>this.handleRequest(Z({path:{itemId:r},client:this.directClient})),"deleteById"),setListsById:t((r,o)=>this.handleRequest(te({body:{listIds:o},path:{itemId:r},client:this.directClient})),"setListsById"),count:t(()=>this.handleRequest(Y({client:this.directClient})),"count")};this.lists={list:t(r=>this.handlePaginatedRequest(G({query:r,client:this.directClient})),"list"),create:t(r=>this.handleRequest(M({body:r,client:this.directClient})),"create"),findById:t(r=>this.handleRequest(H({path:{listId:r},client:this.directClient})),"findById"),updateById:t((r,o)=>this.handleRequest(V({body:o,path:{listId:r},client:this.directClient})),"updateById"),deleteById:t(r=>this.handleRequest($({path:{listId:r},client:this.directClient})),"deleteById"),orderItems:t((r,o)=>this.handleRequest(Q({body:{itemIds:o},path:{listId:r},client:this.directClient})),"orderItems"),addItemsToList:t((r,o)=>this.handleRequest(W({body:{itemIds:o},path:{listId:r},client:this.directClient})),"addItemsToList"),removeItemFromList:t((r,o)=>this.handleRequest(J({path:{listId:r,itemId:o},client:this.directClient})),"removeItemFromList")};this.profiles={createToken:t((r={})=>this.handleRequest(se({body:r,client:this.proxyClient??this.directClient})),"createToken"),identify:t(r=>this.handleRequest(oe({body:r,client:this.directClient})),"identify"),getProfile:t(()=>this.handleRequest(ne({client:this.directClient})),"getProfile")};this.orders={list:t(r=>this.handlePaginatedRequest(pe({query:r,client:this.directClient})),"list"),findById:t(r=>this.handleRequest(ce({path:{orderId:r},client:this.directClient})),"findById")};this.sharedLists={list:t(r=>this.handlePaginatedRequest(he({query:r,client:this.directClient})),"list"),save:t(r=>this.handleRequest(Ce({path:{listId:r},client:this.directClient})),"save"),findById:t(r=>this.handleRequest(ue({path:{listId:r},client:this.directClient})),"findById"),deleteById:t(r=>this.handleRequest(ye({path:{listId:r},client:this.directClient})),"deleteById")};this.analytics={savedItems:t(r=>this.handleRequest(ie({query:r,client:this.directClient})),"savedItems"),sessions:t(r=>this.handleRequest(le({query:r,client:this.directClient})),"sessions"),newLists:t(r=>this.handleRequest(ae({query:r,client:this.directClient})),"newLists")};this.tracking={track:t(r=>this.handleRequest(de({body:r,client:this.directClient})),"track")};this.notifications={list:t(r=>this.handlePaginatedRequest(fe({query:r,client:this.directClient})),"list"),getUnreadCount:t(()=>this.handleRequest(me({client:this.directClient})),"getUnreadCount"),markAsRead:t(r=>this.handleRequest(Ie({body:{notificationIds:r},client:this.directClient})),"markAsRead"),deleteById:t(r=>this.handleRequest(Re({path:{id:r},client:this.directClient})),"deleteById")};this.subscriptions={list:t(r=>this.handlePaginatedRequest(Oe({query:r,client:this.directClient})),"list"),create:t(r=>this.handleRequest(Ee({body:r,client:this.directClient})),"create"),findById:t(r=>this.handleRequest(be({path:{id:r},client:this.directClient})),"findById"),updateById:t((r,o)=>this.handleRequest(Le({body:o,path:{id:r},client:this.directClient})),"updateById"),deleteById:t(r=>this.handleRequest(Se({path:{id:r},client:this.directClient})),"deleteById")};this.handleRequest=t(async r=>{let{data:o,error:s}=await r;return s!=null&&s.error?{error:s.error}:{data:o==null?void 0:o.data}},"handleRequest");this.handlePaginatedRequest=t(async r=>{var i;let{data:o,error:s}=await r;return s!=null&&s.error?{error:s.error}:{data:(o==null?void 0:o.data)??[],pageInfo:(o==null?void 0:o.pageInfo)??{next:null,previous:null,totalCount:((i=o==null?void 0:o.data)==null?void 0:i.length)??0}}},"handlePaginatedRequest");var o,s,i,c;this.directClient=g(S({baseUrl:`https://swish.app/api/${this.version}`,...r.config})),(o=r.config)!=null&&o.authProxy&&(this.proxyClient=g(S({...r.config,baseUrl:r.config.authProxy}))),r.authToken&&(this.authToken=r.authToken),r.requestInterceptor&&((s=this.proxyClient)==null||s.interceptors.request.use(r.requestInterceptor),this.directClient.interceptors.request.use(r.requestInterceptor)),r.responseInterceptor&&((i=this.proxyClient)==null||i.interceptors.response.use(r.responseInterceptor),this.directClient.interceptors.response.use(r.responseInterceptor)),(c=this.proxyClient)==null||c.interceptors.request.use(this.proxyRequestInterceptor.bind(this)),this.directClient.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(r){this.authToken=r}proxyRequestInterceptor(r){return this.version&&r.headers.set("Swish-Api-Version",this.version),r}directRequestInterceptor(r){return this.authToken&&r.headers.set("Authorization",`Bearer ${this.authToken}`),r}};t(Te,"SwishClient");var De=Te;export{rr as apiVersion,vr as createApiClient};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { SwishClientOptions, ApiResponse, PaginatedApiResponse } from "./types";
|
|
2
|
+
import type * as types from "./openapi/types.gen";
|
|
3
|
+
export declare const apiVersion = "unstable";
|
|
4
|
+
export declare const createApiClient: (options: SwishClientOptions) => SwishClient;
|
|
5
|
+
export type { SwishClient };
|
|
6
|
+
declare class SwishClient {
|
|
7
|
+
private authToken?;
|
|
8
|
+
private readonly version;
|
|
9
|
+
private readonly client;
|
|
10
|
+
constructor(options: SwishClientOptions);
|
|
11
|
+
setAuthToken(authToken: string): void;
|
|
12
|
+
directRequestInterceptor(request: Request): Request;
|
|
13
|
+
readonly items: {
|
|
14
|
+
list: (query?: types.ItemControllerFindData["query"]) => Promise<PaginatedApiResponse<types.Item>>;
|
|
15
|
+
create: (items: types.CreateItem) => Promise<ApiResponse<{
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
} & types.Item>>;
|
|
18
|
+
delete: (itemIds: types.DeleteItems["itemIds"]) => Promise<ApiResponse<{
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
} & types.Item[]>>;
|
|
21
|
+
findById: (itemId: string) => Promise<ApiResponse<{
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
} & types.ItemDetail>>;
|
|
24
|
+
updateById: (itemId: string, body: types.UpdateItem) => Promise<ApiResponse<{
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
} & types.Item>>;
|
|
27
|
+
deleteById: (itemId: string) => Promise<ApiResponse<{
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
} & types.Item>>;
|
|
30
|
+
setListsById: (itemId: string, listIds: types.SetItemLists["listIds"]) => Promise<ApiResponse<{
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
} & types.ItemDetail>>;
|
|
33
|
+
count: () => Promise<ApiResponse<{
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
} & types.ItemCount>>;
|
|
36
|
+
};
|
|
37
|
+
readonly lists: {
|
|
38
|
+
list: (query?: types.ListControllerFindData["query"]) => Promise<PaginatedApiResponse<types.ListDetail>>;
|
|
39
|
+
create: (list: types.CreateList) => Promise<ApiResponse<{
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
} & types.List>>;
|
|
42
|
+
findById: (listId: string) => Promise<ApiResponse<{
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
} & types.ListDetail>>;
|
|
45
|
+
updateById: (listId: string, body: types.UpdateList) => Promise<ApiResponse<{
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
} & types.List>>;
|
|
48
|
+
deleteById: (listId: string) => Promise<ApiResponse<{
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
} & types.List>>;
|
|
51
|
+
orderItems: (listId: string, itemIds: types.SetListItemsOrder["itemIds"]) => Promise<ApiResponse<{
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
} & types.List>>;
|
|
54
|
+
addItemsToList: (listId: string, itemIds: types.AddItemsToList["itemIds"]) => Promise<ApiResponse<{
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
} & types.ListDetail>>;
|
|
57
|
+
removeItemFromList: (listId: string, itemId: string) => Promise<ApiResponse<unknown>>;
|
|
58
|
+
};
|
|
59
|
+
readonly profiles: {
|
|
60
|
+
createToken: (body?: types.CreateProfileToken) => Promise<ApiResponse<{
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
} & types.CreateProfileTokenResult>>;
|
|
63
|
+
identify: (body: types.IdentifyProfile) => Promise<ApiResponse<unknown>>;
|
|
64
|
+
getProfile: () => Promise<ApiResponse<{
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
} & types.Profile>>;
|
|
67
|
+
updateProfile: (body: types.UpdateProfile) => Promise<ApiResponse<{
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
} & types.Profile>>;
|
|
70
|
+
};
|
|
71
|
+
readonly orders: {
|
|
72
|
+
list: (query?: types.OrdersControllerFindData["query"]) => Promise<PaginatedApiResponse<types.Order>>;
|
|
73
|
+
findById: (orderId: number) => Promise<ApiResponse<{
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
} & types.OrderDetail>>;
|
|
76
|
+
};
|
|
77
|
+
readonly sharedLists: {
|
|
78
|
+
list: (query?: types.SharedListsControllerFindAllData["query"]) => Promise<PaginatedApiResponse<types.ListDetail>>;
|
|
79
|
+
save: (listId: string) => Promise<ApiResponse<{
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
} & types.ListDetail>>;
|
|
82
|
+
findById: (sharedListId: string) => Promise<ApiResponse<{
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
} & types.ListDetail>>;
|
|
85
|
+
deleteById: (sharedListId: string) => Promise<ApiResponse<unknown>>;
|
|
86
|
+
findItems: (sharedListId: string, query?: types.SharedListsControllerFindItemsData["query"]) => Promise<PaginatedApiResponse<types.Item>>;
|
|
87
|
+
};
|
|
88
|
+
readonly analytics: {
|
|
89
|
+
savedItems: (query: types.AnalyticsControllerLoadSavedItemsData["query"]) => Promise<ApiResponse<{
|
|
90
|
+
[key: string]: unknown;
|
|
91
|
+
} & types.Analytics[]>>;
|
|
92
|
+
sessions: (query: types.AnalyticsControllerLoadSessionsData["query"]) => Promise<ApiResponse<{
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
} & types.Analytics[]>>;
|
|
95
|
+
newLists: (query: types.AnalyticsControllerLoadNewListsData["query"]) => Promise<ApiResponse<{
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
} & types.Analytics[]>>;
|
|
98
|
+
};
|
|
99
|
+
readonly tracking: {
|
|
100
|
+
track: (body: types.TrackingEventRequest) => Promise<ApiResponse<unknown>>;
|
|
101
|
+
};
|
|
102
|
+
readonly notifications: {
|
|
103
|
+
list: (query?: types.NotificationsControllerFindData["query"]) => Promise<PaginatedApiResponse<types.Notification>>;
|
|
104
|
+
getUnreadCount: () => Promise<ApiResponse<{
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
} & types.NotificationUnreadCount>>;
|
|
107
|
+
markAsRead: (notificationIds: types.MarkAsRead["notificationIds"]) => Promise<ApiResponse<{
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
} & types.Notification[]>>;
|
|
110
|
+
markAllAsRead: () => Promise<ApiResponse<{
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
} & types.Notification[]>>;
|
|
113
|
+
deleteById: (id: string) => Promise<ApiResponse<{
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
} & types.Notification>>;
|
|
116
|
+
};
|
|
117
|
+
readonly subscriptions: {
|
|
118
|
+
list: (query?: types.SubscriptionsControllerFindData["query"]) => Promise<PaginatedApiResponse<types.Subscription>>;
|
|
119
|
+
create: (body: types.CreateSubscription) => Promise<ApiResponse<{
|
|
120
|
+
[key: string]: unknown;
|
|
121
|
+
} & types.Subscription>>;
|
|
122
|
+
findById: (id: string) => Promise<ApiResponse<{
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
} & types.Subscription>>;
|
|
125
|
+
updateById: (id: string, body: types.UpdateSubscription) => Promise<ApiResponse<{
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
} & types.Subscription>>;
|
|
128
|
+
deleteById: (id: string) => Promise<ApiResponse<{
|
|
129
|
+
[key: string]: unknown;
|
|
130
|
+
} & types.Subscription>>;
|
|
131
|
+
};
|
|
132
|
+
readonly smartLists: {
|
|
133
|
+
list: () => Promise<ApiResponse<{
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
} & types.ListDetail[]>>;
|
|
136
|
+
findById: (smartListId: string) => Promise<ApiResponse<{
|
|
137
|
+
[key: string]: unknown;
|
|
138
|
+
} & types.ListDetail>>;
|
|
139
|
+
findItems: (smartListId: string, query?: types.SmartListsControllerFindItemsData["query"]) => Promise<PaginatedApiResponse<types.Item>>;
|
|
140
|
+
};
|
|
141
|
+
private readonly handleRequest;
|
|
142
|
+
private readonly handlePaginatedRequest;
|
|
143
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var _e=Object.defineProperty;var t=(e,r)=>_e(e,"name",{value:r,configurable:!0});var ve={bodySerializer:t(e=>JSON.stringify(e,(r,o)=>typeof o=="bigint"?o.toString():o),"bodySerializer")};var ze=t(({onRequest:e,onSseError:r,onSseEvent:o,responseTransformer:s,responseValidator:l,sseDefaultRetryDelay:c,sseMaxRetryAttempts:d,sseMaxRetryDelay:a,sseSleepFn:p,url:h,...n})=>{let f,g=p??(C=>new Promise(I=>setTimeout(I,C)));return{stream:t(async function*(){let C=c??3e3,I=0,O=n.signal??new AbortController().signal;for(;!O.aborted;){I++;let w=n.headers instanceof Headers?n.headers:new Headers(n.headers);f!==void 0&&w.set("Last-Event-ID",f);try{let L={redirect:"follow",...n,body:n.serializedBody,headers:w,signal:O},E=new Request(h,L);e&&(E=await e(h,L));let y=await(n.fetch??globalThis.fetch)(E);if(!y.ok)throw new Error(`SSE failed: ${y.status} ${y.statusText}`);if(!y.body)throw new Error("No body in SSE response");let m=y.body.pipeThrough(new TextDecoderStream).getReader(),F="",ke=t(()=>{try{m.cancel()}catch{}},"abortHandler");O.addEventListener("abort",ke);try{for(;;){let{done:Qe,value:We}=await m.read();if(Qe)break;F+=We,F=F.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`);let Pe=F.split(`
|
|
4
|
+
|
|
5
|
+
`);F=Pe.pop()??"";for(let Je of Pe){let Ke=Je.split(`
|
|
6
|
+
`),k=[],qe;for(let S of Ke)if(S.startsWith("data:"))k.push(S.replace(/^data:\s*/,""));else if(S.startsWith("event:"))qe=S.replace(/^event:\s*/,"");else if(S.startsWith("id:"))f=S.replace(/^id:\s*/,"");else if(S.startsWith("retry:")){let Ne=Number.parseInt(S.replace(/^retry:\s*/,""),10);Number.isNaN(Ne)||(C=Ne)}let b,Ue=!1;if(k.length){let S=k.join(`
|
|
7
|
+
`);try{b=JSON.parse(S),Ue=!0}catch{b=S}}Ue&&(l&&await l(b),s&&(b=await s(b))),o==null||o({data:b,event:qe,id:f,retry:C}),k.length&&(yield b)}}}finally{O.removeEventListener("abort",ke),m.releaseLock()}break}catch(L){if(r==null||r(L),d!==void 0&&I>=d)break;let E=Math.min(C*2**(I-1),a??3e4);await g(E)}}},"createStream")()}},"createSseClient");var Xe=t(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorArrayExplode"),Ye=t(e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"separatorArrayNoExplode"),Ze=t(e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"separatorObjectExplode"),P=t(({allowReserved:e,explode:r,name:o,style:s,value:l})=>{if(!r){let a=(e?l:l.map(p=>encodeURIComponent(p))).join(Ye(s));switch(s){case"label":return`.${a}`;case"matrix":return`;${o}=${a}`;case"simple":return a;default:return`${o}=${a}`}}let c=Xe(s),d=l.map(a=>s==="label"||s==="simple"?e?a:encodeURIComponent(a):D({allowReserved:e,name:o,value:a})).join(c);return s==="label"||s==="matrix"?c+d:d},"serializeArrayParam"),D=t(({allowReserved:e,name:r,value:o})=>{if(o==null)return"";if(typeof o=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${e?o:encodeURIComponent(o)}`},"serializePrimitiveParam"),q=t(({allowReserved:e,explode:r,name:o,style:s,value:l,valueOnly:c})=>{if(l instanceof Date)return c?l.toISOString():`${o}=${l.toISOString()}`;if(s!=="deepObject"&&!r){let p=[];Object.entries(l).forEach(([n,f])=>{p=[...p,n,e?f:encodeURIComponent(f)]});let h=p.join(",");switch(s){case"form":return`${o}=${h}`;case"label":return`.${h}`;case"matrix":return`;${o}=${h}`;default:return h}}let d=Ze(s),a=Object.entries(l).map(([p,h])=>D({allowReserved:e,name:s==="deepObject"?`${o}[${p}]`:p,value:h})).join(d);return s==="label"||s==="matrix"?d+a:a},"serializeObjectParam");var er=/\{[^{}]+\}/g,rr=t(({path:e,url:r})=>{let o=r,s=r.match(er);if(s)for(let l of s){let c=!1,d=l.substring(1,l.length-1),a="simple";d.endsWith("*")&&(c=!0,d=d.substring(0,d.length-1)),d.startsWith(".")?(d=d.substring(1),a="label"):d.startsWith(";")&&(d=d.substring(1),a="matrix");let p=e[d];if(p==null)continue;if(Array.isArray(p)){o=o.replace(l,P({explode:c,name:d,style:a,value:p}));continue}if(typeof p=="object"){o=o.replace(l,q({explode:c,name:d,style:a,value:p,valueOnly:!0}));continue}if(a==="matrix"){o=o.replace(l,`;${D({name:d,value:p})}`);continue}let h=encodeURIComponent(a==="label"?`.${p}`:p);o=o.replace(l,h)}return o},"defaultPathSerializer"),je=t(({baseUrl:e,path:r,query:o,querySerializer:s,url:l})=>{let c=l.startsWith("/")?l:`/${l}`,d=(e??"")+c;r&&(d=rr({path:r,url:d}));let a=o?s(o):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(d+=`?${a}`),d},"getUrl");function N(e){let r=e.body!==void 0;if(r&&e.bodySerializer)return"serializedBody"in e?e.serializedBody!==void 0&&e.serializedBody!==""?e.serializedBody:null:e.body!==""?e.body:null;if(r)return e.body}t(N,"getValidRequestBody");var Me=t(async(e,r)=>{let o=typeof r=="function"?await r(e):r;if(o)return e.scheme==="bearer"?`Bearer ${o}`:e.scheme==="basic"?`Basic ${btoa(o)}`:o},"getAuthToken");var Ge=t(({parameters:e={},...r}={})=>t(s=>{let l=[];if(s&&typeof s=="object")for(let c in s){let d=s[c];if(d==null)continue;let a=e[c]||r;if(Array.isArray(d)){let p=P({allowReserved:a.allowReserved,explode:!0,name:c,style:"form",value:d,...a.array});p&&l.push(p)}else if(typeof d=="object"){let p=q({allowReserved:a.allowReserved,explode:!0,name:c,style:"deepObject",value:d,...a.object});p&&l.push(p)}else{let p=D({allowReserved:a.allowReserved,name:c,value:d});p&&l.push(p)}}return l.join("&")},"querySerializer"),"createQuerySerializer"),$e=t(e=>{var o;if(!e)return"stream";let r=(o=e.split(";")[0])==null?void 0:o.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"}},"getParseAs"),tr=t((e,r)=>{var o,s;return r?!!(e.headers.has(r)||(o=e.query)!=null&&o[r]||(s=e.headers.get("Cookie"))!=null&&s.includes(`${r}=`)):!1},"checkForExistence"),He=t(async({security:e,...r})=>{for(let o of e){if(tr(r,o.name))continue;let s=await Me(o,r.auth);if(!s)continue;let l=o.name??"Authorization";switch(o.in){case"query":r.query||(r.query={}),r.query[l]=s;break;case"cookie":r.headers.append("Cookie",`${l}=${s}`);break;default:r.headers.set(l,s);break}}},"setAuthParams"),v=t(e=>je({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Ge(e.querySerializer),url:e.url}),"buildUrl"),z=t((e,r)=>{var s;let o={...e,...r};return(s=o.baseUrl)!=null&&s.endsWith("/")&&(o.baseUrl=o.baseUrl.substring(0,o.baseUrl.length-1)),o.headers=U(e.headers,r.headers),o},"mergeConfigs"),or=t(e=>{let r=[];return e.forEach((o,s)=>{r.push([s,o])}),r},"headersEntries"),U=t((...e)=>{let r=new Headers;for(let o of e){if(!o)continue;let s=o instanceof Headers?or(o):Object.entries(o);for(let[l,c]of s)if(c===null)r.delete(l);else if(Array.isArray(c))for(let d of c)r.append(l,d);else c!==void 0&&r.set(l,typeof c=="object"?JSON.stringify(c):c)}return r},"mergeHeaders"),j=class j{constructor(){this.fns=[]}clear(){this.fns=[]}eject(r){let o=this.getInterceptorIndex(r);this.fns[o]&&(this.fns[o]=null)}exists(r){let o=this.getInterceptorIndex(r);return!!this.fns[o]}getInterceptorIndex(r){return typeof r=="number"?this.fns[r]?r:-1:this.fns.indexOf(r)}update(r,o){let s=this.getInterceptorIndex(r);return this.fns[s]?(this.fns[s]=o,r):!1}use(r){return this.fns.push(r),this.fns.length-1}};t(j,"Interceptors");var B=j,Ve=t(()=>({error:new B,request:new B,response:new B}),"createInterceptors"),sr=Ge({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),nr={"Content-Type":"application/json"},T=t((e={})=>({...ve,headers:nr,parseAs:"auto",querySerializer:sr,...e}),"createConfig");var A=t((e={})=>{let r=z(T(),e),o=t(()=>({...r}),"getConfig"),s=t(h=>(r=z(r,h),o()),"setConfig"),l=Ve(),c=t(async h=>{let n={...r,...h,fetch:h.fetch??r.fetch??globalThis.fetch,headers:U(r.headers,h.headers),serializedBody:void 0};n.security&&await He({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody==="")&&n.headers.delete("Content-Type");let f=v(n);return{opts:n,url:f}},"beforeRequest"),d=t(async h=>{let{opts:n,url:f}=await c(h),g={redirect:"follow",...n,body:N(n)},R=new Request(f,g);for(let u of l.request.fns)u&&(R=await u(R,n));let x=n.fetch,C;try{C=await x(R)}catch(u){let y=u;for(let m of l.error.fns)m&&(y=await m(u,void 0,R,n));if(y=y||{},n.throwOnError)throw y;return n.responseStyle==="data"?void 0:{error:y,request:R,response:void 0}}for(let u of l.response.fns)u&&(C=await u(C,R,n));let I={request:R,response:C};if(C.ok){let u=(n.parseAs==="auto"?$e(C.headers.get("Content-Type")):n.parseAs)??"json";if(C.status===204||C.headers.get("Content-Length")==="0"){let m;switch(u){case"arrayBuffer":case"blob":case"text":m=await C[u]();break;case"formData":m=new FormData;break;case"stream":m=C.body;break;default:m={};break}return n.responseStyle==="data"?m:{data:m,...I}}let y;switch(u){case"arrayBuffer":case"blob":case"formData":case"text":y=await C[u]();break;case"json":{let m=await C.text();y=m?JSON.parse(m):{};break}case"stream":return n.responseStyle==="data"?C.body:{data:C.body,...I}}return u==="json"&&(n.responseValidator&&await n.responseValidator(y),n.responseTransformer&&(y=await n.responseTransformer(y))),n.responseStyle==="data"?y:{data:y,...I}}let O=await C.text(),w;try{w=JSON.parse(O)}catch{}let L=w??O,E=L;for(let u of l.error.fns)u&&(E=await u(L,C,R,n));if(E=E||{},n.throwOnError)throw E;return n.responseStyle==="data"?void 0:{error:E,...I}},"request"),a=t(h=>n=>d({...n,method:h}),"makeMethodFn"),p=t(h=>async n=>{let{opts:f,url:g}=await c(n);return ze({...f,body:f.body,headers:f.headers,method:h,onRequest:t(async(R,x)=>{let C=new Request(R,x);for(let I of l.request.fns)I&&(C=await I(C,f));return C},"onRequest"),serializedBody:N(f),url:g})},"makeSseFn");return{buildUrl:v,connect:a("CONNECT"),delete:a("DELETE"),get:a("GET"),getConfig:o,head:a("HEAD"),interceptors:l,options:a("OPTIONS"),patch:a("PATCH"),post:a("POST"),put:a("PUT"),request:d,setConfig:s,sse:{connect:p("CONNECT"),delete:p("DELETE"),get:p("GET"),head:p("HEAD"),options:p("OPTIONS"),patch:p("PATCH"),post:p("POST"),put:p("PUT"),trace:p("TRACE")},trace:a("TRACE")}},"createClient");var i=A(T({baseUrl:"https://swish.app/api/unstable"}));var M=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e}),"listControllerFind"),G=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerCreate"),$=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerDeleteById"),H=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e}),"listControllerFindById"),V=t(e=>(e.client??i).patch({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerUpdateById"),Q=t(e=>(e.client??i).put({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/order",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerSetListItemsOrder"),W=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"listControllerAddItemsToList"),J=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/lists/{listId}/items/{itemId}",...e}),"listControllerRemoveItemFromList"),K=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerDelete"),_=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/items",...e}),"itemControllerFind"),X=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/items",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerCreate"),Y=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/items/count",...e}),"itemControllerCount"),Z=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerDeleteById"),ee=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e}),"itemControllerFindById"),re=t(e=>(e.client??i).patch({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerUpdateById"),te=t(e=>(e.client??i).put({security:[{scheme:"bearer",type:"http"}],url:"/items/{itemId}/lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"itemControllerSetListsById"),oe=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/identify",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerIdentify"),se=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/profiles/token",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerCreateToken"),ne=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/profiles",...e}),"profileControllerGetProfile"),le=t(e=>(e.client??i).patch({security:[{scheme:"bearer",type:"http"}],url:"/profiles/profile",...e,headers:{"Content-Type":"application/json",...e.headers}}),"profileControllerUpdateProfile"),ie=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/saved-items",...e}),"analyticsControllerLoadSavedItems"),ae=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/sessions",...e}),"analyticsControllerLoadSessions"),de=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/analytics/new-lists",...e}),"analyticsControllerLoadNewLists"),pe=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/collect",...e,headers:{"Content-Type":"application/json",...e.headers}}),"trackingControllerCollect"),ce=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/orders",...e}),"ordersControllerFind"),Ce=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/orders/{orderId}",...e}),"ordersControllerFindOne"),he=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e}),"sharedListsControllerFindAll"),ye=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists",...e,headers:{"Content-Type":"application/json",...e.headers}}),"sharedListsControllerSave"),ue=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerDeleteById"),fe=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}",...e}),"sharedListsControllerFindById"),me=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/shared-lists/{sharedListId}/items",...e}),"sharedListsControllerFindItems"),Ie=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications",...e}),"notificationsControllerFind"),Re=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/notifications/unread/count",...e}),"notificationsControllerGetUnreadCount"),Se=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read",...e,headers:{"Content-Type":"application/json",...e.headers}}),"notificationsControllerMarkAsRead"),Ee=t(e=>((e==null?void 0:e.client)??i).post({security:[{scheme:"bearer",type:"http"}],url:"/notifications/read/all",...e}),"notificationsControllerMarkAllAsRead"),Oe=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/notifications/{id}",...e}),"notificationsControllerDeleteById"),Le=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e}),"subscriptionsControllerFind"),be=t(e=>(e.client??i).post({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerCreate"),Te=t(e=>(e.client??i).delete({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerDelete"),De=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e}),"subscriptionsControllerFindById"),ge=t(e=>(e.client??i).patch({security:[{scheme:"bearer",type:"http"}],url:"/subscriptions/{id}",...e,headers:{"Content-Type":"application/json",...e.headers}}),"subscriptionsControllerUpdate"),we=t(e=>((e==null?void 0:e.client)??i).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists",...e}),"smartListsControllerFindAll"),Fe=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}",...e}),"smartListsControllerFindById"),Be=t(e=>(e.client??i).get({security:[{scheme:"bearer",type:"http"}],url:"/smart-lists/{smartListId}/items",...e}),"smartListsControllerFindItems");var ir="unstable",Gr=t(e=>new Ae(e),"createApiClient"),xe=class xe{constructor(r){this.version=ir;this.items={list:t(r=>this.handlePaginatedRequest(_({query:r,client:this.client})),"list"),create:t(r=>this.handleRequest(X({body:r,client:this.client})),"create"),delete:t(r=>this.handleRequest(K({body:{itemIds:r},client:this.client})),"delete"),findById:t(r=>this.handleRequest(ee({path:{itemId:r},client:this.client})),"findById"),updateById:t((r,o)=>this.handleRequest(re({body:o,path:{itemId:r},client:this.client})),"updateById"),deleteById:t(r=>this.handleRequest(Z({path:{itemId:r},client:this.client})),"deleteById"),setListsById:t((r,o)=>this.handleRequest(te({body:{listIds:o},path:{itemId:r},client:this.client})),"setListsById"),count:t(()=>this.handleRequest(Y({client:this.client})),"count")};this.lists={list:t(r=>this.handlePaginatedRequest(M({query:r,client:this.client})),"list"),create:t(r=>this.handleRequest(G({body:r,client:this.client})),"create"),findById:t(r=>this.handleRequest(H({path:{listId:r},client:this.client})),"findById"),updateById:t((r,o)=>this.handleRequest(V({body:o,path:{listId:r},client:this.client})),"updateById"),deleteById:t(r=>this.handleRequest($({path:{listId:r},client:this.client})),"deleteById"),orderItems:t((r,o)=>this.handleRequest(Q({body:{itemIds:o},path:{listId:r},client:this.client})),"orderItems"),addItemsToList:t((r,o)=>this.handleRequest(W({body:{itemIds:o},path:{listId:r},client:this.client})),"addItemsToList"),removeItemFromList:t((r,o)=>this.handleRequest(J({path:{listId:r,itemId:o},client:this.client})),"removeItemFromList")};this.profiles={createToken:t((r={})=>this.handleRequest(se({body:r,client:this.client})),"createToken"),identify:t(r=>this.handleRequest(oe({body:r,client:this.client})),"identify"),getProfile:t(()=>this.handleRequest(ne({client:this.client})),"getProfile"),updateProfile:t(r=>this.handleRequest(le({body:r,client:this.client})),"updateProfile")};this.orders={list:t(r=>this.handlePaginatedRequest(ce({query:r,client:this.client})),"list"),findById:t(r=>this.handleRequest(Ce({path:{orderId:r},client:this.client})),"findById")};this.sharedLists={list:t(r=>this.handlePaginatedRequest(he({query:r,client:this.client})),"list"),save:t(r=>this.handleRequest(ye({body:{listId:r},client:this.client})),"save"),findById:t(r=>this.handleRequest(fe({path:{sharedListId:r},client:this.client})),"findById"),deleteById:t(r=>this.handleRequest(ue({path:{sharedListId:r},client:this.client})),"deleteById"),findItems:t((r,o)=>this.handlePaginatedRequest(me({path:{sharedListId:r},query:o,client:this.client})),"findItems")};this.analytics={savedItems:t(r=>this.handleRequest(ie({query:r,client:this.client})),"savedItems"),sessions:t(r=>this.handleRequest(ae({query:r,client:this.client})),"sessions"),newLists:t(r=>this.handleRequest(de({query:r,client:this.client})),"newLists")};this.tracking={track:t(r=>this.handleRequest(pe({body:r,client:this.client})),"track")};this.notifications={list:t(r=>this.handlePaginatedRequest(Ie({query:r,client:this.client})),"list"),getUnreadCount:t(()=>this.handleRequest(Re({client:this.client})),"getUnreadCount"),markAsRead:t(r=>this.handleRequest(Se({body:{notificationIds:r},client:this.client})),"markAsRead"),markAllAsRead:t(()=>this.handleRequest(Ee({client:this.client})),"markAllAsRead"),deleteById:t(r=>this.handleRequest(Oe({path:{id:r},client:this.client})),"deleteById")};this.subscriptions={list:t(r=>this.handlePaginatedRequest(Le({query:r,client:this.client})),"list"),create:t(r=>this.handleRequest(be({body:r,client:this.client})),"create"),findById:t(r=>this.handleRequest(De({path:{id:r},client:this.client})),"findById"),updateById:t((r,o)=>this.handleRequest(ge({body:o,path:{id:r},client:this.client})),"updateById"),deleteById:t(r=>this.handleRequest(Te({path:{id:r},client:this.client})),"deleteById")};this.smartLists={list:t(()=>this.handleRequest(we({client:this.client})),"list"),findById:t(r=>this.handleRequest(Fe({path:{smartListId:r},client:this.client})),"findById"),findItems:t((r,o)=>this.handlePaginatedRequest(Be({path:{smartListId:r},query:o,client:this.client})),"findItems")};this.handleRequest=t(async r=>{let{data:o,error:s}=await r;return s!=null&&s.error?{error:s.error}:{data:o==null?void 0:o.data}},"handleRequest");this.handlePaginatedRequest=t(async r=>{var l;let{data:o,error:s}=await r;return s!=null&&s.error?{error:s.error}:{data:(o==null?void 0:o.data)??[],pageInfo:(o==null?void 0:o.pageInfo)??{next:null,previous:null,totalCount:((l=o==null?void 0:o.data)==null?void 0:l.length)??0}}},"handlePaginatedRequest");this.client=A(T({baseUrl:`https://swish.app/api/${this.version}`,...r.config})),r.authToken&&(this.authToken=r.authToken),r.requestInterceptor&&this.client.interceptors.request.use(r.requestInterceptor),r.responseInterceptor&&this.client.interceptors.response.use(r.responseInterceptor),this.client.interceptors.request.use(this.directRequestInterceptor.bind(this))}setAuthToken(r){this.authToken=r}directRequestInterceptor(r){return this.authToken&&r.headers.set("Authorization",`Bearer ${this.authToken}`),r}};t(xe,"SwishClient");var Ae=xe;export{ir as apiVersion,Gr as createApiClient};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Auth } from '../core/auth.gen';
|
|
2
|
+
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
3
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
|
|
4
|
+
export { buildClientParams } from '../core/params.gen';
|
|
5
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
6
|
+
export { createClient } from './client.gen';
|
|
7
|
+
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from './types.gen';
|
|
8
|
+
export { createConfig, mergeHeaders } from './utils.gen';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Auth } from '../core/auth.gen';
|
|
2
|
+
import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
|
|
3
|
+
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
|
4
|
+
import type { Middleware } from './utils.gen';
|
|
5
|
+
export type ResponseStyle = 'data' | 'fields';
|
|
6
|
+
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Base URL for all requests made by this client.
|
|
9
|
+
*/
|
|
10
|
+
baseUrl?: T['baseUrl'];
|
|
11
|
+
/**
|
|
12
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
13
|
+
* fetch instance.
|
|
14
|
+
*
|
|
15
|
+
* @default globalThis.fetch
|
|
16
|
+
*/
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
/**
|
|
19
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
20
|
+
* options won't have any effect.
|
|
21
|
+
*
|
|
22
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
23
|
+
*/
|
|
24
|
+
next?: never;
|
|
25
|
+
/**
|
|
26
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
27
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
28
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
29
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
30
|
+
*
|
|
31
|
+
* @default 'auto'
|
|
32
|
+
*/
|
|
33
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
34
|
+
/**
|
|
35
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
36
|
+
*
|
|
37
|
+
* @default 'fields'
|
|
38
|
+
*/
|
|
39
|
+
responseStyle?: ResponseStyle;
|
|
40
|
+
/**
|
|
41
|
+
* Throw an error instead of returning it in the response?
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
throwOnError?: T['throwOnError'];
|
|
46
|
+
}
|
|
47
|
+
export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
48
|
+
responseStyle: TResponseStyle;
|
|
49
|
+
throwOnError: ThrowOnError;
|
|
50
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
51
|
+
/**
|
|
52
|
+
* Any body that you want to add to your request.
|
|
53
|
+
*
|
|
54
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
55
|
+
*/
|
|
56
|
+
body?: unknown;
|
|
57
|
+
path?: Record<string, unknown>;
|
|
58
|
+
query?: Record<string, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Security mechanism(s) to use for the request.
|
|
61
|
+
*/
|
|
62
|
+
security?: ReadonlyArray<Auth>;
|
|
63
|
+
url: Url;
|
|
64
|
+
}
|
|
65
|
+
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
66
|
+
serializedBody?: string;
|
|
67
|
+
}
|
|
68
|
+
export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
69
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
70
|
+
request: Request;
|
|
71
|
+
response: Response;
|
|
72
|
+
}> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
73
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
74
|
+
error: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
data: undefined;
|
|
77
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
78
|
+
}) & {
|
|
79
|
+
request: Request;
|
|
80
|
+
response: Response;
|
|
81
|
+
}>;
|
|
82
|
+
export interface ClientOptions {
|
|
83
|
+
baseUrl?: string;
|
|
84
|
+
responseStyle?: ResponseStyle;
|
|
85
|
+
throwOnError?: boolean;
|
|
86
|
+
}
|
|
87
|
+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
88
|
+
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
89
|
+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
90
|
+
type BuildUrlFn = <TData extends {
|
|
91
|
+
body?: unknown;
|
|
92
|
+
path?: Record<string, unknown>;
|
|
93
|
+
query?: Record<string, unknown>;
|
|
94
|
+
url: string;
|
|
95
|
+
}>(options: TData & Options<TData>) => string;
|
|
96
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
97
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
101
|
+
* and the returned object will become the client's initial configuration.
|
|
102
|
+
*
|
|
103
|
+
* You may want to initialize your client this way instead of calling
|
|
104
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
105
|
+
* to ensure your client always has the correct values.
|
|
106
|
+
*/
|
|
107
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
108
|
+
export interface TDataShape {
|
|
109
|
+
body?: unknown;
|
|
110
|
+
headers?: unknown;
|
|
111
|
+
path?: unknown;
|
|
112
|
+
query?: unknown;
|
|
113
|
+
url: string;
|
|
114
|
+
}
|
|
115
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
116
|
+
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
2
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
3
|
+
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Infers parseAs value from provided Content-Type header.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
|
|
8
|
+
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions>, "security"> & Pick<RequestOptions, "auth" | "query"> & {
|
|
9
|
+
headers: Headers;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
export declare const buildUrl: Client['buildUrl'];
|
|
12
|
+
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
13
|
+
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
14
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
15
|
+
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
16
|
+
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
17
|
+
declare class Interceptors<Interceptor> {
|
|
18
|
+
fns: Array<Interceptor | null>;
|
|
19
|
+
clear(): void;
|
|
20
|
+
eject(id: number | Interceptor): void;
|
|
21
|
+
exists(id: number | Interceptor): boolean;
|
|
22
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
23
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
24
|
+
use(fn: Interceptor): number;
|
|
25
|
+
}
|
|
26
|
+
export interface Middleware<Req, Res, Err, Options> {
|
|
27
|
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
28
|
+
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
29
|
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
30
|
+
}
|
|
31
|
+
export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
|
|
32
|
+
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClientOptions, type Config } from './client';
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
3
|
+
/**
|
|
4
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
+
* and the returned object will become the client's initial configuration.
|
|
6
|
+
*
|
|
7
|
+
* You may want to initialize your client this way instead of calling
|
|
8
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
+
* to ensure your client always has the correct values.
|
|
10
|
+
*/
|
|
11
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
12
|
+
export declare const client: import("./client").Client;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AuthToken = string | undefined;
|
|
2
|
+
export interface Auth {
|
|
3
|
+
/**
|
|
4
|
+
* Which part of the request do we use to send the auth?
|
|
5
|
+
*
|
|
6
|
+
* @default 'header'
|
|
7
|
+
*/
|
|
8
|
+
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* Header or query parameter name.
|
|
11
|
+
*
|
|
12
|
+
* @default 'Authorization'
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
scheme?: 'basic' | 'bearer';
|
|
16
|
+
type: 'apiKey' | 'http';
|
|
17
|
+
}
|
|
18
|
+
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|