@swishapp/api-client 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/client/client.gen.js +1 -5
- package/dist/client/index.js +1 -3
- package/dist/client/sdk.gen.d.ts +8 -5
- package/dist/client/sdk.gen.js +1 -102
- package/dist/client/types.gen.d.ts +68 -21
- package/dist/client/types.gen.js +0 -2
- package/dist/client.d.ts +111 -0
- package/dist/client.js +1 -0
- package/dist/index.d.ts +2 -47
- package/dist/index.js +1 -43
- package/dist/types.d.ts +30 -0
- package/package.json +23 -6
package/README.md
CHANGED
|
@@ -13,10 +13,9 @@ npm install @swishapp/api-client
|
|
|
13
13
|
```ts
|
|
14
14
|
import { SwishClient } from "@swishapp/api-client";
|
|
15
15
|
|
|
16
|
-
const swish =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
key: "gid://shopify/Customer/123456789",
|
|
16
|
+
const swish = createClient({
|
|
17
|
+
authToken: "swish-api-token",
|
|
18
|
+
profile: "gid://shopify/Customer/12345",
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
const { data } = await swish.items.list();
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createClient, createConfig } from '@hey-api/client-fetch';
|
|
3
|
-
export const client = createClient(createConfig({
|
|
4
|
-
baseUrl: 'https://swish.app/api/unstable'
|
|
5
|
-
}));
|
|
1
|
+
var T=Object.defineProperty;var l=(n,r)=>T(n,"name",{value:r,configurable:!0});var z=l(async(n,r)=>{let e=typeof r=="function"?await r(n):r;if(e)return n.scheme==="bearer"?`Bearer ${e}`:n.scheme==="basic"?`Basic ${btoa(e)}`:e},"A");var U={bodySerializer:l(n=>JSON.stringify(n,(r,e)=>typeof e=="bigint"?e.toString():e),"bodySerializer")};var E=l(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"U"),D=l(n=>{switch(n){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},"_"),_=l(n=>{switch(n){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},"D"),v=l(({allowReserved:n,explode:r,name:e,style:i,value:s})=>{if(!r){let a=(n?s:s.map(u=>encodeURIComponent(u))).join(D(i));switch(i){case"label":return`.${a}`;case"matrix":return`;${e}=${a}`;case"simple":return a;default:return`${e}=${a}`}}let o=E(i),t=s.map(a=>i==="label"||i==="simple"?n?a:encodeURIComponent(a):g({allowReserved:n,name:e,value:a})).join(o);return i==="label"||i==="matrix"?o+t:t},"O"),g=l(({allowReserved:n,name:r,value:e})=>{if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${n?e:encodeURIComponent(e)}`},"y"),x=l(({allowReserved:n,explode:r,name:e,style:i,value:s})=>{if(s instanceof Date)return`${e}=${s.toISOString()}`;if(i!=="deepObject"&&!r){let a=[];Object.entries(s).forEach(([h,p])=>{a=[...a,h,n?p:encodeURIComponent(p)]});let u=a.join(",");switch(i){case"form":return`${e}=${u}`;case"label":return`.${u}`;case"matrix":return`;${e}=${u}`;default:return u}}let o=_(i),t=Object.entries(s).map(([a,u])=>g({allowReserved:n,name:i==="deepObject"?`${e}[${a}]`:a,value:u})).join(o);return i==="label"||i==="matrix"?o+t:t},"q"),W=/\{[^{}]+\}/g,N=l(({path:n,url:r})=>{let e=r,i=r.match(W);if(i)for(let s of i){let o=!1,t=s.substring(1,s.length-1),a="simple";t.endsWith("*")&&(o=!0,t=t.substring(0,t.length-1)),t.startsWith(".")?(t=t.substring(1),a="label"):t.startsWith(";")&&(t=t.substring(1),a="matrix");let u=n[t];if(u==null)continue;if(Array.isArray(u)){e=e.replace(s,v({explode:o,name:t,style:a,value:u}));continue}if(typeof u=="object"){e=e.replace(s,x({explode:o,name:t,style:a,value:u}));continue}if(a==="matrix"){e=e.replace(s,`;${g({name:t,value:u})}`);continue}let h=encodeURIComponent(a==="label"?`.${u}`:u);e=e.replace(s,h)}return e},"B"),$=l(({allowReserved:n,array:r,object:e}={})=>i=>{let s=[];if(i&&typeof i=="object")for(let o in i){let t=i[o];if(t!=null){if(Array.isArray(t)){s=[...s,v({allowReserved:n,explode:!0,name:o,style:"form",value:t,...r})];continue}if(typeof t=="object"){s=[...s,x({allowReserved:n,explode:!0,name:o,style:"deepObject",value:t,...e})];continue}s=[...s,g({allowReserved:n,name:o,value:t})]}}return s.join("&")},"E"),I=l(n=>{var e;if(!n)return"stream";let r=(e=n.split(";")[0])==null?void 0:e.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(i=>r.startsWith(i)))return"blob";if(r.startsWith("text/"))return"text"}},"P"),P=l(async({security:n,...r})=>{for(let e of n){let i=await z(e,r.auth);if(!i)continue;let s=e.name??"Authorization";switch(e.in){case"query":r.query||(r.query={}),r.query[s]=i;break;case"header":default:r.headers.set(s,i);break}return}},"I"),O=l(n=>B({baseUrl:n.baseUrl,path:n.path,query:n.query,querySerializer:typeof n.querySerializer=="function"?n.querySerializer:$(n.querySerializer),url:n.url}),"S"),B=l(({baseUrl:n,path:r,query:e,querySerializer:i,url:s})=>{let o=s.startsWith("/")?s:`/${s}`,t=(n??"")+o;r&&(t=N({path:r,url:t}));let a=e?i(e):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(t+=`?${a}`),t},"W"),S=l((n,r)=>{var i;let e={...n,...r};return(i=e.baseUrl)!=null&&i.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=q(n.headers,r.headers),e},"C"),q=l((...n)=>{let r=new Headers;for(let e of n){if(!e||typeof e!="object")continue;let i=e instanceof Headers?e.entries():Object.entries(e);for(let[s,o]of i)if(o===null)r.delete(s);else if(Array.isArray(o))for(let t of o)r.append(s,t);else o!==void 0&&r.set(s,typeof o=="object"?JSON.stringify(o):o)}return r},"x"),d,C=(d=class{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}exists(r){return this._fns.indexOf(r)!==-1}eject(r){let e=this._fns.indexOf(r);e!==-1&&(this._fns=[...this._fns.slice(0,e),...this._fns.slice(e+1)])}use(r){this._fns=[...this._fns,r]}},l(d,"m"),d),J=l(()=>({error:new C,request:new C,response:new C}),"T"),H=$({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),k={"Content-Type":"application/json"},j=l((n={})=>({...U,headers:k,parseAs:"auto",querySerializer:H,...n}),"w"),R=l((n={})=>{let r=S(j(),n),e=l(()=>({...r}),"e"),i=l(t=>(r=S(r,t),e()),"a"),s=J(),o=l(async t=>{let a={...r,...t,fetch:t.fetch??r.fetch??globalThis.fetch,headers:q(r.headers,t.headers)};a.security&&await P({...a,security:a.security}),a.body&&a.bodySerializer&&(a.body=a.bodySerializer(a.body)),(a.body===void 0||a.body==="")&&a.headers.delete("Content-Type");let u=O(a),h={redirect:"follow",...a},p=new Request(u,h);for(let c of s.request._fns)p=await c(p,a);let A=a.fetch,f=await A(p);for(let c of s.response._fns)f=await c(f,p,a);let m={request:p,response:f};if(f.ok){if(f.status===204||f.headers.get("Content-Length")==="0")return{data:{},...m};let c=(a.parseAs==="auto"?I(f.headers.get("Content-Type")):a.parseAs)??"json";if(c==="stream")return{data:f.body,...m};let w=await f[c]();return c==="json"&&(a.responseValidator&&await a.responseValidator(w),a.responseTransformer&&(w=await a.responseTransformer(w))),{data:w,...m}}let b=await f.text();try{b=JSON.parse(b)}catch{}let y=b;for(let c of s.error._fns)y=await c(b,f,p,a);if(y=y||{},a.throwOnError)throw y;return{error:y,...m}},"o");return{buildUrl:O,connect:l(t=>o({...t,method:"CONNECT"}),"connect"),delete:l(t=>o({...t,method:"DELETE"}),"delete"),get:l(t=>o({...t,method:"GET"}),"get"),getConfig:e,head:l(t=>o({...t,method:"HEAD"}),"head"),interceptors:s,options:l(t=>o({...t,method:"OPTIONS"}),"options"),patch:l(t=>o({...t,method:"PATCH"}),"patch"),post:l(t=>o({...t,method:"POST"}),"post"),put:l(t=>o({...t,method:"PUT"}),"put"),request:o,setConfig:i,trace:l(t=>o({...t,method:"TRACE"}),"trace")}},"J");var Q=R(j({baseUrl:"https://swish.app/api/unstable"}));export{Q as client};
|
package/dist/client/index.js
CHANGED
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
-
import type { ListControllerFindData, ListControllerFindError, ListControllerCreateData, ListControllerCreateError, ListControllerDeleteByIdData, ListControllerDeleteByIdError, ListControllerFindByIdData, ListControllerFindByIdError, ListControllerUpdateByIdData, ListControllerUpdateByIdError, ItemControllerDeleteData, ItemControllerDeleteError, ItemControllerFindData, ItemControllerFindError, ItemControllerCreateData, ItemControllerCreateError, ItemControllerDeleteByIdData, ItemControllerDeleteByIdError, ItemControllerUpdateByIdData, ItemControllerUpdateByIdError,
|
|
2
|
+
import type { ListControllerFindData, ListControllerFindError, ListControllerCreateData, ListControllerCreateError, ListControllerDeleteByIdData, ListControllerDeleteByIdError, ListControllerFindByIdData, ListControllerFindByIdError, ListControllerUpdateByIdData, ListControllerUpdateByIdError, ItemControllerDeleteData, ItemControllerDeleteError, ItemControllerFindData, ItemControllerFindError, ItemControllerCreateData, ItemControllerCreateError, ItemControllerDeleteByIdData, ItemControllerDeleteByIdError, ItemControllerUpdateByIdData, ItemControllerUpdateByIdError, ProfileControllerCustomerAccountsVersionData, ProfileControllerCustomerAccountsVersionError, ProfileControllerIdentifyData, ProfileControllerIdentifyError, ProfileControllerCreateTokenData, ProfileControllerCreateTokenError } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -37,9 +37,12 @@ export declare const itemControllerDeleteById: <ThrowOnError extends boolean = f
|
|
|
37
37
|
export declare const itemControllerUpdateById: <ThrowOnError extends boolean = false>(options: Options<ItemControllerUpdateByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
38
38
|
data?: import("./types.gen").Item;
|
|
39
39
|
}, ItemControllerUpdateByIdError, ThrowOnError>;
|
|
40
|
-
export declare const
|
|
41
|
-
data?: import("./types.gen").
|
|
42
|
-
},
|
|
40
|
+
export declare const profileControllerCustomerAccountsVersion: <ThrowOnError extends boolean = false>(options?: Options<ProfileControllerCustomerAccountsVersionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
41
|
+
data?: import("./types.gen").AccountsVersionResult;
|
|
42
|
+
}, ProfileControllerCustomerAccountsVersionError, ThrowOnError>;
|
|
43
|
+
export declare const profileControllerIdentify: <ThrowOnError extends boolean = false>(options: Options<ProfileControllerIdentifyData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
44
|
+
data?: import("./types.gen").IdentifyProfileResult;
|
|
45
|
+
}, ProfileControllerIdentifyError, ThrowOnError>;
|
|
43
46
|
export declare const profileControllerCreateToken: <ThrowOnError extends boolean = false>(options: Options<ProfileControllerCreateTokenData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Response & {
|
|
44
|
-
data?: import("./types.gen").
|
|
47
|
+
data?: import("./types.gen").CreateProfileTokenResult;
|
|
45
48
|
}, ProfileControllerCreateTokenError, ThrowOnError>;
|
package/dist/client/sdk.gen.js
CHANGED
|
@@ -1,102 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { client as _heyApiClient } from './client.gen';
|
|
3
|
-
export const listControllerFind = (options) => {
|
|
4
|
-
return (options?.client ?? _heyApiClient).get({
|
|
5
|
-
url: '/lists',
|
|
6
|
-
...options
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
export const listControllerCreate = (options) => {
|
|
10
|
-
return (options.client ?? _heyApiClient).post({
|
|
11
|
-
url: '/lists',
|
|
12
|
-
...options,
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
...options?.headers
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export const listControllerDeleteById = (options) => {
|
|
20
|
-
return (options.client ?? _heyApiClient).delete({
|
|
21
|
-
url: '/lists/{listId}',
|
|
22
|
-
...options
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
export const listControllerFindById = (options) => {
|
|
26
|
-
return (options.client ?? _heyApiClient).get({
|
|
27
|
-
url: '/lists/{listId}',
|
|
28
|
-
...options
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
export const listControllerUpdateById = (options) => {
|
|
32
|
-
return (options.client ?? _heyApiClient).patch({
|
|
33
|
-
url: '/lists/{listId}',
|
|
34
|
-
...options,
|
|
35
|
-
headers: {
|
|
36
|
-
'Content-Type': 'application/json',
|
|
37
|
-
...options?.headers
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
export const itemControllerDelete = (options) => {
|
|
42
|
-
return (options.client ?? _heyApiClient).delete({
|
|
43
|
-
url: '/items',
|
|
44
|
-
...options,
|
|
45
|
-
headers: {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
...options?.headers
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
export const itemControllerFind = (options) => {
|
|
52
|
-
return (options?.client ?? _heyApiClient).get({
|
|
53
|
-
url: '/items',
|
|
54
|
-
...options
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
export const itemControllerCreate = (options) => {
|
|
58
|
-
return (options.client ?? _heyApiClient).post({
|
|
59
|
-
url: '/items',
|
|
60
|
-
...options,
|
|
61
|
-
headers: {
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
...options?.headers
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
export const itemControllerDeleteById = (options) => {
|
|
68
|
-
return (options.client ?? _heyApiClient).delete({
|
|
69
|
-
url: '/items/{itemId}',
|
|
70
|
-
...options
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
export const itemControllerUpdateById = (options) => {
|
|
74
|
-
return (options.client ?? _heyApiClient).patch({
|
|
75
|
-
url: '/items/{itemId}',
|
|
76
|
-
...options,
|
|
77
|
-
headers: {
|
|
78
|
-
'Content-Type': 'application/json',
|
|
79
|
-
...options?.headers
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
export const profileControllerIdentifyProfile = (options) => {
|
|
84
|
-
return (options.client ?? _heyApiClient).post({
|
|
85
|
-
url: '/profiles/identify',
|
|
86
|
-
...options,
|
|
87
|
-
headers: {
|
|
88
|
-
'Content-Type': 'application/json',
|
|
89
|
-
...options?.headers
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
export const profileControllerCreateToken = (options) => {
|
|
94
|
-
return (options.client ?? _heyApiClient).post({
|
|
95
|
-
url: '/profiles/token',
|
|
96
|
-
...options,
|
|
97
|
-
headers: {
|
|
98
|
-
'Content-Type': 'application/json',
|
|
99
|
-
...options?.headers
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
};
|
|
1
|
+
var l=Object.defineProperty;var e=(r,o)=>l(r,"name",{value:o,configurable:!0});import{client as t}from"./client.gen";const s=e(r=>((r==null?void 0:r.client)??t).get({url:"/lists",...r}),"listControllerFind"),C=e(r=>(r.client??t).post({url:"/lists",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"listControllerCreate"),d=e(r=>(r.client??t).delete({url:"/lists/{listId}",...r}),"listControllerDeleteById"),i=e(r=>(r.client??t).get({url:"/lists/{listId}",...r}),"listControllerFindById"),I=e(r=>(r.client??t).patch({url:"/lists/{listId}",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"listControllerUpdateById"),E=e(r=>(r.client??t).delete({url:"/items",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"itemControllerDelete"),h=e(r=>((r==null?void 0:r.client)??t).get({url:"/items",...r}),"itemControllerFind"),T=e(r=>(r.client??t).post({url:"/items",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"itemControllerCreate"),O=e(r=>(r.client??t).delete({url:"/items/{itemId}",...r}),"itemControllerDeleteById"),c=e(r=>(r.client??t).patch({url:"/items/{itemId}",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"itemControllerUpdateById"),m=e(r=>((r==null?void 0:r.client)??t).get({url:"/profiles/accounts-version",...r}),"profileControllerCustomerAccountsVersion"),p=e(r=>(r.client??t).post({url:"/profiles/identify",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"profileControllerIdentify"),y=e(r=>(r.client??t).post({url:"/profiles/token",...r,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}}),"profileControllerCreateToken");export{T as itemControllerCreate,E as itemControllerDelete,O as itemControllerDeleteById,h as itemControllerFind,c as itemControllerUpdateById,C as listControllerCreate,d as listControllerDeleteById,s as listControllerFind,i as listControllerFindById,I as listControllerUpdateById,y as profileControllerCreateToken,m as profileControllerCustomerAccountsVersion,p as profileControllerIdentify};
|
|
@@ -137,7 +137,10 @@ export type UpdateItemInput = {
|
|
|
137
137
|
*/
|
|
138
138
|
quantity?: number;
|
|
139
139
|
};
|
|
140
|
-
export type
|
|
140
|
+
export type AccountsVersionResult = {
|
|
141
|
+
customerAccountsVersion: string;
|
|
142
|
+
};
|
|
143
|
+
export type CreateProfileTokenResult = {
|
|
141
144
|
/**
|
|
142
145
|
* A Swish API token for the profile
|
|
143
146
|
*/
|
|
@@ -147,7 +150,7 @@ export type CreateProfileTokenResponse = {
|
|
|
147
150
|
*/
|
|
148
151
|
profile: string;
|
|
149
152
|
};
|
|
150
|
-
export type
|
|
153
|
+
export type IdentifyProfileResult = {
|
|
151
154
|
/**
|
|
152
155
|
* The auth flow to use
|
|
153
156
|
*/
|
|
@@ -172,12 +175,7 @@ export type CreateProfileTokenInput = {
|
|
|
172
175
|
export type ListControllerFindData = {
|
|
173
176
|
body?: never;
|
|
174
177
|
path?: never;
|
|
175
|
-
query?:
|
|
176
|
-
/**
|
|
177
|
-
* The page cursor
|
|
178
|
-
*/
|
|
179
|
-
page?: string;
|
|
180
|
-
};
|
|
178
|
+
query?: never;
|
|
181
179
|
url: '/lists';
|
|
182
180
|
};
|
|
183
181
|
export type ListControllerFindErrors = {
|
|
@@ -512,12 +510,7 @@ export type ItemControllerDeleteResponse = ItemControllerDeleteResponses[keyof I
|
|
|
512
510
|
export type ItemControllerFindData = {
|
|
513
511
|
body?: never;
|
|
514
512
|
path?: never;
|
|
515
|
-
query?:
|
|
516
|
-
/**
|
|
517
|
-
* The page cursor
|
|
518
|
-
*/
|
|
519
|
-
page?: string;
|
|
520
|
-
};
|
|
513
|
+
query?: never;
|
|
521
514
|
url: '/items';
|
|
522
515
|
};
|
|
523
516
|
export type ItemControllerFindErrors = {
|
|
@@ -738,13 +731,67 @@ export type ItemControllerUpdateByIdResponses = {
|
|
|
738
731
|
};
|
|
739
732
|
};
|
|
740
733
|
export type ItemControllerUpdateByIdResponse = ItemControllerUpdateByIdResponses[keyof ItemControllerUpdateByIdResponses];
|
|
741
|
-
export type
|
|
734
|
+
export type ProfileControllerCustomerAccountsVersionData = {
|
|
735
|
+
body?: never;
|
|
736
|
+
path?: never;
|
|
737
|
+
query?: never;
|
|
738
|
+
url: '/profiles/accounts-version';
|
|
739
|
+
};
|
|
740
|
+
export type ProfileControllerCustomerAccountsVersionErrors = {
|
|
741
|
+
/**
|
|
742
|
+
* Bad Request
|
|
743
|
+
*/
|
|
744
|
+
400: ErrorResponse & {
|
|
745
|
+
error?: {
|
|
746
|
+
statusCode?: number;
|
|
747
|
+
error?: string;
|
|
748
|
+
};
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* Unauthorized
|
|
752
|
+
*/
|
|
753
|
+
401: ErrorResponse & {
|
|
754
|
+
error?: {
|
|
755
|
+
statusCode?: number;
|
|
756
|
+
error?: string;
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* Forbidden
|
|
761
|
+
*/
|
|
762
|
+
403: ErrorResponse & {
|
|
763
|
+
error?: {
|
|
764
|
+
statusCode?: number;
|
|
765
|
+
error?: string;
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
/**
|
|
769
|
+
* Not Found
|
|
770
|
+
*/
|
|
771
|
+
404: ErrorResponse & {
|
|
772
|
+
error?: {
|
|
773
|
+
statusCode?: number;
|
|
774
|
+
error?: string;
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
export type ProfileControllerCustomerAccountsVersionError = ProfileControllerCustomerAccountsVersionErrors[keyof ProfileControllerCustomerAccountsVersionErrors];
|
|
779
|
+
export type ProfileControllerCustomerAccountsVersionResponses = {
|
|
780
|
+
/**
|
|
781
|
+
* The customer accounts version has been fetched
|
|
782
|
+
*/
|
|
783
|
+
200: Response & {
|
|
784
|
+
data?: AccountsVersionResult;
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
export type ProfileControllerCustomerAccountsVersionResponse = ProfileControllerCustomerAccountsVersionResponses[keyof ProfileControllerCustomerAccountsVersionResponses];
|
|
788
|
+
export type ProfileControllerIdentifyData = {
|
|
742
789
|
body: IdentifyProfileInput;
|
|
743
790
|
path?: never;
|
|
744
791
|
query?: never;
|
|
745
792
|
url: '/profiles/identify';
|
|
746
793
|
};
|
|
747
|
-
export type
|
|
794
|
+
export type ProfileControllerIdentifyErrors = {
|
|
748
795
|
/**
|
|
749
796
|
* Bad Request
|
|
750
797
|
*/
|
|
@@ -782,16 +829,16 @@ export type ProfileControllerIdentifyProfileErrors = {
|
|
|
782
829
|
};
|
|
783
830
|
};
|
|
784
831
|
};
|
|
785
|
-
export type
|
|
786
|
-
export type
|
|
832
|
+
export type ProfileControllerIdentifyError = ProfileControllerIdentifyErrors[keyof ProfileControllerIdentifyErrors];
|
|
833
|
+
export type ProfileControllerIdentifyResponses = {
|
|
787
834
|
/**
|
|
788
835
|
* The profile has been identified
|
|
789
836
|
*/
|
|
790
837
|
200: Response & {
|
|
791
|
-
data?:
|
|
838
|
+
data?: IdentifyProfileResult;
|
|
792
839
|
};
|
|
793
840
|
};
|
|
794
|
-
export type
|
|
841
|
+
export type ProfileControllerIdentifyResponse = ProfileControllerIdentifyResponses[keyof ProfileControllerIdentifyResponses];
|
|
795
842
|
export type ProfileControllerCreateTokenData = {
|
|
796
843
|
body: CreateProfileTokenInput;
|
|
797
844
|
path?: never;
|
|
@@ -842,7 +889,7 @@ export type ProfileControllerCreateTokenResponses = {
|
|
|
842
889
|
* The token has been created
|
|
843
890
|
*/
|
|
844
891
|
201: Response & {
|
|
845
|
-
data?:
|
|
892
|
+
data?: CreateProfileTokenResult;
|
|
846
893
|
};
|
|
847
894
|
};
|
|
848
895
|
export type ProfileControllerCreateTokenResponse = ProfileControllerCreateTokenResponses[keyof ProfileControllerCreateTokenResponses];
|
package/dist/client/types.gen.js
CHANGED
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { SwishClientConfig, SwishClientOptions, ApiError } from "./types";
|
|
2
|
+
import type * as types from "./client/types.gen";
|
|
3
|
+
export declare const createClient: (options: SwishClientOptions) => SwishClient;
|
|
4
|
+
export type { SwishClient };
|
|
5
|
+
declare class SwishClient {
|
|
6
|
+
private authToken?;
|
|
7
|
+
private profile?;
|
|
8
|
+
constructor(options: SwishClientOptions);
|
|
9
|
+
setProfile(profile: string): void;
|
|
10
|
+
setAuthToken(authToken: string): void;
|
|
11
|
+
setConfig(config: SwishClientConfig): void;
|
|
12
|
+
requestInterceptor(request: Request): Request;
|
|
13
|
+
readonly items: {
|
|
14
|
+
list: (query?: types.ItemControllerFindData["query"]) => Promise<{
|
|
15
|
+
data: null;
|
|
16
|
+
error: ApiError;
|
|
17
|
+
} | {
|
|
18
|
+
data: types.Item[];
|
|
19
|
+
error: null;
|
|
20
|
+
}>;
|
|
21
|
+
create: (items: types.CreateItemInput) => Promise<{
|
|
22
|
+
data: null;
|
|
23
|
+
error: ApiError;
|
|
24
|
+
} | {
|
|
25
|
+
data: types.Item;
|
|
26
|
+
error: null;
|
|
27
|
+
}>;
|
|
28
|
+
delete: (items: types.DeleteItemsInput["items"]) => Promise<{
|
|
29
|
+
data: null;
|
|
30
|
+
error: ApiError;
|
|
31
|
+
} | {
|
|
32
|
+
data: unknown;
|
|
33
|
+
error: null;
|
|
34
|
+
}>;
|
|
35
|
+
deleteById: (itemId: string) => Promise<{
|
|
36
|
+
data: null;
|
|
37
|
+
error: ApiError;
|
|
38
|
+
} | {
|
|
39
|
+
data: unknown;
|
|
40
|
+
error: null;
|
|
41
|
+
}>;
|
|
42
|
+
updateById: (itemId: string, body: types.UpdateItemInput) => Promise<{
|
|
43
|
+
data: null;
|
|
44
|
+
error: ApiError;
|
|
45
|
+
} | {
|
|
46
|
+
data: types.Item;
|
|
47
|
+
error: null;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
readonly lists: {
|
|
51
|
+
list: (query?: types.ListControllerFindData["query"]) => Promise<{
|
|
52
|
+
data: null;
|
|
53
|
+
error: ApiError;
|
|
54
|
+
} | {
|
|
55
|
+
data: types.List[];
|
|
56
|
+
error: null;
|
|
57
|
+
}>;
|
|
58
|
+
findById: (listId: string) => Promise<{
|
|
59
|
+
data: null;
|
|
60
|
+
error: ApiError;
|
|
61
|
+
} | {
|
|
62
|
+
data: types.List;
|
|
63
|
+
error: null;
|
|
64
|
+
}>;
|
|
65
|
+
create: (list: types.CreateListInput) => Promise<{
|
|
66
|
+
data: null;
|
|
67
|
+
error: ApiError;
|
|
68
|
+
} | {
|
|
69
|
+
data: types.List;
|
|
70
|
+
error: null;
|
|
71
|
+
}>;
|
|
72
|
+
deleteById: (listId: string) => Promise<{
|
|
73
|
+
data: null;
|
|
74
|
+
error: ApiError;
|
|
75
|
+
} | {
|
|
76
|
+
data: unknown;
|
|
77
|
+
error: null;
|
|
78
|
+
}>;
|
|
79
|
+
updateById: (listId: string, body: types.UpdateListInput) => Promise<{
|
|
80
|
+
data: null;
|
|
81
|
+
error: ApiError;
|
|
82
|
+
} | {
|
|
83
|
+
data: types.List;
|
|
84
|
+
error: null;
|
|
85
|
+
}>;
|
|
86
|
+
};
|
|
87
|
+
readonly profiles: {
|
|
88
|
+
customerAccountsVersion: () => Promise<{
|
|
89
|
+
data: null;
|
|
90
|
+
error: ApiError;
|
|
91
|
+
} | {
|
|
92
|
+
data: types.AccountsVersionResult;
|
|
93
|
+
error: null;
|
|
94
|
+
}>;
|
|
95
|
+
createToken: (body?: types.CreateProfileTokenInput) => Promise<{
|
|
96
|
+
data: null;
|
|
97
|
+
error: ApiError;
|
|
98
|
+
} | {
|
|
99
|
+
data: types.CreateProfileTokenResult;
|
|
100
|
+
error: null;
|
|
101
|
+
}>;
|
|
102
|
+
identify: (body: types.IdentifyProfileInput) => Promise<{
|
|
103
|
+
data: null;
|
|
104
|
+
error: ApiError;
|
|
105
|
+
} | {
|
|
106
|
+
data: types.IdentifyProfileResult;
|
|
107
|
+
error: null;
|
|
108
|
+
}>;
|
|
109
|
+
};
|
|
110
|
+
private readonly handleRequest;
|
|
111
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var t=(o,e)=>d(o,"name",{value:e,configurable:!0});import*as r from"./client/sdk.gen";import{client as n}from"./client/client.gen";const h=t(o=>new l(o),"createClient"),a=class a{constructor(e){this.items={list:t(e=>this.handleRequest(r.itemControllerFind({query:e})),"list"),create:t(e=>this.handleRequest(r.itemControllerCreate({body:e})),"create"),delete:t(e=>this.handleRequest(r.itemControllerDelete({body:{items:e}})),"delete"),deleteById:t(e=>this.handleRequest(r.itemControllerDeleteById({path:{itemId:e}})),"deleteById"),updateById:t((e,s)=>this.handleRequest(r.itemControllerUpdateById({body:s,path:{itemId:e}})),"updateById")};this.lists={list:t(e=>this.handleRequest(r.listControllerFind({query:e})),"list"),findById:t(e=>this.handleRequest(r.listControllerFindById({path:{listId:e}})),"findById"),create:t(e=>this.handleRequest(r.listControllerCreate({body:e})),"create"),deleteById:t(e=>this.handleRequest(r.listControllerDeleteById({path:{listId:e}})),"deleteById"),updateById:t((e,s)=>this.handleRequest(r.listControllerUpdateById({body:s,path:{listId:e}})),"updateById")};this.profiles={customerAccountsVersion:t(()=>this.handleRequest(r.profileControllerCustomerAccountsVersion()),"customerAccountsVersion"),createToken:t((e={})=>this.handleRequest(r.profileControllerCreateToken({body:e})),"createToken"),identify:t(e=>this.handleRequest(r.profileControllerIdentify({body:e})),"identify")};this.handleRequest=t(async e=>{const{data:s,error:i}=await e;return i!=null&&i.error?{data:null,error:i==null?void 0:i.error}:s!=null&&s.data?{data:s.data,error:null}:{data:null,error:null}},"handleRequest");this.profile=e.profile,e.authToken&&(this.authToken=e.authToken),e.config&&n.setConfig(e.config),n.interceptors.request.use(this.requestInterceptor.bind(this)),e.requestInterceptor&&n.interceptors.request.use(e.requestInterceptor),e.responseInterceptor&&n.interceptors.response.use(e.responseInterceptor)}setProfile(e){this.profile=e}setAuthToken(e){this.authToken=e}setConfig(e){n.setConfig(e)}requestInterceptor(e){return this.authToken&&e.headers.set("Authorization",`Bearer ${this.authToken}`),this.profile&&e.headers.set("Profile",this.profile),e}};t(a,"SwishClient");let l=a;export{h as createClient};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
authToken: string;
|
|
4
|
-
profile?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class SwishClient {
|
|
7
|
-
private readonly options;
|
|
8
|
-
constructor(options: SwishClientOptions);
|
|
9
|
-
readonly items: {
|
|
10
|
-
list: (query?: ItemControllerFindData["query"]) => Promise<(import(".").PaginatedResponse & {
|
|
11
|
-
data?: Array<import(".").Item>;
|
|
12
|
-
}) | undefined>;
|
|
13
|
-
create: (items: CreateItemInput) => Promise<(import(".").Response & {
|
|
14
|
-
data?: import(".").Item;
|
|
15
|
-
}) | undefined>;
|
|
16
|
-
delete: (items: DeleteItemsInput["items"]) => Promise<void | undefined>;
|
|
17
|
-
deleteById: (itemId: string) => Promise<void | undefined>;
|
|
18
|
-
updateById: (itemId: string, body: UpdateItemInput) => Promise<(import(".").Response & {
|
|
19
|
-
data?: import(".").Item;
|
|
20
|
-
}) | undefined>;
|
|
21
|
-
};
|
|
22
|
-
readonly lists: {
|
|
23
|
-
list: (query?: ListControllerFindData["query"]) => Promise<(import(".").PaginatedResponse & {
|
|
24
|
-
data?: Array<import(".").List>;
|
|
25
|
-
}) | undefined>;
|
|
26
|
-
findById: (listId: string) => Promise<(import(".").Response & {
|
|
27
|
-
data?: import(".").List;
|
|
28
|
-
}) | undefined>;
|
|
29
|
-
create: (list: CreateListInput) => Promise<(import(".").Response & {
|
|
30
|
-
data?: import(".").List;
|
|
31
|
-
}) | undefined>;
|
|
32
|
-
deleteById: (listId: string) => Promise<void | undefined>;
|
|
33
|
-
updateById: (listId: string, body: UpdateListInput) => Promise<(import(".").Response & {
|
|
34
|
-
data?: import(".").List;
|
|
35
|
-
}) | undefined>;
|
|
36
|
-
};
|
|
37
|
-
readonly profiles: {
|
|
38
|
-
createToken: (body?: CreateProfileTokenInput) => Promise<(import(".").Response & {
|
|
39
|
-
data?: import(".").CreateProfileTokenResponse;
|
|
40
|
-
}) | undefined>;
|
|
41
|
-
identifyProfile: (body: IdentifyProfileInput) => Promise<(import(".").Response & {
|
|
42
|
-
data?: import(".").IdentifyProfileResponse;
|
|
43
|
-
}) | undefined>;
|
|
44
|
-
};
|
|
45
|
-
private readonly addHeaders;
|
|
46
|
-
private readonly handleRequest;
|
|
47
|
-
}
|
|
1
|
+
export * from "./client";
|
|
2
|
+
export type * from "./types";
|
|
48
3
|
export type * from "./client/types.gen";
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class SwishClient {
|
|
3
|
-
constructor(options) {
|
|
4
|
-
this.items = {
|
|
5
|
-
list: (query) => this.handleRequest(itemControllerFind(this.addHeaders({ query }))),
|
|
6
|
-
create: (items) => this.handleRequest(itemControllerCreate(this.addHeaders({ body: items }))),
|
|
7
|
-
delete: (items) => this.handleRequest(itemControllerDelete(this.addHeaders({ body: { items } }))),
|
|
8
|
-
deleteById: (itemId) => this.handleRequest(itemControllerDeleteById(this.addHeaders({ path: { itemId } }))),
|
|
9
|
-
updateById: (itemId, body) => this.handleRequest(itemControllerUpdateById(this.addHeaders({
|
|
10
|
-
body,
|
|
11
|
-
path: { itemId },
|
|
12
|
-
}))),
|
|
13
|
-
};
|
|
14
|
-
this.lists = {
|
|
15
|
-
list: (query) => this.handleRequest(listControllerFind(this.addHeaders({ query }))),
|
|
16
|
-
findById: (listId) => this.handleRequest(listControllerFindById(this.addHeaders({ path: { listId } }))),
|
|
17
|
-
create: (list) => this.handleRequest(listControllerCreate(this.addHeaders({ body: list }))),
|
|
18
|
-
deleteById: (listId) => this.handleRequest(listControllerDeleteById(this.addHeaders({ path: { listId } }))),
|
|
19
|
-
updateById: (listId, body) => this.handleRequest(listControllerUpdateById(this.addHeaders({ body, path: { listId } }))),
|
|
20
|
-
};
|
|
21
|
-
this.profiles = {
|
|
22
|
-
createToken: (body = {}) => this.handleRequest(profileControllerCreateToken(this.addHeaders({ body }))),
|
|
23
|
-
identifyProfile: (body) => this.handleRequest(profileControllerIdentifyProfile(this.addHeaders({ body }))),
|
|
24
|
-
};
|
|
25
|
-
this.addHeaders = (options) => ({
|
|
26
|
-
headers: {
|
|
27
|
-
Authorization: `Bearer ${this.options.authToken}`,
|
|
28
|
-
...(this.options.profile && { Profile: this.options.profile }),
|
|
29
|
-
},
|
|
30
|
-
...options,
|
|
31
|
-
});
|
|
32
|
-
this.handleRequest = async (request) => {
|
|
33
|
-
const { data, error } = await request;
|
|
34
|
-
if (error) {
|
|
35
|
-
// TODO: Add unified error responses
|
|
36
|
-
// TODO: Add { cause: error }
|
|
37
|
-
throw new Error("Failed to execute API request");
|
|
38
|
-
}
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
this.options = options;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
export*from"./client";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ClientOptions, Config } from "@hey-api/client-fetch";
|
|
2
|
+
import type { SwishClient } from "./client";
|
|
3
|
+
export type { SwishClient };
|
|
4
|
+
export interface SwishClientOptions {
|
|
5
|
+
authToken?: string;
|
|
6
|
+
profile?: string;
|
|
7
|
+
config?: SwishClientConfig;
|
|
8
|
+
requestInterceptor?: (request: Request) => Request;
|
|
9
|
+
responseInterceptor?: (response: Response) => Response;
|
|
10
|
+
}
|
|
11
|
+
export type SwishClientConfig = Config<ClientOptions>;
|
|
12
|
+
export type ListItemsResponse = Awaited<ReturnType<SwishClient["items"]["list"]>>;
|
|
13
|
+
export type CreateItemResponse = Awaited<ReturnType<SwishClient["items"]["create"]>>;
|
|
14
|
+
export type DeleteItemsResponse = Awaited<ReturnType<SwishClient["items"]["delete"]>>;
|
|
15
|
+
export type DeleteItemByIdResponse = Awaited<ReturnType<SwishClient["items"]["deleteById"]>>;
|
|
16
|
+
export type UpdateItemByIdResponse = Awaited<ReturnType<SwishClient["items"]["updateById"]>>;
|
|
17
|
+
export type ListListsResponse = Awaited<ReturnType<SwishClient["lists"]["list"]>>;
|
|
18
|
+
export type FindListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["findById"]>>;
|
|
19
|
+
export type CreateListResponse = Awaited<ReturnType<SwishClient["lists"]["create"]>>;
|
|
20
|
+
export type DeleteListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["deleteById"]>>;
|
|
21
|
+
export type UpdateListByIdResponse = Awaited<ReturnType<SwishClient["lists"]["updateById"]>>;
|
|
22
|
+
export type CustomerAccountsVersionResponse = Awaited<ReturnType<SwishClient["profiles"]["customerAccountsVersion"]>>;
|
|
23
|
+
export type CreateProfileTokenResponse = Awaited<ReturnType<SwishClient["profiles"]["createToken"]>>;
|
|
24
|
+
export type IdentifyProfileResponse = Awaited<ReturnType<SwishClient["profiles"]["identify"]>>;
|
|
25
|
+
export interface ApiError {
|
|
26
|
+
error: string;
|
|
27
|
+
message: string;
|
|
28
|
+
requestId: string;
|
|
29
|
+
statusCode: number;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swishapp/api-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "API client for the Swish API",
|
|
5
5
|
"website": "https://swish.app",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"module": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
9
23
|
"files": [
|
|
10
|
-
"dist",
|
|
24
|
+
"dist/**/*.*",
|
|
11
25
|
"README.md"
|
|
12
26
|
],
|
|
13
27
|
"scripts": {
|
|
14
28
|
"generate": "openapi-ts",
|
|
15
29
|
"test": "jest",
|
|
16
30
|
"test:watch": "jest --watch",
|
|
17
|
-
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
31
|
+
"build": "rimraf dist && node esbuild.js && tsc -p tsconfig.build.json",
|
|
18
32
|
"prepublishOnly": "npm run build",
|
|
19
33
|
"lint": "eslint src --ext .ts",
|
|
20
34
|
"clean": "rimraf dist"
|
|
@@ -22,10 +36,13 @@
|
|
|
22
36
|
"publishConfig": {
|
|
23
37
|
"access": "public"
|
|
24
38
|
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@hey-api/client-fetch": "0.8.3"
|
|
41
|
+
},
|
|
25
42
|
"devDependencies": {
|
|
26
|
-
"@hey-api/client-fetch": "0.8.3",
|
|
27
43
|
"@hey-api/openapi-ts": "0.64.10",
|
|
28
44
|
"@types/jest": "29.5.14",
|
|
45
|
+
"esbuild": "0.25.1",
|
|
29
46
|
"jest": "29.7.0",
|
|
30
47
|
"rimraf": "5.0.1",
|
|
31
48
|
"ts-jest": "29.1.1",
|