@mitreka/coreflow-types 0.0.18 → 0.0.19
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/README.md +74 -1
- package/auth.ts +8 -5
- package/company.ts +15 -2
- package/find.ts +0 -3
- package/index.ts +1 -3
- package/package.json +1 -1
- package/plan.ts +29 -0
- package/user.ts +19 -55
- package/hr.ts +0 -3
- package/storage.ts +0 -9
- package/subscription.ts +0 -19
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
1
|
# CoreFlow Types Definition
|
|
2
|
+
All entities must extend either `BaseEntity` or `RelationEntity`. For example we assume `User` interface is `BaseEntity` and `UserRole` interface is `RelationEntity`.
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
`entity.ts`
|
|
5
|
+
```ts
|
|
6
|
+
export interface BaseEntity extends RelationEntity {
|
|
7
|
+
deleted_at?: Date;
|
|
8
|
+
deleted_by?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RelationEntity {
|
|
12
|
+
created_at: Date;
|
|
13
|
+
created_by: string;
|
|
14
|
+
updated_at?: Date;
|
|
15
|
+
updated_by?: string;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Base Entity
|
|
20
|
+
If you have base schema like this:
|
|
21
|
+
|
|
22
|
+
```sql
|
|
23
|
+
CREATE TABLE users (
|
|
24
|
+
"id" primary character varying(255) not null,
|
|
25
|
+
"name" character varying(255) not null,
|
|
26
|
+
"email" character varying(255) not null,
|
|
27
|
+
"password" character varying(255) not null,
|
|
28
|
+
"created_at" timestamp not null default now(),
|
|
29
|
+
"created_by" bigserial not null,
|
|
30
|
+
"updated_at" timestamp,
|
|
31
|
+
"updated_by" bigserial,
|
|
32
|
+
"deleted_at" timestamp,
|
|
33
|
+
"deleted_by" bigserial
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then you have to make the entities like these:
|
|
38
|
+
```ts
|
|
39
|
+
export interface UserEntity extends BaseEntity {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
email: string;
|
|
43
|
+
password: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type User = Omit<UserEntity, 'id' | keyof BaseEntity>;
|
|
47
|
+
export type UserRequest = QueryFilters & BaseEntityFilters & User;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Relation Entity
|
|
51
|
+
|
|
52
|
+
If you have relation schema like this:
|
|
53
|
+
|
|
54
|
+
```sql
|
|
55
|
+
CREATE TABLE user_roles (
|
|
56
|
+
"id" primary character varying(255) not null,
|
|
57
|
+
"user_id" character varying(255) not null,
|
|
58
|
+
"role_id" character varying(255) not null,
|
|
59
|
+
"created_at" timestamp not null default now(),
|
|
60
|
+
"created_by" bigserial not null,
|
|
61
|
+
"updated_at" timestamp,
|
|
62
|
+
"updated_by" bigserial
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then you have to make the entities like these:
|
|
67
|
+
```ts
|
|
68
|
+
export interface UserRoleEntity extends RelationEntity {
|
|
69
|
+
id: string;
|
|
70
|
+
user_id: string;
|
|
71
|
+
role_id: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type User = Omit<UserEntity, 'id' | keyof BaseEntity>;
|
|
75
|
+
export type UserRequest = QueryFilters & BaseEntityFilters & User;
|
|
76
|
+
```
|
package/auth.ts
CHANGED
|
@@ -26,7 +26,10 @@ export type AuthGrantType = 'authorization_code' | 'refresh_token';
|
|
|
26
26
|
export type AuthPrompt = 'none' | 'select_account';
|
|
27
27
|
export type AuthResponseType = 'code' | 'token';
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Authorization params.
|
|
31
|
+
*/
|
|
32
|
+
export type AuthorizationParams = {
|
|
30
33
|
client_id: string;
|
|
31
34
|
client_secret: string;
|
|
32
35
|
code: string;
|
|
@@ -46,22 +49,22 @@ export type AuthorizationParam = {
|
|
|
46
49
|
user_id: string;
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
export type AuthorizationCallback = Pick<
|
|
52
|
+
export type AuthorizationCallback = Pick<AuthorizationParams, 'code' | 'error' | 'state'>;
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
55
|
* Authorization exchange
|
|
53
56
|
*/
|
|
54
|
-
export type AuthorizationExchange = Pick<
|
|
57
|
+
export type AuthorizationExchange = Pick<AuthorizationParams, 'client_id' | 'client_secret' | 'code' | 'code_verifier' | 'grant_type' | 'redirect_uri' | 'token_version'>;
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Authorization refresh
|
|
58
61
|
*/
|
|
59
|
-
export type AuthorizationRefresh = Pick<
|
|
62
|
+
export type AuthorizationRefresh = Pick<AuthorizationParams, 'client_id' | 'client_secret' | 'company_id' | 'grant_type' | 'refresh_token'>;
|
|
60
63
|
|
|
61
64
|
/**
|
|
62
65
|
* Authorization request
|
|
63
66
|
*/
|
|
64
|
-
export type AuthorizationRequest = Omit<
|
|
67
|
+
export type AuthorizationRequest = Omit<AuthorizationParams, 'client_secret' | 'code' | 'code_verifier' | 'company_id' | 'error' | 'grant_type' | 'refresh_token'>;
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* Authorize client
|
package/company.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Point } from './common.js'
|
|
2
|
-
import type { BaseEntity } from './entity.js'
|
|
3
|
-
import type { BaseEntityFilters, QueryFilters } from './filter.js';
|
|
2
|
+
import type { BaseEntity, RelationEntity } from './entity.js'
|
|
3
|
+
import type { BaseEntityFilters, QueryFilters, RelationEntityFilters } from './filter.js';
|
|
4
4
|
|
|
5
5
|
export interface CityEntity extends BaseEntity {
|
|
6
6
|
id: string;
|
|
@@ -68,6 +68,19 @@ export type CompanyRequest = QueryFilters & BaseEntityFilters & {
|
|
|
68
68
|
website: string;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
export interface CompanyPlanEntity extends RelationEntity {
|
|
72
|
+
id: string;
|
|
73
|
+
company_id: string;
|
|
74
|
+
plan_id: string;
|
|
75
|
+
price: number;
|
|
76
|
+
start_date: Date;
|
|
77
|
+
end_date: Date;
|
|
78
|
+
is_active: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type CompanyPlan = Omit<CompanyPlanEntity, 'id' | keyof RelationEntity>;
|
|
81
|
+
export type CompanyPlanRequest = QueryFilters & RelationEntityFilters & CompanyPlan;
|
|
82
|
+
|
|
83
|
+
|
|
71
84
|
export interface CountryEntity extends BaseEntity {
|
|
72
85
|
id: string;
|
|
73
86
|
country_code: string;
|
package/find.ts
CHANGED
package/index.ts
CHANGED
|
@@ -8,8 +8,6 @@ export * from './entity.js';
|
|
|
8
8
|
export * from './error.js';
|
|
9
9
|
export * from './find.js';
|
|
10
10
|
export * from './filter.js';
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './storage.js';
|
|
13
|
-
export * from './subscription.js';
|
|
11
|
+
export * from './plan.js';
|
|
14
12
|
export * from './task.js';
|
|
15
13
|
export * from './user.js';
|
package/package.json
CHANGED
package/plan.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseEntity, RelationEntity } from './entity.js';
|
|
2
|
+
import { type BaseEntityFilters, type QueryFilters, type RelationEntityFilters } from './filter.js';
|
|
3
|
+
|
|
4
|
+
export enum PeriodType {
|
|
5
|
+
MONTH = 'month',
|
|
6
|
+
YEAR = 'year'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface PlanEntity extends BaseEntity {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
price: number;
|
|
14
|
+
promo_price: number;
|
|
15
|
+
period_duration: number;
|
|
16
|
+
period_type: PeriodType;
|
|
17
|
+
};
|
|
18
|
+
// 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
|
|
19
|
+
export type Plan = Omit<PlanEntity, 'id' | keyof BaseEntity>;
|
|
20
|
+
export type PlanRequest = QueryFilters & BaseEntityFilters & Plan;
|
|
21
|
+
|
|
22
|
+
export interface PlanPermissionEntity extends RelationEntity {
|
|
23
|
+
id: string;
|
|
24
|
+
plan_id: string;
|
|
25
|
+
permission_id: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type PlanPermission = Omit<PlanPermissionEntity, 'id' | keyof RelationEntity>;
|
|
29
|
+
export type PlanPermissionRequest = QueryFilters & RelationEntityFilters & PlanPermission;
|
package/user.ts
CHANGED
|
@@ -6,15 +6,11 @@ export interface PermissionEntity extends BaseEntity {
|
|
|
6
6
|
name: string;
|
|
7
7
|
module: string;
|
|
8
8
|
description?: string;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
export type Permission = Omit<PermissionEntity, 'id' | keyof BaseEntity>;
|
|
12
|
-
export type PermissionRequest = QueryFilters & BaseEntityFilters &
|
|
13
|
-
|
|
14
|
-
name: string;
|
|
15
|
-
module: string;
|
|
16
|
-
description: string;
|
|
17
|
-
};
|
|
12
|
+
export type PermissionRequest = QueryFilters & BaseEntityFilters &
|
|
13
|
+
Omit<PermissionEntity, keyof BaseEntity>;
|
|
18
14
|
|
|
19
15
|
export interface RoleEntity extends BaseEntity {
|
|
20
16
|
id: string;
|
|
@@ -22,22 +18,17 @@ export interface RoleEntity extends BaseEntity {
|
|
|
22
18
|
name: string;
|
|
23
19
|
is_active: boolean;
|
|
24
20
|
is_owner: boolean;
|
|
25
|
-
}
|
|
21
|
+
};
|
|
26
22
|
|
|
27
23
|
export type Role = Omit<RoleEntity, 'id' | keyof BaseEntity>;
|
|
28
|
-
export type RoleRequest = QueryFilters & BaseEntityFilters &
|
|
29
|
-
|
|
30
|
-
company_id: string;
|
|
31
|
-
name: string;
|
|
32
|
-
is_active: string;
|
|
33
|
-
is_owner: string;
|
|
34
|
-
};
|
|
24
|
+
export type RoleRequest = QueryFilters & BaseEntityFilters &
|
|
25
|
+
Omit<RoleEntity, keyof BaseEntity>;
|
|
35
26
|
|
|
36
27
|
export interface RolePermissionEntity extends RelationEntity {
|
|
37
28
|
id: string;
|
|
38
29
|
role_id: string;
|
|
39
30
|
permission_id: string;
|
|
40
|
-
}
|
|
31
|
+
};
|
|
41
32
|
|
|
42
33
|
export type RolePermission = Omit<RolePermissionEntity, 'id' | keyof BaseEntity>;
|
|
43
34
|
export type RolePermissionRequest = QueryFilters & RolePermissionEntity;
|
|
@@ -47,7 +38,7 @@ export interface SkillEntity extends BaseEntity {
|
|
|
47
38
|
company_id: string;
|
|
48
39
|
parent_id: string;
|
|
49
40
|
name: string;
|
|
50
|
-
}
|
|
41
|
+
};
|
|
51
42
|
|
|
52
43
|
export type Skill = Omit<SkillEntity, 'id' | keyof BaseEntity>;
|
|
53
44
|
export type SkillRequest = QueryFilters & SkillEntity;
|
|
@@ -67,23 +58,11 @@ export interface UserEntity extends BaseEntity {
|
|
|
67
58
|
birth_place?: string;
|
|
68
59
|
country?: string;
|
|
69
60
|
meta?: UserMeta;
|
|
70
|
-
}
|
|
61
|
+
};
|
|
71
62
|
|
|
72
63
|
export type User = Omit<UserEntity, 'id' | keyof BaseEntity>;
|
|
73
|
-
export type UserRequest = QueryFilters & BaseEntityFilters &
|
|
74
|
-
|
|
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
|
-
};
|
|
64
|
+
export type UserRequest = QueryFilters & BaseEntityFilters &
|
|
65
|
+
Omit<User, 'password' | 'meta' | keyof BaseEntity>;
|
|
87
66
|
|
|
88
67
|
export interface UserCompanyEntity extends RelationEntity {
|
|
89
68
|
id: string;
|
|
@@ -92,7 +71,7 @@ export interface UserCompanyEntity extends RelationEntity {
|
|
|
92
71
|
is_admin: boolean;
|
|
93
72
|
is_primary: boolean;
|
|
94
73
|
load?: UserLoad;
|
|
95
|
-
}
|
|
74
|
+
};
|
|
96
75
|
|
|
97
76
|
export type UserCompany = Omit<UserCompanyEntity, 'id' | keyof RelationEntity>;
|
|
98
77
|
export type UserCompanyRequest = QueryFilters & RelationEntityFilters & {
|
|
@@ -106,7 +85,7 @@ export type UserCompanyRequest = QueryFilters & RelationEntityFilters & {
|
|
|
106
85
|
export enum UserGender {
|
|
107
86
|
FEMALE = "F",
|
|
108
87
|
MALE = "M"
|
|
109
|
-
}
|
|
88
|
+
};
|
|
110
89
|
|
|
111
90
|
export type UserLoad = {
|
|
112
91
|
status: UserLoadStatus;
|
|
@@ -118,7 +97,7 @@ export enum UserLoadStatus {
|
|
|
118
97
|
HIGH = "HIGH",
|
|
119
98
|
MEDIUM = "MEDIUM",
|
|
120
99
|
LOW = "LOW"
|
|
121
|
-
}
|
|
100
|
+
};
|
|
122
101
|
|
|
123
102
|
export type UserMeta = {
|
|
124
103
|
token: string;
|
|
@@ -128,7 +107,7 @@ export interface UserRoleEntity extends RelationEntity {
|
|
|
128
107
|
id: string;
|
|
129
108
|
user_id: string;
|
|
130
109
|
role_id: string;
|
|
131
|
-
}
|
|
110
|
+
};
|
|
132
111
|
|
|
133
112
|
export type UserRole = Omit<UserRoleEntity, 'id' | keyof RelationEntity>;
|
|
134
113
|
export type UserRoleRequest = QueryFilters & RelationEntityFilters &
|
|
@@ -138,7 +117,7 @@ export interface UserRoleCreate {
|
|
|
138
117
|
user_id: string;
|
|
139
118
|
role_id: string;
|
|
140
119
|
is_active: boolean;
|
|
141
|
-
}
|
|
120
|
+
};
|
|
142
121
|
|
|
143
122
|
export interface UserSkill {
|
|
144
123
|
id: string;
|
|
@@ -146,26 +125,11 @@ export interface UserSkill {
|
|
|
146
125
|
skill_id: string;
|
|
147
126
|
created_at: Date;
|
|
148
127
|
created_by: string;
|
|
149
|
-
}
|
|
128
|
+
};
|
|
150
129
|
|
|
151
130
|
export interface UserSkillCreate {
|
|
152
131
|
user_id: string;
|
|
153
132
|
skill_id: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export type UserSkillRequest = QueryFilters & RelationEntityFilters & UserSkill;
|
|
157
|
-
|
|
158
|
-
export interface UserSubscription {
|
|
159
|
-
id: string;
|
|
160
|
-
user_id: string;
|
|
161
|
-
subscription_id: string;
|
|
162
|
-
start_date?: Date;
|
|
163
|
-
end_date?: Date;
|
|
164
|
-
}
|
|
133
|
+
};
|
|
165
134
|
|
|
166
|
-
export
|
|
167
|
-
user_id: string;
|
|
168
|
-
subscription_id: string;
|
|
169
|
-
start_date?: Date;
|
|
170
|
-
end_date?: Date;
|
|
171
|
-
}
|
|
135
|
+
export type UserSkillRequest = QueryFilters & RelationEntityFilters & UserSkill;
|
package/hr.ts
DELETED
package/storage.ts
DELETED
package/subscription.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BaseEntity } from './entity.js';
|
|
2
|
-
|
|
3
|
-
export interface Subscriber extends BaseEntity, SubscriberEntity {
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface SubscriberEntity {
|
|
8
|
-
email: string;
|
|
9
|
-
is_validated: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Subscription extends BaseEntity, SubscriptionEntity {
|
|
13
|
-
id: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SubscriptionEntity {
|
|
17
|
-
name: string;
|
|
18
|
-
price: number;
|
|
19
|
-
}
|