This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.ts
97 lines (84 loc) · 2.46 KB
/
types.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
86
87
88
89
90
91
92
93
94
95
96
97
import { RouteProps } from 'react-router-dom';
export type Primitive = boolean | number | string;
export type RecordKey = string | number | symbol;
export type UnknownRecord = Record<RecordKey, unknown>;
export type NullOrUndefined<T = undefined> = T | null | undefined;
export type Point = { x: number; y: number };
export type Range<T = Primitive> = [T, T];
export type Eventually<T> = T | Promise<T>;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export type RawJson = Record<string, any>;
export interface Pagination {
limit: number;
offset: number;
total?: number;
}
export interface FetchOptions {
signal?: AbortSignal;
}
interface ApiBase {
name: string;
stubbedResponse?: unknown;
unAuthenticated?: boolean;
// middlewares?: Middleware[]; // success/failure middlewares
}
export type RecordUnknown = Record<RecordKey, unknown>;
// Designed for use with Swagger generated api bindings.
export interface DetApi<Input, DetOutput, Output> extends ApiBase {
postProcess: (response: DetOutput) => Output;
request: (params: Input, options?: FetchOptions) => Promise<DetOutput>;
stubbedResponse?: DetOutput;
}
/**
* @description helper to organize storing api response data.
*/
export interface ApiState<T> {
data?: T;
/**
* error, if any, with the last state update.
* this should be cleared on the next successful update.
*/
error?: Error;
/**
* indicates whether the state has been fetched at least once or not.
* should always be initialized to false.
*/
hasBeenInitialized?: boolean;
/** is the state being updated? */
isLoading?: boolean;
}
export interface SingleEntityParams {
id: number;
}
/* eslint-disable-next-line @typescript-eslint/ban-types */
export type EmptyParams = {};
/**
* Router Configuration
* If the component is not defined, the route is assumed to be an external route,
* meaning React will attempt to load the path outside of the internal routing
* mechanism.
*/
export type RouteConfig = {
icon?: string;
id: string;
needAuth?: boolean;
path: string;
popout?: boolean;
redirect?: string;
suffixIcon?: string;
title?: string;
} & RouteProps;
export interface ClassNameProp {
/** classname to be applied to the base element */
className?: string;
}
export interface CommonProps extends ClassNameProp {
children?: React.ReactNode;
title?: string;
}
export interface SemanticVersion {
major: number;
minor: number;
patch: number;
}
export type ValueOf<T> = T[keyof T];