-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.ts
62 lines (52 loc) · 1.65 KB
/
interfaces.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
import { Readable, Duplex } from 'stream';
import { AxiosRequestConfig } from 'axios';
export const TTL_HEADER = 'x-eio-ttl';
export const CONTENT_TYPE_HEADER = 'content-type';
export interface StreamBasedRequestConfig {
getFreshStream?: () => Promise<Readable>;
axiosReqConfig: AxiosRequestConfig;
}
export interface reqWithBodyHeaders {
[TTL_HEADER]?: number;
[CONTENT_TYPE_HEADER]?: string;
[index: `x-query-${string}`]: string | number
[index: `x-meta-${string}`]: string | number
}
export interface reqHeaders {
responseType?: ResponseType;
}
export interface ReqOptions extends reqHeaders {
jwtPayloadOrToken?: JWTPayload | string;
retryOptions?: RetryOptions;
}
export interface ReqWithBodyOptions {
jwtPayloadOrToken?: JWTPayload | string;
retryOptions?: RetryOptions;
headers?: reqWithBodyHeaders
}
export interface RetryOptions {
retriesCount?: number; // values are validated with RETRIES_COUNT const below
requestTimeout?: number; // values are validated with REQUEST_TIMEOUT const below
}
export interface JWTPayload {
tenantId?: string,
contractId?: string,
workspaceId?: string,
flowId?: string,
userId?: string
}
export type searchObjectCriteria = string | object;
export type uploadData = string | object | number | Array<any>;
export type TransformMiddleware = () => Duplex;
export type ResponseType = 'stream' | 'json' | 'arraybuffer';
export const DEFAULT_RESPONSE_TYPE: ResponseType = 'json';
export const RETRIES_COUNT = {
minValue: 0,
defaultValue: 2, // times error will be retried
maxValue: 4
} as const;
export const REQUEST_TIMEOUT = {
minValue: 500,
defaultValue: 10000, // 10s
maxValue: 20000
} as const;