-
Notifications
You must be signed in to change notification settings - Fork 0
/
commons-rest-api.ts
121 lines (112 loc) · 2.49 KB
/
commons-rest-api.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* wrapped response in case of errors
*/
export interface ErrorResponse {
/**
* http status code
*/
status: number;
/**
* user readable error explanation
*/
message: string;
/**
* in case of form validations details related to properties. key is the filed value list of related errors
*/
fields?: Record<string, string[]>;
}
/**
* wrapping object for paged result lists
*/
export interface PageableResult<E> {
/**
* total count of values in database
*/
totalElements: number;
/**
* count of pages in total with given pageSize
*/
totalPages: number;
/**
* current page (starts by 0)
*/
page: number;
/**
* maximum size of content list
*/
pageSize: number;
/**
* content of current page. count of elements is less or equals pageSize (depends on totalElements and page/pageSize)
*/
content: E[];
}
/**
* simple address object
*/
export interface AddressDto {
/**
* first address line
*/
addressLineOne?: string;
/**
* second address line (optional)
*/
addressLineTwo?: string;
city?: string;
state?: string;
postalCode?: string;
/**
* iso country code 2 letters - ISO 3166-1 alpha-2
*/
countryCode?: string;
}
export interface ContactDto extends HasFirstAndLastName {
gender?: Gender;
salutation?: string;
title?: string;
email?: string;
landline?: string;
cellphone?: string;
}
/**
* Object representation of validation constraints defined on a model domain object
*/
export interface ModelConstraint {
/**
* Model class name. Example: io.rocketbase.commons.model.User
*/
model: string;
/**
* Map of all validation constraints on each model property
*/
constraints: Record<string, ValidationConstraint[]>;
}
/**
* Object representation of validation constraints.
*/
export interface ValidationConstraint {
/**
* Constraint type. Example: NotNull
*/
type: string;
/**
* Associated constraint message. Example: may not be null
*/
message: string;
}
export interface EntityWithKeyValue<T> extends HasKeyValue {
}
/**
* entity/dto has firstName + lastName capability
*/
export interface HasFirstAndLastName {
firstName?: string;
lastName?: string;
}
/**
* entity/dto has key value capability
*/
export interface HasKeyValue {
keyValues?: Record<string, string>;
}
export type Gender = "female" | "male" | "diverse";