-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
80 lines (69 loc) · 3.35 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import {AxiosInstance, AxiosRequestConfig} from 'axios'
export type cachebusterConfig = {
callback: Function,
methods: string[]
}
export type CacheStrategies = 'off' | 'rootIndexOnly' | 'all'
export interface responseProcessorFunction {
(result: unknown, axiosOptions: AxiosRequestConfig)
}
export type extendedAxiosConfig = {
cachebuster: cachebusterConfig
}
export type hateoasExtendedConfig = {
axiosConfig?: AxiosRequestConfig
axiosConfigCb?: () => Promise<AxiosRequestConfig>
rootEndpoint?: string | Record<string, unknown>
rootIndexLinksPath?: string
allowedLinksProperties?: string[]
enableLogging?: boolean
disableCache?: boolean
cacheStrategy?: CacheStrategies
responseProcessors?: responseProcessorFunction[]
withVerbsRestrictions?: boolean
}
export interface ExtendedAxiosInstance extends AxiosInstance {
setCacheBuster(callback: Function|null, methods?: string[]):void
removeCacheBuster():void
getEndpoint(url: string, config?: AxiosRequestConfig, fullResponse?: boolean):Promise<any>
downloadBinary(url: string, config?: AxiosRequestConfig, name?: string):Promise<any>
openBinary(url: string, config?: AxiosRequestConfig, name?: string, forceDownload?: boolean):Promise<any>
}
export interface HateoasAxiosInstance extends AxiosInstance {
setCacheBuster(callback: Function|null, methods?: string[]):void
removeCacheBuster():void
getEndpoint(url: string, config?: AxiosRequestConfig, fullResponse?: boolean):Promise<any>
loadIndex(endpoint: string):Promise<any>
resolveUri(resource: object, rel: string, params?: object):string
getRelEndpoint(index: object, rel: string, params?: object, axiosConfig?: AxiosRequestConfig, fullResponse?: boolean):Promise<any>
followLink(resource: object, rel: string, params?: object, axiosConfig?: AxiosRequestConfig):Promise<any>
downloadBinary(resource: object, rel: string, params?: object, axiosConfig?: AxiosRequestConfig, filename?: string):Promise<any>
}
export interface HateoasExtended {
cacheDisabled:Boolean,
axios:HateoasAxiosInstance
nocache():HateoasExtended
generateCanceller():AbortController
isCancel(e: object):Boolean
clearCache(path?:string, params?:object):void
resetCache():void
get(hpath: string, params?: object, axiosOptions?: AxiosRequestConfig, suffixes?: string[]):Promise<any>
post(resource: object|string, rel: string, payload?: object, axiosOptions?: AxiosRequestConfig, urlPlaceholders?: object):Promise<any>
put(resource: object|string, rel: string, payload?: object, axiosOptions?: AxiosRequestConfig, urlPlaceholders?: object):Promise<any>
delete(resource: object|string, rel: string, params?: object):Promise<any>
follow(resource: object, rel: string, params?: object, axiosOptions?: AxiosRequestConfig, cachePrefixes?: string[], cacheSuffixes?: string[]):Promise<any>
download(resource: object|string, rel: string, params?: object, axiosOptions?: AxiosRequestConfig, filename?: string):Promise<any>
}
declare function http(config: AxiosRequestConfig): ExtendedAxiosInstance;
declare function hateoas(config: AxiosRequestConfig): HateoasAxiosInstance;
declare function extended(config: hateoasExtendedConfig): HateoasExtended;
declare function use(client: HateoasExtended, mixin: Function | string): void;
declare function registerMixin(name: string, mixin: Function): void;
export {
http,
hateoas,
extended,
use,
registerMixin
}
export default http