-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.d.ts
85 lines (77 loc) · 1.99 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
81
82
83
84
85
export default class Hubkit {
static defaults: Options & {stats: Stats};
static Stats: StatsClass;
static readonly RETRY: unique symbol;
static readonly DONT_RETRY: unique symbol;
constructor(options?: Options);
defaultOptions: Options;
request(path: string, options?: Options): Promise<any>;
graph(query: string, options?: Options & {variables?: Record<string, any>}): Promise<any>;
interpolate(string: string, options?: Record<string, any>): string;
scope(options: Options): Hubkit;
}
interface Options {
method?: string;
host?: string;
graphHost?: string;
pathPattern?: string;
body?: any;
media?: string;
ifNotFound?: any;
ifGone?: any;
perPage?: number;
allPages?: boolean;
boolean?: boolean;
immutable?: boolean;
fresh?: boolean;
stale?: boolean;
responseType?: string;
maxTries?: number;
timeout?: number;
maxItemSizeRatio?: number;
metadata?: Metadata;
stats?: Stats;
agent?: any;
corsSuccessFlags?: Record<string, boolean>;
cache?: any;
userAgent?: string;
token?: string;
clientId?: string;
clientSecret?: string;
apiVersion?: string;
[key: string]: any;
onRequest?(options: Options): void | Promise<void>; // can mutate options
onSend?(cause: 'initial' | 'retry' | 'page'): number; // returns timeout
onReceive?(): void;
onError?(error: Error & {
status?: number,
data?: any,
errors?: any,
method?: string,
path?: string,
request?: any,
response?: any,
logTag?: string,
fingerprint?: string[],
timeout?: boolean,
}):
undefined | typeof Hubkit.RETRY | typeof Hubkit.DONT_RETRY | any;
}
interface StatsClass {
new(): Stats;
}
interface Stats {
reset(): void;
record(isHit: boolean, size: number): void;
hitRate: number;
hitSizeRate: number;
}
interface Metadata {
rateLimit?: number;
rateLimitRemaining?: number;
searchRateLimit?: number;
searchRateLimitRemaining?: number;
graphRateLimit?: number;
graphRateLimitRemaining?: number;
oAuthScopes?: string[];
}