@mitreka/coreflow-types 0.0.10 → 0.0.12
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 +94 -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,45 @@ 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
|
+
token_version: number; // Custom key for token format compatibility. Remove it if not used by any client.
|
|
62
|
+
user_id: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type AuthorizationCallback = Pick<AuthorizationParam, 'code' | 'error' | 'state'>;
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
68
|
* Authorization exchange
|
|
63
69
|
*/
|
|
64
|
-
export type AuthorizationExchange =
|
|
70
|
+
export type AuthorizationExchange = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'redirect_uri' | 'token_version'>;
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* Authorization refresh
|
|
68
74
|
*/
|
|
69
|
-
export type AuthorizationRefresh = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'grant_type' | 'refresh_token'>;
|
|
75
|
+
export type AuthorizationRefresh = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'company_id' | 'grant_type' | 'refresh_token'>;
|
|
70
76
|
|
|
71
77
|
/**
|
|
72
78
|
* Authorization request
|
|
73
79
|
*/
|
|
74
|
-
export type AuthorizationRequest = Omit<AuthorizationParam, 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'refresh_token'>;
|
|
80
|
+
export type AuthorizationRequest = Omit<AuthorizationParam, 'client_secret' | 'code' | 'code_verifier' | 'company_id' | 'error' | 'grant_type' | 'refresh_token'>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Authorize client
|
|
84
|
+
*/
|
|
85
|
+
export type AuthorizeClient = Pick<AuthorizationRequest, 'client_id' | 'user_id' | 'scope' | 'redirect_uri' | 'code_challenge' | 'code_challenge_method' | 'state'>;
|
|
75
86
|
|
|
76
87
|
export type ClientDetail = {
|
|
77
88
|
name: string;
|
|
78
89
|
description?: string;
|
|
79
|
-
}
|
|
90
|
+
};
|
|
80
91
|
|
|
81
92
|
export type IDToken = {
|
|
82
93
|
iss: string;
|
|
@@ -86,123 +97,138 @@ export type IDToken = {
|
|
|
86
97
|
email?: string;
|
|
87
98
|
iat: number;
|
|
88
99
|
exp: number;
|
|
89
|
-
}
|
|
100
|
+
};
|
|
90
101
|
|
|
91
102
|
export type KeyPair = {
|
|
92
103
|
private: string;
|
|
93
104
|
public: string;
|
|
94
|
-
}
|
|
105
|
+
};
|
|
95
106
|
|
|
96
|
-
export interface
|
|
107
|
+
export interface OAuthClientEntity extends BaseEntity {
|
|
97
108
|
id: string;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface OAuthClientEntity {
|
|
101
|
-
name: string;
|
|
102
109
|
company_id: string;
|
|
110
|
+
name: string;
|
|
103
111
|
secret: string;
|
|
104
112
|
description?: string;
|
|
105
113
|
is_active: boolean;
|
|
106
114
|
expired_at: Date;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
export
|
|
117
|
+
export type OAuthClient = Omit<OAuthClientEntity, 'id' | keyof BaseEntity>;
|
|
118
|
+
export type OAuthClientRequest = QueryFilters & BaseEntityFilters & {
|
|
110
119
|
id: string;
|
|
111
|
-
|
|
120
|
+
company_id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
secret: string;
|
|
123
|
+
is_active: string;
|
|
124
|
+
expired_at_from: string;
|
|
125
|
+
expired_at_to: string;
|
|
126
|
+
};
|
|
112
127
|
|
|
113
128
|
export interface OAuthGrantEntity {
|
|
129
|
+
id: string;
|
|
114
130
|
client_id: string;
|
|
115
131
|
user_id: string;
|
|
116
132
|
code: string;
|
|
117
|
-
|
|
118
|
-
auth_code: string;
|
|
133
|
+
scope: string;
|
|
119
134
|
redirect_uri: string;
|
|
120
|
-
expired_at
|
|
121
|
-
granted_at
|
|
135
|
+
expired_at: Date;
|
|
136
|
+
granted_at: Date;
|
|
137
|
+
code_challenge: string;
|
|
138
|
+
code_challenge_method: AuthChallengeMethod;
|
|
122
139
|
}
|
|
123
140
|
|
|
141
|
+
export type OAuthGrant = Omit<OAuthGrantEntity, 'id'>;
|
|
142
|
+
export type OAuthGrantRequest = QueryFilters & {
|
|
143
|
+
id: string;
|
|
144
|
+
client_id: string;
|
|
145
|
+
user_id: string;
|
|
146
|
+
code: string;
|
|
147
|
+
scope: string;
|
|
148
|
+
redirect_uri: string;
|
|
149
|
+
expired_at_from: string;
|
|
150
|
+
expired_at_to: string;
|
|
151
|
+
granted_at_from: string;
|
|
152
|
+
granted_at_to: string;
|
|
153
|
+
code_challenge: string;
|
|
154
|
+
code_challenge_method: AuthChallengeMethod;
|
|
155
|
+
};
|
|
156
|
+
|
|
124
157
|
export type OAuthLogin = {
|
|
125
|
-
|
|
158
|
+
email: string;
|
|
126
159
|
password: string;
|
|
127
160
|
client_id: string;
|
|
128
161
|
redirect_uri: string;
|
|
129
162
|
scope: string;
|
|
130
|
-
}
|
|
163
|
+
};
|
|
131
164
|
|
|
132
|
-
export interface
|
|
165
|
+
export interface OAuthScopeEntity extends BaseEntity {
|
|
133
166
|
id: string;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface OAuthScopeEntity {
|
|
137
167
|
name: string;
|
|
138
168
|
description?: string;
|
|
139
169
|
}
|
|
140
170
|
|
|
141
|
-
export
|
|
171
|
+
export type OAuthScope = Pick<OAuthScopeEntity, 'name' | 'description'>;
|
|
172
|
+
export type OAuthScopeRequest = QueryFilters & BaseEntityFilters & {
|
|
142
173
|
id: string;
|
|
143
|
-
|
|
174
|
+
name: string;
|
|
175
|
+
};
|
|
144
176
|
|
|
145
177
|
export interface OAuthSessionEntity {
|
|
178
|
+
id: string;
|
|
146
179
|
user_id: string;
|
|
147
180
|
ip_address: string;
|
|
148
181
|
user_agent: string;
|
|
149
|
-
|
|
182
|
+
expired_at?: Date;
|
|
150
183
|
}
|
|
151
184
|
|
|
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
|
-
}
|
|
185
|
+
export type OAuthSession = Omit<OAuthSessionEntity, 'id'>;
|
|
161
186
|
|
|
162
187
|
export type RefreshToken = {
|
|
163
188
|
jti: string;
|
|
164
189
|
iat: number;
|
|
165
190
|
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
|
-
}
|
|
191
|
+
};
|
|
174
192
|
|
|
175
193
|
export type SessionList = {
|
|
176
194
|
active: string;
|
|
177
195
|
list: string[];
|
|
178
|
-
}
|
|
196
|
+
};
|
|
179
197
|
|
|
180
198
|
export type TokenExpires = {
|
|
181
199
|
accessExpiresIn: string;
|
|
182
200
|
refreshExpiresIn: string;
|
|
183
|
-
}
|
|
201
|
+
};
|
|
184
202
|
|
|
185
203
|
export type TokenPair = {
|
|
186
204
|
access_token: string;
|
|
187
205
|
refresh_token: string;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type UserIdentity = {
|
|
209
|
+
company_id: string;
|
|
210
|
+
email: string;
|
|
211
|
+
jti: string;
|
|
212
|
+
name: string;
|
|
213
|
+
user_id: string;
|
|
188
214
|
}
|
|
189
215
|
|
|
190
216
|
export type UserSession = {
|
|
191
217
|
company: AccessCompany;
|
|
192
218
|
roles: AccessRole[];
|
|
193
219
|
user: AccessUser;
|
|
194
|
-
}
|
|
220
|
+
};
|
|
195
221
|
|
|
196
|
-
export type
|
|
197
|
-
jti: string;
|
|
222
|
+
export type UserIdentityParam = {
|
|
198
223
|
company_id: string;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type UserVerifyRequest = {
|
|
204
|
-
username: string;
|
|
224
|
+
email: string;
|
|
225
|
+
jti: string;
|
|
205
226
|
password: string;
|
|
206
227
|
refresh_token: string;
|
|
207
|
-
|
|
208
|
-
}
|
|
228
|
+
user_id: string;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export type UserVerifyByJti = Pick<UserIdentityParam, 'company_id' | 'jti'>;
|
|
232
|
+
export type UserVerifyByToken = Pick<UserIdentityParam, 'company_id' | 'refresh_token'>;
|
|
233
|
+
export type UserVerifyByUserId = Pick<UserIdentityParam, 'company_id' | 'user_id'>;
|
|
234
|
+
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.12",
|
|
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;
|