@mitreka/coreflow-types 0.0.4 → 0.0.5
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/auth.ts +159 -0
- package/common.ts +0 -26
- package/{Company.ts → company.ts} +5 -1
- package/coreflow.ts +20 -0
- package/cryptor.ts +4 -0
- package/entity.ts +11 -0
- package/find.ts +28 -0
- package/index.ts +13 -0
- package/package.json +1 -1
- package/{API.ts → resource.ts} +2 -2
- package/storage.ts +9 -0
- package/{Subscription.ts → subscription.ts} +1 -1
- package/{Task.ts → task.ts} +8 -8
- package/{User.ts → user.ts} +29 -9
- package/Auth.ts +0 -61
- package/CoreFlow.ts +0 -15
- package/index.d.ts +0 -9
- /package/{HR.ts → hr.ts} +0 -0
package/auth.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { BaseEntity } from "./entity.js";
|
|
2
|
+
|
|
3
|
+
export type AccessCompany = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
is_owner: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AccessRole = {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type AccessToken = {
|
|
15
|
+
iss: string; // issuer
|
|
16
|
+
sub: string; // client id
|
|
17
|
+
scope: string; // scopes of client, separated by space
|
|
18
|
+
permissions: string[]; // permissions of client
|
|
19
|
+
company_id: string; // company id
|
|
20
|
+
user_id: string; // user id
|
|
21
|
+
iat: number;
|
|
22
|
+
exp: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type AccessTokenResponse = {
|
|
26
|
+
access_token: string;
|
|
27
|
+
token_type: string; // Bearer
|
|
28
|
+
expires_in: number;
|
|
29
|
+
scope: string;
|
|
30
|
+
refresh_token?: string;
|
|
31
|
+
id_token?: string; // JWT of IDToken
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type AccessUser = {
|
|
35
|
+
id: string;
|
|
36
|
+
username: string;
|
|
37
|
+
name: string;
|
|
38
|
+
email: string;
|
|
39
|
+
phone?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type AuthAccessType = 'offline' | 'online';
|
|
43
|
+
|
|
44
|
+
export type AuthGrantType = 'authorization_code' | 'refresh_token';
|
|
45
|
+
|
|
46
|
+
export type AuthResponseType = 'code' | 'token';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Authorization request
|
|
50
|
+
*/
|
|
51
|
+
export type AuthorizationRequest = {
|
|
52
|
+
client_id: string;
|
|
53
|
+
client_secret: string;
|
|
54
|
+
code: string;
|
|
55
|
+
code_challenge: string;
|
|
56
|
+
code_challenge_method: string;
|
|
57
|
+
code_verifier: string;
|
|
58
|
+
grant_type: AuthGrantType;
|
|
59
|
+
response_type: AuthResponseType;
|
|
60
|
+
refresh_token: string;
|
|
61
|
+
scope: string;
|
|
62
|
+
state: string;
|
|
63
|
+
redirect_uri: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type IDToken = {
|
|
67
|
+
iss: string;
|
|
68
|
+
aud: string; // Client ID
|
|
69
|
+
sub: string; // User ID
|
|
70
|
+
name: string;
|
|
71
|
+
email: string;
|
|
72
|
+
iat: number;
|
|
73
|
+
exp: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type KeyPair = {
|
|
77
|
+
private: string;
|
|
78
|
+
public: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface OAuthClient extends BaseEntity, OAuthClientEntity {
|
|
82
|
+
id: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface OAuthClientEntity {
|
|
86
|
+
name: string;
|
|
87
|
+
company_id: string;
|
|
88
|
+
secret: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
is_active: boolean;
|
|
91
|
+
expired_at: Date;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface OAuthGrant {
|
|
95
|
+
id: string;
|
|
96
|
+
client_id: string;
|
|
97
|
+
user_id: string;
|
|
98
|
+
scopes: string;
|
|
99
|
+
is_granted: boolean;
|
|
100
|
+
expires_at?: Date;
|
|
101
|
+
granted_at: Date;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface OAuthScope extends BaseEntity, OAuthScopeEntity {
|
|
105
|
+
id: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface OAuthScopeEntity {
|
|
109
|
+
name: string;
|
|
110
|
+
description?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type RefreshToken = {
|
|
114
|
+
jti: string;
|
|
115
|
+
iat: number;
|
|
116
|
+
exp: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type RefreshTokenOptions = {
|
|
120
|
+
grant_type: AuthGrantType; // refresh_token
|
|
121
|
+
refresh_token: string;
|
|
122
|
+
company_id?: string;
|
|
123
|
+
scope?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type TokenExpires = {
|
|
127
|
+
accessExpiresIn: string;
|
|
128
|
+
refreshExpiresIn: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type TokenPair = {
|
|
132
|
+
access_token: string;
|
|
133
|
+
refresh_token: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type UserCredentials = {
|
|
137
|
+
username: string;
|
|
138
|
+
password: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type UserSession = {
|
|
142
|
+
company: AccessCompany;
|
|
143
|
+
roles: AccessRole[];
|
|
144
|
+
user: AccessUser;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type UserVerify = {
|
|
148
|
+
jti: string;
|
|
149
|
+
company_id: string;
|
|
150
|
+
permissions: string[];
|
|
151
|
+
user: AccessUser;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type UserVerifyRequest = {
|
|
155
|
+
username: string;
|
|
156
|
+
password: string;
|
|
157
|
+
refresh_token: string;
|
|
158
|
+
company_id: string;
|
|
159
|
+
}
|
package/common.ts
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
export interface BaseEntity {
|
|
2
|
-
created_at: Date;
|
|
3
|
-
created_by: string;
|
|
4
|
-
updated_at?: Date;
|
|
5
|
-
updated_by?: string;
|
|
6
|
-
deleted_at?: Date;
|
|
7
|
-
deleted_by?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type FindOptions<T> = {
|
|
11
|
-
page: number;
|
|
12
|
-
limit: number;
|
|
13
|
-
search: string;
|
|
14
|
-
order: FindOrderOptions<T>;
|
|
15
|
-
where: FindWhereOptions<T>;
|
|
16
|
-
with?: string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type FindOrder = "ASC" | "DESC";
|
|
20
|
-
|
|
21
|
-
export type FindOrderOptions<T> = Array<{ [K in keyof T]?: FindOrder }>;
|
|
22
|
-
|
|
23
|
-
export type FindWhereOptions<T> = {
|
|
24
|
-
[K in keyof T]?: T[K] | T[K][];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
1
|
export type Point = {
|
|
28
2
|
x: number;
|
|
29
3
|
y: number;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Point } from './common.js'
|
|
2
|
+
import type { BaseEntity } from './entity.js'
|
|
3
|
+
import type { User } from './user.js';
|
|
2
4
|
|
|
3
5
|
export interface City extends BaseEntity, CityEntity {
|
|
4
6
|
id: string;
|
|
@@ -41,6 +43,8 @@ export interface CompanyEntity {
|
|
|
41
43
|
website?: string;
|
|
42
44
|
coordinate?: Point;
|
|
43
45
|
radius?: number;
|
|
46
|
+
projects?: Project[];
|
|
47
|
+
users?: User[];
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export interface Country extends BaseEntity, CountryEntity {
|
package/coreflow.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KeyPair, TokenExpires, TokenPair } from './auth.js';
|
|
2
|
+
import type { CryptorOptions } from './cryptor.js';
|
|
3
|
+
|
|
4
|
+
export interface CoreFlowOptions {
|
|
5
|
+
client_id: string;
|
|
6
|
+
client_secret: string;
|
|
7
|
+
cryptor: CryptorOptions;
|
|
8
|
+
endpoints: EndpointList;
|
|
9
|
+
keys: KeyPair;
|
|
10
|
+
tokens: TokenPair;
|
|
11
|
+
tokenExpires: TokenExpires;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EndpointList {
|
|
15
|
+
auth?: string;
|
|
16
|
+
company?: string;
|
|
17
|
+
subscription?: string;
|
|
18
|
+
task?: string;
|
|
19
|
+
user?: string;
|
|
20
|
+
}
|
package/cryptor.ts
ADDED
package/entity.ts
ADDED
package/find.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Company } from './company.js';
|
|
2
|
+
import type { Role, User } from './user.js';
|
|
3
|
+
|
|
4
|
+
export type EntityRelations = {
|
|
5
|
+
company: ['user', 'project'];
|
|
6
|
+
user: ['company', 'project', 'role'];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type FindOptions<T> = {
|
|
10
|
+
page: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
search: string;
|
|
13
|
+
order: FindOrderOptions<T>;
|
|
14
|
+
where: FindWhereOptions<T>;
|
|
15
|
+
with: Array<FindEntityOptions<T>>;
|
|
16
|
+
}
|
|
17
|
+
|
|
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
|
+
export type FindOrder = 'ASC' | 'DESC'
|
|
24
|
+
|
|
25
|
+
export type FindOrderOptions<T> = { [K in keyof T]?: FindOrder }
|
|
26
|
+
|
|
27
|
+
export type FindWhereOptions<T> = { [K in keyof T]?: T[K] | T[K][] } |
|
|
28
|
+
Array<{ [K in keyof T]?: T[K] | T[K][] }>
|
package/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './auth.js';
|
|
2
|
+
export * from './common.js'
|
|
3
|
+
export * from './company.js';
|
|
4
|
+
export * from './coreflow.js';
|
|
5
|
+
export * from './cryptor.js';
|
|
6
|
+
export * from './entity.js';
|
|
7
|
+
export * from './find.js';
|
|
8
|
+
export * from './hr.js';
|
|
9
|
+
export * from './resource.js';
|
|
10
|
+
export * from './storage.js';
|
|
11
|
+
export * from './subscription.js';
|
|
12
|
+
export * from './task.js';
|
|
13
|
+
export * from './user.js';
|
package/package.json
CHANGED
package/{API.ts → resource.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type ResourceCollection<T> = {
|
|
2
2
|
message: string;
|
|
3
3
|
data: T[];
|
|
4
4
|
meta: {
|
|
@@ -9,7 +9,7 @@ export type APIResponseCollection<T> = {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type ResourceEntity<T> = {
|
|
13
13
|
message: string;
|
|
14
14
|
data: T;
|
|
15
15
|
}
|
package/storage.ts
ADDED
package/{Task.ts → task.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseEntity } from
|
|
1
|
+
import type { BaseEntity } from './entity.js';
|
|
2
2
|
|
|
3
3
|
export interface Board extends BaseEntity, BoardEntity {
|
|
4
4
|
id: string;
|
|
@@ -14,7 +14,7 @@ export interface BoardEntity {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export enum BoardType {
|
|
17
|
-
|
|
17
|
+
BACKLOG, PROGRESS, DONE
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface Color extends ColorEntity {
|
|
@@ -198,8 +198,8 @@ export interface WorkspaceMemberEntity {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export enum WorkspaceMemberStatus {
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
ACTIVE = "ACTIVE",
|
|
202
|
+
INACTIVE = "INACTIVE"
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
export interface WorkspaceSkill extends BaseEntity, WorkspaceSkillEntity {
|
|
@@ -212,8 +212,8 @@ export interface WorkspaceSkillEntity {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
export enum WorkspaceStatus {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
ACTIVE = "ACTIVE",
|
|
216
|
+
CLOSED = "CLOSED",
|
|
217
|
+
HOLD = "HOLD",
|
|
218
|
+
PLANNED = "PLANNED"
|
|
219
219
|
}
|
package/{User.ts → user.ts}
RENAMED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Company } from './company.js';
|
|
2
|
+
import type { BaseEntity, RelationEntity } from './entity.js';
|
|
3
|
+
import type { Subscription } from './subscription.js';
|
|
4
|
+
import type { Task } from './task.js';
|
|
2
5
|
|
|
3
6
|
export interface Permission extends BaseEntity, PermissionEntity {
|
|
4
7
|
id: string;
|
|
@@ -6,7 +9,8 @@ export interface Permission extends BaseEntity, PermissionEntity {
|
|
|
6
9
|
|
|
7
10
|
export interface PermissionEntity {
|
|
8
11
|
name: string;
|
|
9
|
-
|
|
12
|
+
module: string;
|
|
13
|
+
description?: string;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export interface Role extends BaseEntity, RoleEntity {
|
|
@@ -16,7 +20,17 @@ export interface Role extends BaseEntity, RoleEntity {
|
|
|
16
20
|
export interface RoleEntity {
|
|
17
21
|
company_id: string;
|
|
18
22
|
name: string;
|
|
19
|
-
|
|
23
|
+
is_active: boolean;
|
|
24
|
+
is_owner: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RolePermission extends RelationEntity, RolePermissionEntity {
|
|
28
|
+
id: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RolePermissionEntity {
|
|
32
|
+
role_id: string;
|
|
33
|
+
permission_id: string;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
export interface Skill extends BaseEntity, SkillEntity {
|
|
@@ -40,7 +54,7 @@ export interface UserEntity {
|
|
|
40
54
|
email: string;
|
|
41
55
|
phone?: string;
|
|
42
56
|
is_active: boolean;
|
|
43
|
-
|
|
57
|
+
is_loginable: boolean;
|
|
44
58
|
address?: string;
|
|
45
59
|
avatar?: string;
|
|
46
60
|
gender: UserGender;
|
|
@@ -48,6 +62,11 @@ export interface UserEntity {
|
|
|
48
62
|
birth_place?: string;
|
|
49
63
|
country?: string;
|
|
50
64
|
meta?: UserMeta
|
|
65
|
+
companies?: Company[];
|
|
66
|
+
roles?: Role[];
|
|
67
|
+
skills?: Skill[];
|
|
68
|
+
subscriptions?: Subscription[];
|
|
69
|
+
tasks?: Task[];
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
export interface UserCompany extends BaseEntity, UserCompanyEntity {
|
|
@@ -58,12 +77,13 @@ export interface UserCompanyEntity {
|
|
|
58
77
|
user_id: string;
|
|
59
78
|
company_id: string;
|
|
60
79
|
is_active: boolean;
|
|
80
|
+
is_owner: boolean;
|
|
61
81
|
load?: UserLoad;
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
export enum UserGender {
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
FEMALE = "F",
|
|
86
|
+
MALE = "M"
|
|
67
87
|
}
|
|
68
88
|
|
|
69
89
|
export type UserLoad = {
|
|
@@ -73,9 +93,9 @@ export type UserLoad = {
|
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
export enum UserLoadStatus {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
HIGH = "HIGH",
|
|
97
|
+
MEDIUM = "MEDIUM",
|
|
98
|
+
LOW = "LOW"
|
|
79
99
|
}
|
|
80
100
|
|
|
81
101
|
export type UserMeta = {
|
package/Auth.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export type AccessCompany = {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
is_active: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type AccessRole = {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
permissions: string[];
|
|
11
|
-
company_id: string;
|
|
12
|
-
is_active: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type AccessToken = {
|
|
16
|
-
company: AccessCompany;
|
|
17
|
-
role: AccessRole;
|
|
18
|
-
user: AccessUser;
|
|
19
|
-
iat: number;
|
|
20
|
-
exp: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type AccessUser = {
|
|
24
|
-
id: string;
|
|
25
|
-
username: string;
|
|
26
|
-
name: string;
|
|
27
|
-
email: string;
|
|
28
|
-
phone?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type KeyPair = {
|
|
32
|
-
private?: string;
|
|
33
|
-
public?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type RefreshToken = {
|
|
37
|
-
jti: string;
|
|
38
|
-
iat: number;
|
|
39
|
-
exp: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type RefreshTokenOptions = {
|
|
43
|
-
role_id?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type TokenExpires = {
|
|
47
|
-
accessExpiresIn: string;
|
|
48
|
-
refreshExpiresIn: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type TokenPair = {
|
|
52
|
-
access_token: string;
|
|
53
|
-
refresh_token: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type UserVerify = {
|
|
57
|
-
companies: AccessCompany[];
|
|
58
|
-
jti: string;
|
|
59
|
-
roles: AccessRole[];
|
|
60
|
-
user: AccessUser;
|
|
61
|
-
}
|
package/CoreFlow.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { KeyPair, TokenPair } from "./Auth.js";
|
|
2
|
-
|
|
3
|
-
export interface CoreFlowConfig {
|
|
4
|
-
endpoints?: EndpointList;
|
|
5
|
-
keys?: KeyPair;
|
|
6
|
-
tokens?: TokenPair;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface EndpointList {
|
|
10
|
-
auth?: string;
|
|
11
|
-
company?: string;
|
|
12
|
-
subscription?: string;
|
|
13
|
-
task?: string;
|
|
14
|
-
user?: string;
|
|
15
|
-
}
|
package/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./API.ts";
|
|
2
|
-
export * from "./Auth.ts";
|
|
3
|
-
export * from "./Company.ts";
|
|
4
|
-
export * from "./CoreFlow.ts";
|
|
5
|
-
export * from "./common.ts";
|
|
6
|
-
export * from "./HR.ts";
|
|
7
|
-
export * from "./Subscription.ts";
|
|
8
|
-
export * from "./Task.ts";
|
|
9
|
-
export * from "./User.ts";
|
/package/{HR.ts → hr.ts}
RENAMED
|
File without changes
|