@mitreka/coreflow-types 0.0.9 → 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/api.ts +23 -0
- package/auth.ts +110 -75
- 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 +0 -25
package/api.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type PageMetaData = {
|
|
2
|
+
page: number;
|
|
3
|
+
limit: number;
|
|
4
|
+
total: number;
|
|
5
|
+
total_pages: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List response.
|
|
10
|
+
*/
|
|
11
|
+
export type ListResponse<T> = {
|
|
12
|
+
message: string;
|
|
13
|
+
meta: PageMetaData;
|
|
14
|
+
data: T[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Single API response
|
|
19
|
+
*/
|
|
20
|
+
export type SingleResponse<T> = {
|
|
21
|
+
message: string;
|
|
22
|
+
data: T;
|
|
23
|
+
}
|
package/auth.ts
CHANGED
|
@@ -1,198 +1,233 @@
|
|
|
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';
|
|
43
|
-
|
|
42
|
+
export type AuthChallengeMethod = 'S256';
|
|
44
43
|
export type AuthGrantType = 'authorization_code' | 'refresh_token';
|
|
45
|
-
|
|
46
44
|
export type AuthResponseType = 'code' | 'token';
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
* Authorization request
|
|
50
|
-
*/
|
|
51
|
-
export type AuthorizationRequest = {
|
|
46
|
+
export type AuthorizationParam = {
|
|
52
47
|
client_id: string;
|
|
53
48
|
client_secret: string;
|
|
54
49
|
code: string;
|
|
55
|
-
code_challenge: string;
|
|
56
|
-
code_challenge_method: string;
|
|
57
50
|
code_verifier: string;
|
|
51
|
+
code_challenge: string;
|
|
52
|
+
code_challenge_method: AuthChallengeMethod;
|
|
53
|
+
company_id: string;
|
|
54
|
+
error: string;
|
|
58
55
|
grant_type: AuthGrantType;
|
|
59
|
-
|
|
56
|
+
redirect_uri: string;
|
|
60
57
|
refresh_token: string;
|
|
58
|
+
response_type: AuthResponseType;
|
|
61
59
|
scope: string;
|
|
62
60
|
state: string;
|
|
63
|
-
|
|
64
|
-
}
|
|
61
|
+
user_id: string;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type AuthorizationCallback = Pick<AuthorizationParam, 'code' | 'error' | 'state'>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Authorization exchange
|
|
68
|
+
*/
|
|
69
|
+
export type AuthorizationExchange = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'redirect_uri'>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Authorization refresh
|
|
73
|
+
*/
|
|
74
|
+
export type AuthorizationRefresh = Pick<AuthorizationParam, 'client_id' | 'client_secret' | 'company_id' | 'grant_type' | 'refresh_token'>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Authorization request
|
|
78
|
+
*/
|
|
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'>;
|
|
65
85
|
|
|
66
86
|
export type ClientDetail = {
|
|
67
87
|
name: string;
|
|
68
88
|
description?: string;
|
|
69
|
-
}
|
|
89
|
+
};
|
|
70
90
|
|
|
71
91
|
export type IDToken = {
|
|
72
92
|
iss: string;
|
|
73
93
|
aud: string; // Client ID
|
|
74
94
|
sub: string; // User ID
|
|
75
95
|
name: string;
|
|
76
|
-
email
|
|
96
|
+
email?: string;
|
|
77
97
|
iat: number;
|
|
78
98
|
exp: number;
|
|
79
|
-
}
|
|
99
|
+
};
|
|
80
100
|
|
|
81
101
|
export type KeyPair = {
|
|
82
102
|
private: string;
|
|
83
103
|
public: string;
|
|
84
|
-
}
|
|
104
|
+
};
|
|
85
105
|
|
|
86
|
-
export interface
|
|
106
|
+
export interface OAuthClientEntity extends BaseEntity {
|
|
87
107
|
id: string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface OAuthClientEntity {
|
|
91
|
-
name: string;
|
|
92
108
|
company_id: string;
|
|
109
|
+
name: string;
|
|
93
110
|
secret: string;
|
|
94
111
|
description?: string;
|
|
95
112
|
is_active: boolean;
|
|
96
113
|
expired_at: Date;
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
export
|
|
116
|
+
export type OAuthClient = Omit<OAuthClientEntity, 'id' | keyof BaseEntity>;
|
|
117
|
+
export type OAuthClientRequest = QueryFilters & BaseEntityFilters & {
|
|
100
118
|
id: string;
|
|
101
|
-
|
|
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
|
+
};
|
|
102
126
|
|
|
103
127
|
export interface OAuthGrantEntity {
|
|
128
|
+
id: string;
|
|
104
129
|
client_id: string;
|
|
105
130
|
user_id: string;
|
|
106
131
|
code: string;
|
|
107
|
-
|
|
108
|
-
auth_code: string;
|
|
132
|
+
scope: string;
|
|
109
133
|
redirect_uri: string;
|
|
110
|
-
expired_at
|
|
111
|
-
granted_at
|
|
134
|
+
expired_at: Date;
|
|
135
|
+
granted_at: Date;
|
|
136
|
+
code_challenge: string;
|
|
137
|
+
code_challenge_method: AuthChallengeMethod;
|
|
112
138
|
}
|
|
113
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
|
+
|
|
114
156
|
export type OAuthLogin = {
|
|
115
|
-
|
|
157
|
+
email: string;
|
|
116
158
|
password: string;
|
|
117
159
|
client_id: string;
|
|
118
160
|
redirect_uri: string;
|
|
119
161
|
scope: string;
|
|
120
|
-
}
|
|
162
|
+
};
|
|
121
163
|
|
|
122
|
-
export interface
|
|
164
|
+
export interface OAuthScopeEntity extends BaseEntity {
|
|
123
165
|
id: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface OAuthScopeEntity {
|
|
127
166
|
name: string;
|
|
128
167
|
description?: string;
|
|
129
168
|
}
|
|
130
169
|
|
|
131
|
-
export
|
|
170
|
+
export type OAuthScope = Pick<OAuthScopeEntity, 'name' | 'description'>;
|
|
171
|
+
export type OAuthScopeRequest = QueryFilters & BaseEntityFilters & {
|
|
132
172
|
id: string;
|
|
133
|
-
|
|
173
|
+
name: string;
|
|
174
|
+
};
|
|
134
175
|
|
|
135
176
|
export interface OAuthSessionEntity {
|
|
177
|
+
id: string;
|
|
136
178
|
user_id: string;
|
|
137
179
|
ip_address: string;
|
|
138
180
|
user_agent: string;
|
|
139
|
-
|
|
181
|
+
expired_at?: Date;
|
|
140
182
|
}
|
|
141
183
|
|
|
142
|
-
export type
|
|
143
|
-
client_id: string;
|
|
144
|
-
code_challenge: string;
|
|
145
|
-
code_challenge_method: string;
|
|
146
|
-
redirect_uri: string;
|
|
147
|
-
response_type: AuthResponseType;
|
|
148
|
-
scope: string;
|
|
149
|
-
state?: string;
|
|
150
|
-
}
|
|
184
|
+
export type OAuthSession = Omit<OAuthSessionEntity, 'id'>;
|
|
151
185
|
|
|
152
186
|
export type RefreshToken = {
|
|
153
187
|
jti: string;
|
|
154
188
|
iat: number;
|
|
155
189
|
exp: number;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export type RefreshTokenOptions = {
|
|
159
|
-
grant_type: AuthGrantType; // refresh_token
|
|
160
|
-
refresh_token: string;
|
|
161
|
-
company_id?: string;
|
|
162
|
-
scope?: string;
|
|
163
|
-
}
|
|
190
|
+
};
|
|
164
191
|
|
|
165
192
|
export type SessionList = {
|
|
166
193
|
active: string;
|
|
167
194
|
list: string[];
|
|
168
|
-
}
|
|
195
|
+
};
|
|
169
196
|
|
|
170
197
|
export type TokenExpires = {
|
|
171
198
|
accessExpiresIn: string;
|
|
172
199
|
refreshExpiresIn: string;
|
|
173
|
-
}
|
|
200
|
+
};
|
|
174
201
|
|
|
175
202
|
export type TokenPair = {
|
|
176
203
|
access_token: string;
|
|
177
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;
|
|
178
213
|
}
|
|
179
214
|
|
|
180
215
|
export type UserSession = {
|
|
181
216
|
company: AccessCompany;
|
|
182
217
|
roles: AccessRole[];
|
|
183
218
|
user: AccessUser;
|
|
184
|
-
}
|
|
219
|
+
};
|
|
185
220
|
|
|
186
|
-
export type
|
|
187
|
-
jti: string;
|
|
221
|
+
export type UserIdentityParam = {
|
|
188
222
|
company_id: string;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export type UserVerifyRequest = {
|
|
194
|
-
username: string;
|
|
223
|
+
email: string;
|
|
224
|
+
jti: string;
|
|
195
225
|
password: string;
|
|
196
226
|
refresh_token: string;
|
|
197
|
-
|
|
198
|
-
}
|
|
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;
|
package/resource.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type PageMetaData = {
|
|
2
|
-
page: number;
|
|
3
|
-
limit: number;
|
|
4
|
-
total: number;
|
|
5
|
-
total_pages: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type ResourceCollection<T> = {
|
|
9
|
-
message: string;
|
|
10
|
-
data: T[];
|
|
11
|
-
meta: PageMetaData;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type ResourceListRequest = {
|
|
15
|
-
order: string;
|
|
16
|
-
page: number;
|
|
17
|
-
limit: number;
|
|
18
|
-
search: string;
|
|
19
|
-
where: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ResourceEntity<T> = {
|
|
23
|
-
message: string;
|
|
24
|
-
data: T;
|
|
25
|
-
}
|