@mitreka/coreflow-types 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{resource.ts → api.ts} +9 -11
- package/auth.ts +93 -68
- package/company.ts +51 -22
- package/error.ts +7 -0
- package/filter.ts +52 -0
- package/find.ts +0 -6
- package/index.ts +2 -1
- package/package.json +2 -2
- package/user.ts +70 -42
package/{resource.ts → api.ts}
RENAMED
|
@@ -5,21 +5,19 @@ export type PageMetaData = {
|
|
|
5
5
|
total_pages: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* List response.
|
|
10
|
+
*/
|
|
11
|
+
export type ListResponse<T> = {
|
|
9
12
|
message: string;
|
|
10
|
-
data: T[];
|
|
11
13
|
meta: PageMetaData;
|
|
14
|
+
data: T[];
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
limit: number;
|
|
19
|
-
q: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ResourceEntity<T> = {
|
|
17
|
+
/**
|
|
18
|
+
* Single API response
|
|
19
|
+
*/
|
|
20
|
+
export type SingleResponse<T> = {
|
|
23
21
|
message: string;
|
|
24
22
|
data: T;
|
|
25
23
|
}
|
package/auth.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import type { BaseEntity } from "./entity.js";
|
|
2
|
+
import type { BaseEntityFilters, QueryFilters } from "./filter.js";
|
|
2
3
|
|
|
3
4
|
export type AccessCompany = {
|
|
4
5
|
id: string;
|
|
5
6
|
name: string;
|
|
6
7
|
is_owner: boolean;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
8
9
|
|
|
9
10
|
export type AccessRole = {
|
|
10
11
|
id: string;
|
|
11
12
|
name: string;
|
|
12
|
-
}
|
|
13
|
+
};
|
|
13
14
|
|
|
14
15
|
export type AccessToken = {
|
|
15
16
|
iss: string; // issuer
|
|
16
17
|
sub: string; // client id
|
|
17
18
|
scope: string; // scopes of client, separated by space
|
|
18
|
-
permissions: string[]; // permissions of client
|
|
19
19
|
company_id: string; // company id
|
|
20
20
|
user_id: string; // user id
|
|
21
21
|
iat: number;
|
|
22
22
|
exp: number;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
export type AccessTokenResponse = {
|
|
26
26
|
access_token: string;
|
|
27
27
|
token_type: string; // Bearer
|
|
28
28
|
expires_in: number;
|
|
29
29
|
scope: string;
|
|
30
|
-
refresh_token?: string;
|
|
31
|
-
id_token?: string; // JWT
|
|
32
|
-
}
|
|
30
|
+
refresh_token?: string; // Refresh Token JWT
|
|
31
|
+
id_token?: string; // IDToken JWT
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
export type AccessUser = {
|
|
35
35
|
id: string;
|
|
36
|
-
username: string;
|
|
37
|
-
name: string;
|
|
38
36
|
email: string;
|
|
37
|
+
name: string;
|
|
39
38
|
phone?: string;
|
|
40
|
-
}
|
|
39
|
+
};
|
|
41
40
|
|
|
42
41
|
export type AuthAccessType = 'offline' | 'online';
|
|
42
|
+
export type AuthChallengeMethod = 'S256';
|
|
43
43
|
export type AuthGrantType = 'authorization_code' | 'refresh_token';
|
|
44
44
|
export type AuthResponseType = 'code' | 'token';
|
|
45
45
|
|
|
@@ -49,34 +49,44 @@ export type AuthorizationParam = {
|
|
|
49
49
|
code: string;
|
|
50
50
|
code_verifier: string;
|
|
51
51
|
code_challenge: string;
|
|
52
|
-
code_challenge_method:
|
|
52
|
+
code_challenge_method: AuthChallengeMethod;
|
|
53
|
+
company_id: string;
|
|
54
|
+
error: string;
|
|
53
55
|
grant_type: AuthGrantType;
|
|
54
56
|
redirect_uri: string;
|
|
55
57
|
refresh_token: string;
|
|
56
58
|
response_type: AuthResponseType;
|
|
57
59
|
scope: string;
|
|
58
60
|
state: string;
|
|
59
|
-
|
|
61
|
+
user_id: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type AuthorizationCallback = Pick<AuthorizationParam, 'code' | 'error' | 'state'>;
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
67
|
* Authorization exchange
|
|
63
68
|
*/
|
|
64
|
-
export type AuthorizationExchange =
|
|
69
|
+
export type AuthorizationExchange = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'redirect_uri'>;
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
72
|
* Authorization refresh
|
|
68
73
|
*/
|
|
69
|
-
export type AuthorizationRefresh = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'grant_type' | 'refresh_token'>;
|
|
74
|
+
export type AuthorizationRefresh = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'company_id' | 'grant_type' | 'refresh_token'>;
|
|
70
75
|
|
|
71
76
|
/**
|
|
72
77
|
* Authorization request
|
|
73
78
|
*/
|
|
74
|
-
export type AuthorizationRequest = Omit<AuthorizationParam, 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'refresh_token'>;
|
|
79
|
+
export type AuthorizationRequest = Omit<AuthorizationParam, 'client_secret' | 'code' | 'code_verifier' | 'company_id' | 'error' | 'grant_type' | 'refresh_token'>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Authorize client
|
|
83
|
+
*/
|
|
84
|
+
export type AuthorizeClient = Pick<AuthorizationRequest, 'client_id' | 'user_id' | 'scope' | 'redirect_uri' | 'code_challenge' | 'code_challenge_method' | 'state'>;
|
|
75
85
|
|
|
76
86
|
export type ClientDetail = {
|
|
77
87
|
name: string;
|
|
78
88
|
description?: string;
|
|
79
|
-
}
|
|
89
|
+
};
|
|
80
90
|
|
|
81
91
|
export type IDToken = {
|
|
82
92
|
iss: string;
|
|
@@ -86,123 +96,138 @@ export type IDToken = {
|
|
|
86
96
|
email?: string;
|
|
87
97
|
iat: number;
|
|
88
98
|
exp: number;
|
|
89
|
-
}
|
|
99
|
+
};
|
|
90
100
|
|
|
91
101
|
export type KeyPair = {
|
|
92
102
|
private: string;
|
|
93
103
|
public: string;
|
|
94
|
-
}
|
|
104
|
+
};
|
|
95
105
|
|
|
96
|
-
export interface
|
|
106
|
+
export interface OAuthClientEntity extends BaseEntity {
|
|
97
107
|
id: string;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface OAuthClientEntity {
|
|
101
|
-
name: string;
|
|
102
108
|
company_id: string;
|
|
109
|
+
name: string;
|
|
103
110
|
secret: string;
|
|
104
111
|
description?: string;
|
|
105
112
|
is_active: boolean;
|
|
106
113
|
expired_at: Date;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
|
-
export
|
|
116
|
+
export type OAuthClient = Omit<OAuthClientEntity, 'id' | keyof BaseEntity>;
|
|
117
|
+
export type OAuthClientRequest = QueryFilters & BaseEntityFilters & {
|
|
110
118
|
id: string;
|
|
111
|
-
|
|
119
|
+
company_id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
secret: string;
|
|
122
|
+
is_active: string;
|
|
123
|
+
expired_at_from: string;
|
|
124
|
+
expired_at_to: string;
|
|
125
|
+
};
|
|
112
126
|
|
|
113
127
|
export interface OAuthGrantEntity {
|
|
128
|
+
id: string;
|
|
114
129
|
client_id: string;
|
|
115
130
|
user_id: string;
|
|
116
131
|
code: string;
|
|
117
|
-
|
|
118
|
-
auth_code: string;
|
|
132
|
+
scope: string;
|
|
119
133
|
redirect_uri: string;
|
|
120
|
-
expired_at
|
|
121
|
-
granted_at
|
|
134
|
+
expired_at: Date;
|
|
135
|
+
granted_at: Date;
|
|
136
|
+
code_challenge: string;
|
|
137
|
+
code_challenge_method: AuthChallengeMethod;
|
|
122
138
|
}
|
|
123
139
|
|
|
140
|
+
export type OAuthGrant = Omit<OAuthGrantEntity, 'id'>;
|
|
141
|
+
export type OAuthGrantRequest = QueryFilters & {
|
|
142
|
+
id: string;
|
|
143
|
+
client_id: string;
|
|
144
|
+
user_id: string;
|
|
145
|
+
code: string;
|
|
146
|
+
scope: string;
|
|
147
|
+
redirect_uri: string;
|
|
148
|
+
expired_at_from: string;
|
|
149
|
+
expired_at_to: string;
|
|
150
|
+
granted_at_from: string;
|
|
151
|
+
granted_at_to: string;
|
|
152
|
+
code_challenge: string;
|
|
153
|
+
code_challenge_method: AuthChallengeMethod;
|
|
154
|
+
};
|
|
155
|
+
|
|
124
156
|
export type OAuthLogin = {
|
|
125
|
-
|
|
157
|
+
email: string;
|
|
126
158
|
password: string;
|
|
127
159
|
client_id: string;
|
|
128
160
|
redirect_uri: string;
|
|
129
161
|
scope: string;
|
|
130
|
-
}
|
|
162
|
+
};
|
|
131
163
|
|
|
132
|
-
export interface
|
|
164
|
+
export interface OAuthScopeEntity extends BaseEntity {
|
|
133
165
|
id: string;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface OAuthScopeEntity {
|
|
137
166
|
name: string;
|
|
138
167
|
description?: string;
|
|
139
168
|
}
|
|
140
169
|
|
|
141
|
-
export
|
|
170
|
+
export type OAuthScope = Pick<OAuthScopeEntity, 'name' | 'description'>;
|
|
171
|
+
export type OAuthScopeRequest = QueryFilters & BaseEntityFilters & {
|
|
142
172
|
id: string;
|
|
143
|
-
|
|
173
|
+
name: string;
|
|
174
|
+
};
|
|
144
175
|
|
|
145
176
|
export interface OAuthSessionEntity {
|
|
177
|
+
id: string;
|
|
146
178
|
user_id: string;
|
|
147
179
|
ip_address: string;
|
|
148
180
|
user_agent: string;
|
|
149
|
-
|
|
181
|
+
expired_at?: Date;
|
|
150
182
|
}
|
|
151
183
|
|
|
152
|
-
export type
|
|
153
|
-
client_id: string;
|
|
154
|
-
code_challenge: string;
|
|
155
|
-
code_challenge_method: string;
|
|
156
|
-
redirect_uri: string;
|
|
157
|
-
response_type: AuthResponseType;
|
|
158
|
-
scope: string;
|
|
159
|
-
state?: string;
|
|
160
|
-
}
|
|
184
|
+
export type OAuthSession = Omit<OAuthSessionEntity, 'id'>;
|
|
161
185
|
|
|
162
186
|
export type RefreshToken = {
|
|
163
187
|
jti: string;
|
|
164
188
|
iat: number;
|
|
165
189
|
exp: number;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export type RefreshTokenOptions = {
|
|
169
|
-
grant_type: AuthGrantType; // refresh_token
|
|
170
|
-
refresh_token: string;
|
|
171
|
-
company_id?: string;
|
|
172
|
-
scope?: string;
|
|
173
|
-
}
|
|
190
|
+
};
|
|
174
191
|
|
|
175
192
|
export type SessionList = {
|
|
176
193
|
active: string;
|
|
177
194
|
list: string[];
|
|
178
|
-
}
|
|
195
|
+
};
|
|
179
196
|
|
|
180
197
|
export type TokenExpires = {
|
|
181
198
|
accessExpiresIn: string;
|
|
182
199
|
refreshExpiresIn: string;
|
|
183
|
-
}
|
|
200
|
+
};
|
|
184
201
|
|
|
185
202
|
export type TokenPair = {
|
|
186
203
|
access_token: string;
|
|
187
204
|
refresh_token: string;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export type UserIdentity = {
|
|
208
|
+
company_id: string;
|
|
209
|
+
email: string;
|
|
210
|
+
jti: string;
|
|
211
|
+
name: string;
|
|
212
|
+
user_id: string;
|
|
188
213
|
}
|
|
189
214
|
|
|
190
215
|
export type UserSession = {
|
|
191
216
|
company: AccessCompany;
|
|
192
217
|
roles: AccessRole[];
|
|
193
218
|
user: AccessUser;
|
|
194
|
-
}
|
|
219
|
+
};
|
|
195
220
|
|
|
196
|
-
export type
|
|
197
|
-
jti: string;
|
|
221
|
+
export type UserIdentityParam = {
|
|
198
222
|
company_id: string;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type UserVerifyRequest = {
|
|
204
|
-
username: string;
|
|
223
|
+
email: string;
|
|
224
|
+
jti: string;
|
|
205
225
|
password: string;
|
|
206
226
|
refresh_token: string;
|
|
207
|
-
|
|
208
|
-
}
|
|
227
|
+
user_id: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export type UserVerifyByJti = Pick<UserIdentityParam, 'company_id' | 'jti'>;
|
|
231
|
+
export type UserVerifyByToken = Pick<UserIdentityParam, 'company_id' | 'refresh_token'>;
|
|
232
|
+
export type UserVerifyByUserId = Pick<UserIdentityParam, 'company_id' | 'user_id'>;
|
|
233
|
+
export type UserVerifyByCredentials = Pick<UserIdentityParam, 'company_id' | 'email' | 'password'>;
|
package/company.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import type { Point } from './common.js'
|
|
2
2
|
import type { BaseEntity } from './entity.js'
|
|
3
|
-
import type {
|
|
3
|
+
import type { BaseEntityFilters, QueryFilters } from './filter.js';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface CityEntity extends BaseEntity {
|
|
6
6
|
id: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface CityEntity {
|
|
10
7
|
name: string;
|
|
11
8
|
province_id: string;
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
export
|
|
11
|
+
export type City = Pick<CityEntity, 'name' | 'province_id'>;
|
|
12
|
+
export type CityRequest = QueryFilters & BaseEntityFilters & {
|
|
15
13
|
id: string;
|
|
16
|
-
|
|
14
|
+
name: string;
|
|
15
|
+
province_id: string;
|
|
16
|
+
};
|
|
17
17
|
|
|
18
|
-
export interface ClientEntity {
|
|
18
|
+
export interface ClientEntity extends BaseEntity {
|
|
19
|
+
id: string;
|
|
19
20
|
parent_id?: string;
|
|
20
21
|
company_id: string;
|
|
21
22
|
user_am_id: string; // Account Manager
|
|
@@ -26,11 +27,20 @@ export interface ClientEntity {
|
|
|
26
27
|
address?: string;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export
|
|
30
|
+
export type Client = Omit<ClientEntity, 'id' | keyof BaseEntity>;
|
|
31
|
+
export type ClientRequest = QueryFilters & BaseEntityFilters & {
|
|
30
32
|
id: string;
|
|
31
|
-
|
|
33
|
+
parent_id: string;
|
|
34
|
+
company_id: string;
|
|
35
|
+
user_am_id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
code: string;
|
|
38
|
+
abbrev: string;
|
|
39
|
+
address: string;
|
|
40
|
+
};
|
|
32
41
|
|
|
33
|
-
export interface CompanyEntity {
|
|
42
|
+
export interface CompanyEntity extends BaseEntity {
|
|
43
|
+
id: string;
|
|
34
44
|
name: string;
|
|
35
45
|
address?: string;
|
|
36
46
|
country?: string;
|
|
@@ -41,30 +51,49 @@ export interface CompanyEntity {
|
|
|
41
51
|
email?: string;
|
|
42
52
|
fax?: string;
|
|
43
53
|
website?: string;
|
|
44
|
-
coordinate?: Point;
|
|
45
|
-
radius?: number;
|
|
46
|
-
projects?: Project[];
|
|
47
|
-
users?: User[];
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
export
|
|
56
|
+
export type Company = Omit<CompanyEntity, 'id' | keyof BaseEntity>;
|
|
57
|
+
export type CompanyRequest = QueryFilters & BaseEntityFilters & {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
address: string;
|
|
61
|
+
country: string;
|
|
62
|
+
province: string;
|
|
63
|
+
city: string;
|
|
64
|
+
zip_code: string;
|
|
65
|
+
phone_number: string;
|
|
66
|
+
email: string;
|
|
67
|
+
fax: string;
|
|
68
|
+
website: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export interface CountryEntity extends BaseEntity {
|
|
51
72
|
id: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface CountryEntity {
|
|
55
73
|
country_code: string;
|
|
56
74
|
name: string;
|
|
57
75
|
phone_code?: string;
|
|
58
76
|
}
|
|
59
77
|
|
|
60
|
-
export
|
|
78
|
+
export type Country = Omit<CountryEntity, 'id' | keyof BaseEntity>;
|
|
79
|
+
export type CountryRequest = QueryFilters & BaseEntityFilters & {
|
|
61
80
|
id: string;
|
|
62
|
-
|
|
81
|
+
country_code: string;
|
|
82
|
+
name: string;
|
|
83
|
+
phone_code: string;
|
|
84
|
+
};
|
|
63
85
|
|
|
64
|
-
export interface IndustriEntity {
|
|
86
|
+
export interface IndustriEntity extends BaseEntity {
|
|
87
|
+
id: string;
|
|
65
88
|
name: string;
|
|
66
89
|
}
|
|
67
90
|
|
|
91
|
+
export type Industry = Omit<IndustriEntity, 'id' | keyof BaseEntity>;
|
|
92
|
+
export type IndustryRequest = QueryFilters & BaseEntityFilters & {
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
68
97
|
export interface OrganizationLevel extends BaseEntity, OrganizationLevelEntity {
|
|
69
98
|
id: string;
|
|
70
99
|
}
|
package/error.ts
CHANGED
|
@@ -15,6 +15,13 @@ export class BadRequestError extends HttpError {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export class ConflictError extends HttpError {
|
|
19
|
+
constructor(message: string = 'Conflict') {
|
|
20
|
+
super(409, message);
|
|
21
|
+
this.name = 'ConflictError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
export class UnauthorizedError extends HttpError {
|
|
19
26
|
constructor(message = 'Unauthorized') {
|
|
20
27
|
super(401, message);
|
package/filter.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expired filters.
|
|
3
|
+
*/
|
|
4
|
+
export type ExpiredFilters = {
|
|
5
|
+
expired_at_from: string;
|
|
6
|
+
expired_at_to: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Granted filters.
|
|
11
|
+
*/
|
|
12
|
+
export type GrantedFilters = {
|
|
13
|
+
granted_at_from: string;
|
|
14
|
+
granted_at_to: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Query filters.
|
|
19
|
+
*/
|
|
20
|
+
export type QueryFilters = {
|
|
21
|
+
order: string;
|
|
22
|
+
page: number;
|
|
23
|
+
limit: number;
|
|
24
|
+
q: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Inclusive BaseEntity filters.
|
|
29
|
+
*/
|
|
30
|
+
export type BaseEntityFilters = {
|
|
31
|
+
created_at_from: string;
|
|
32
|
+
created_at_to: string;
|
|
33
|
+
created_by: string;
|
|
34
|
+
updated_at_from: string;
|
|
35
|
+
updated_at_to: string;
|
|
36
|
+
updated_by: string;
|
|
37
|
+
deleted_at_from: string;
|
|
38
|
+
deleted_at_to: string;
|
|
39
|
+
deleted_by: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Inclusive RelationEntity filters.
|
|
44
|
+
*/
|
|
45
|
+
export type RelationEntityFilters = {
|
|
46
|
+
created_at_from: string;
|
|
47
|
+
created_at_to: string;
|
|
48
|
+
created_by: string;
|
|
49
|
+
updated_at_from: string;
|
|
50
|
+
updated_at_to: string;
|
|
51
|
+
updated_by: string;
|
|
52
|
+
}
|
package/find.ts
CHANGED
|
@@ -12,14 +12,8 @@ export type FindOptions<T> = {
|
|
|
12
12
|
search: string;
|
|
13
13
|
order: FindOrderOptions<T>;
|
|
14
14
|
where: FindWhereOptions<T>;
|
|
15
|
-
with: Array<FindEntityOptions<T>>;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export type FindEntityOptions<T> =
|
|
19
|
-
T extends Company ? EntityRelations['company'][number] :
|
|
20
|
-
T extends Role ? EntityRelations['company'][number] :
|
|
21
|
-
T extends User ? EntityRelations['user'][number] : never
|
|
22
|
-
|
|
23
17
|
export type FindOrder = 'ASC' | 'DESC'
|
|
24
18
|
|
|
25
19
|
export type FindOrderOptions<T> = { [K in keyof T]?: FindOrder }
|
package/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './api.js';
|
|
1
2
|
export * from './auth.js';
|
|
2
3
|
export * from './common.js'
|
|
3
4
|
export * from './company.js';
|
|
@@ -6,8 +7,8 @@ export * from './cryptor.js';
|
|
|
6
7
|
export * from './entity.js';
|
|
7
8
|
export * from './error.js';
|
|
8
9
|
export * from './find.js';
|
|
10
|
+
export * from './filter.js';
|
|
9
11
|
export * from './hr.js';
|
|
10
|
-
export * from './resource.js';
|
|
11
12
|
export * from './storage.js';
|
|
12
13
|
export * from './subscription.js';
|
|
13
14
|
export * from './task.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mitreka/coreflow-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "CoreFlow Types Definition",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Riyan Widiyanto",
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
"scripts": {},
|
|
27
27
|
"dependencies": {},
|
|
28
28
|
"peerDependencies": {}
|
|
29
|
-
}
|
|
29
|
+
}
|
package/user.ts
CHANGED
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseEntityFilters, QueryFilters, RelationEntityFilters } from './filter.js';
|
|
2
2
|
import type { BaseEntity, RelationEntity } from './entity.js';
|
|
3
|
-
import type { Subscription } from './subscription.js';
|
|
4
|
-
import type { Task } from './task.js';
|
|
5
3
|
|
|
6
|
-
export interface
|
|
7
|
-
id: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface PermissionEntity {
|
|
4
|
+
export interface PermissionEntity extends BaseEntity {
|
|
5
|
+
id: string
|
|
11
6
|
name: string;
|
|
12
7
|
module: string;
|
|
13
8
|
description?: string;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
export
|
|
11
|
+
export type Permission = Omit<PermissionEntity, 'id' | keyof BaseEntity>;
|
|
12
|
+
export type PermissionRequest = QueryFilters & BaseEntityFilters & {
|
|
17
13
|
id: string;
|
|
18
|
-
|
|
14
|
+
name: string;
|
|
15
|
+
module: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
19
18
|
|
|
20
|
-
export interface RoleEntity {
|
|
19
|
+
export interface RoleEntity extends BaseEntity {
|
|
20
|
+
id: string;
|
|
21
21
|
company_id: string;
|
|
22
22
|
name: string;
|
|
23
23
|
is_active: boolean;
|
|
24
24
|
is_owner: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export
|
|
27
|
+
export type Role = Omit<RoleEntity, 'id' | keyof BaseEntity>;
|
|
28
|
+
export type RoleRequest = QueryFilters & BaseEntityFilters & {
|
|
28
29
|
id: string;
|
|
29
|
-
|
|
30
|
+
company_id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
is_active: string;
|
|
33
|
+
is_owner: string;
|
|
34
|
+
};
|
|
30
35
|
|
|
31
|
-
export interface RolePermissionEntity {
|
|
36
|
+
export interface RolePermissionEntity extends RelationEntity {
|
|
37
|
+
id: string;
|
|
32
38
|
role_id: string;
|
|
33
39
|
permission_id: string;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
}
|
|
42
|
+
export type RolePermission = Omit<RolePermissionEntity, 'id' | keyof BaseEntity>;
|
|
43
|
+
export type RolePermissionRequest = QueryFilters & RolePermissionEntity;
|
|
39
44
|
|
|
40
|
-
export interface SkillEntity {
|
|
45
|
+
export interface SkillEntity extends BaseEntity {
|
|
46
|
+
id: string;
|
|
41
47
|
company_id: string;
|
|
42
48
|
parent_id: string;
|
|
43
49
|
name: string;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
}
|
|
52
|
+
export type Skill = Omit<SkillEntity, 'id' | keyof BaseEntity>;
|
|
53
|
+
export type SkillRequest = QueryFilters & SkillEntity;
|
|
49
54
|
|
|
50
|
-
export interface UserEntity {
|
|
51
|
-
|
|
52
|
-
password: string;
|
|
53
|
-
name: string;
|
|
55
|
+
export interface UserEntity extends BaseEntity {
|
|
56
|
+
id: string;
|
|
54
57
|
email: string;
|
|
58
|
+
password?: string;
|
|
59
|
+
name: string;
|
|
55
60
|
phone?: string;
|
|
56
61
|
is_active: boolean;
|
|
57
62
|
is_loginable: boolean;
|
|
@@ -61,26 +66,43 @@ export interface UserEntity {
|
|
|
61
66
|
birth_date?: Date;
|
|
62
67
|
birth_place?: string;
|
|
63
68
|
country?: string;
|
|
64
|
-
meta?: UserMeta
|
|
65
|
-
companies?: Company[];
|
|
66
|
-
roles?: Role[];
|
|
67
|
-
skills?: Skill[];
|
|
68
|
-
subscriptions?: Subscription[];
|
|
69
|
-
tasks?: Task[];
|
|
69
|
+
meta?: UserMeta;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export
|
|
72
|
+
export type User = Omit<UserEntity, 'id' | keyof BaseEntity>;
|
|
73
|
+
export type UserRequest = QueryFilters & BaseEntityFilters & {
|
|
74
|
+
id: string;
|
|
75
|
+
email: string;
|
|
76
|
+
name: string;
|
|
77
|
+
phone: string;
|
|
78
|
+
is_active: string;
|
|
79
|
+
is_loginable: string;
|
|
80
|
+
address: string;
|
|
81
|
+
avatar: string;
|
|
82
|
+
gender: string;
|
|
83
|
+
birth_date: string;
|
|
84
|
+
birth_place: string;
|
|
85
|
+
country: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export interface UserCompanyEntity extends RelationEntity {
|
|
73
89
|
id: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface UserCompanyEntity {
|
|
77
90
|
user_id: string;
|
|
78
91
|
company_id: string;
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
is_admin: boolean;
|
|
93
|
+
is_primary: boolean;
|
|
81
94
|
load?: UserLoad;
|
|
82
95
|
}
|
|
83
96
|
|
|
97
|
+
export type UserCompany = Omit<UserCompanyEntity, 'id' | keyof RelationEntity>;
|
|
98
|
+
export type UserCompanyRequest = QueryFilters & RelationEntityFilters & {
|
|
99
|
+
id: string;
|
|
100
|
+
user_id: string;
|
|
101
|
+
company_id: string;
|
|
102
|
+
is_admin: boolean | string;
|
|
103
|
+
is_primary: boolean | string;
|
|
104
|
+
};
|
|
105
|
+
|
|
84
106
|
export enum UserGender {
|
|
85
107
|
FEMALE = "F",
|
|
86
108
|
MALE = "M"
|
|
@@ -90,7 +112,7 @@ export type UserLoad = {
|
|
|
90
112
|
status: UserLoadStatus;
|
|
91
113
|
task: number;
|
|
92
114
|
project: number;
|
|
93
|
-
}
|
|
115
|
+
};
|
|
94
116
|
|
|
95
117
|
export enum UserLoadStatus {
|
|
96
118
|
HIGH = "HIGH",
|
|
@@ -100,17 +122,21 @@ export enum UserLoadStatus {
|
|
|
100
122
|
|
|
101
123
|
export type UserMeta = {
|
|
102
124
|
token: string;
|
|
103
|
-
}
|
|
125
|
+
};
|
|
104
126
|
|
|
105
|
-
export interface
|
|
127
|
+
export interface UserRoleEntity extends RelationEntity {
|
|
106
128
|
id: string;
|
|
107
129
|
user_id: string;
|
|
108
130
|
role_id: string;
|
|
109
131
|
is_active: boolean;
|
|
110
|
-
created_at: Date;
|
|
111
|
-
created_by: string;
|
|
112
132
|
}
|
|
113
133
|
|
|
134
|
+
export type UserRole = Omit<UserRoleEntity, 'id' | keyof RelationEntity>;
|
|
135
|
+
export type UserRoleRequest = QueryFilters & RelationEntityFilters &
|
|
136
|
+
Omit<UserRoleEntity, 'is_active' | keyof RelationEntity> & {
|
|
137
|
+
is_active: boolean | string;
|
|
138
|
+
}
|
|
139
|
+
|
|
114
140
|
export interface UserRoleCreate {
|
|
115
141
|
user_id: string;
|
|
116
142
|
role_id: string;
|
|
@@ -130,6 +156,8 @@ export interface UserSkillCreate {
|
|
|
130
156
|
skill_id: string;
|
|
131
157
|
}
|
|
132
158
|
|
|
159
|
+
export type UserSkillRequest = QueryFilters & RelationEntityFilters & UserSkill;
|
|
160
|
+
|
|
133
161
|
export interface UserSubscription {
|
|
134
162
|
id: string;
|
|
135
163
|
user_id: string;
|