@mitreka/coreflow-types 0.0.3 → 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 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 ADDED
@@ -0,0 +1,4 @@
1
+ export type Point = {
2
+ x: number;
3
+ y: number;
4
+ }
package/company.ts ADDED
@@ -0,0 +1,163 @@
1
+ import type { Point } from './common.js'
2
+ import type { BaseEntity } from './entity.js'
3
+ import type { User } from './user.js';
4
+
5
+ export interface City extends BaseEntity, CityEntity {
6
+ id: string;
7
+ }
8
+
9
+ export interface CityEntity {
10
+ name: string;
11
+ province_id: string;
12
+ }
13
+
14
+ export interface Client extends BaseEntity, ClientEntity {
15
+ id: string;
16
+ }
17
+
18
+ export interface ClientEntity {
19
+ parent_id?: string;
20
+ company_id: string;
21
+ user_am_id: string; // Account Manager
22
+ name: string;
23
+ code: string;
24
+ abbrev: string; // Singkatan
25
+ coordinate?: Point; // Maps
26
+ address?: string;
27
+ }
28
+
29
+ export interface Company extends BaseEntity, CompanyEntity {
30
+ id: string;
31
+ }
32
+
33
+ export interface CompanyEntity {
34
+ name: string;
35
+ address?: string;
36
+ country?: string;
37
+ province?: string;
38
+ city?: string;
39
+ zip_code?: string;
40
+ phone_number?: string;
41
+ email?: string;
42
+ fax?: string;
43
+ website?: string;
44
+ coordinate?: Point;
45
+ radius?: number;
46
+ projects?: Project[];
47
+ users?: User[];
48
+ }
49
+
50
+ export interface Country extends BaseEntity, CountryEntity {
51
+ id: string;
52
+ }
53
+
54
+ export interface CountryEntity {
55
+ country_code: string;
56
+ name: string;
57
+ phone_code?: string;
58
+ }
59
+
60
+ export interface Industry extends BaseEntity, IndustriEntity {
61
+ id: string;
62
+ }
63
+
64
+ export interface IndustriEntity {
65
+ name: string;
66
+ }
67
+
68
+ export interface OrganizationLevel extends BaseEntity, OrganizationLevelEntity {
69
+ id: string;
70
+ }
71
+
72
+ export interface OrganizationLevelEntity {
73
+ company: Company;
74
+ parent?: OrganizationLevel;
75
+ parent_id?: string;
76
+ company_id: string;
77
+ children: OrganizationLevel[];
78
+ name: string;
79
+ code: string;
80
+ level: number;
81
+ is_active: boolean;
82
+ }
83
+
84
+ export interface OrganizationLevelMember extends BaseEntity, OrganizationLevelMemberEntity {
85
+ id: string;
86
+ }
87
+
88
+ export interface OrganizationLevelMemberEntity {
89
+ level: OrganizationLevel;
90
+ organization_level_id: string;
91
+ user_id: string;
92
+ member_role: string;
93
+ is_primary: boolean;
94
+ }
95
+
96
+ export interface OrganizationStructureMember extends BaseEntity, OrganizationStructureMemberEntity {
97
+ version: OrganizationStructureVersion;
98
+ version_id: string;
99
+ node: OrganizationStructureNode;
100
+ node_id: string;
101
+ user_id: string;
102
+ member_role: string;
103
+ is_primary: boolean;
104
+ }
105
+
106
+ export interface OrganizationStructureMemberEntity {
107
+ version: OrganizationStructureVersion;
108
+ version_id: string;
109
+ node: OrganizationStructureNode;
110
+ node_id: string;
111
+ user_id: string;
112
+ member_role: string;
113
+ is_primary: boolean;
114
+ }
115
+
116
+ export interface OrganizationStructureNode extends BaseEntity, OrganizationStructureNodeEntity {
117
+ id: string;
118
+ }
119
+
120
+ export interface OrganizationStructureNodeEntity {
121
+ version: OrganizationStructureVersion;
122
+ version_id: string;
123
+ name: string;
124
+ code: string;
125
+ level: number;
126
+ is_active: boolean;
127
+ parent_node_id?: string;
128
+ source_level_id?: string;
129
+ mpath?: string;
130
+ members: OrganizationStructureMember[];
131
+ }
132
+
133
+ export interface OrganizationStructureVersion extends BaseEntity, OrganizationStructureVersionEntity {
134
+ id: string;
135
+ }
136
+
137
+ export interface OrganizationStructureVersionEntity {
138
+ company_id: string;
139
+ period_type: string;
140
+ period_label: string;
141
+ period_start: string;
142
+ period_end: string;
143
+ decree_no?: string;
144
+ decree_date?: string;
145
+ status: "draft" | "active" | "archived";
146
+ notes?: string;
147
+ nodes: OrganizationStructureNode[];
148
+ }
149
+
150
+ export interface Project extends BaseEntity, ProjectEntity {
151
+ id: string;
152
+ }
153
+
154
+ export interface ProjectEntity {
155
+ company_id: string;
156
+ client_id: string;
157
+ name: string;
158
+ start_date: Date;
159
+ end_date: Date;
160
+ user_pm_id?: string;
161
+ pic_name?: string;
162
+ pic_phone?: string;
163
+ }
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
@@ -0,0 +1,4 @@
1
+ export type CryptorOptions = {
2
+ key: string;
3
+ iv: string;
4
+ }
package/entity.ts ADDED
@@ -0,0 +1,11 @@
1
+ export interface BaseEntity extends RelationEntity {
2
+ deleted_at?: Date;
3
+ deleted_by?: string;
4
+ }
5
+
6
+ export interface RelationEntity {
7
+ created_at: Date;
8
+ created_by: string;
9
+ updated_at?: Date;
10
+ updated_by?: string;
11
+ }
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/hr.ts ADDED
@@ -0,0 +1,3 @@
1
+ export interface Attendance {
2
+ id: string;
3
+ }
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitreka/coreflow-types",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "CoreFlow Types Definition",
5
5
  "author": {
6
6
  "name": "Riyan Widiyanto",
@@ -1,4 +1,4 @@
1
- export type APIResponseCollection<T> = {
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 APIResponseEntity<T> = {
12
+ export type ResourceEntity<T> = {
13
13
  message: string;
14
14
  data: T;
15
15
  }
package/storage.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { BaseEntity } from "./entity.js";
2
+
3
+ export interface Storage extends BaseEntity, StorageEntity {
4
+ id: string;
5
+ }
6
+
7
+ export interface StorageEntity {
8
+
9
+ }
@@ -0,0 +1,19 @@
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
+ }
package/task.ts ADDED
@@ -0,0 +1,219 @@
1
+ import type { BaseEntity } from './entity.js';
2
+
3
+ export interface Board extends BaseEntity, BoardEntity {
4
+ id: string;
5
+ }
6
+
7
+ export interface BoardEntity {
8
+ company_id: string;
9
+ workspace_id: string;
10
+ name: string;
11
+ board_type: BoardType;
12
+ order_no: number;
13
+ order_position: number;
14
+ }
15
+
16
+ export enum BoardType {
17
+ BACKLOG, PROGRESS, DONE
18
+ }
19
+
20
+ export interface Color extends ColorEntity {
21
+ id: string;
22
+ }
23
+
24
+ export interface ColorEntity {
25
+ name: string;
26
+ color_code: string;
27
+ color_order: number;
28
+ }
29
+
30
+ export interface Comment extends BaseEntity, CommentEntity {
31
+ id: string;
32
+ }
33
+
34
+ export interface CommentEntity {
35
+ parent_id: string;
36
+ task_id: string;
37
+ comment_text: string;
38
+ member_id: string;
39
+ }
40
+
41
+ export interface Label {
42
+ id: string;
43
+ workspace_id: string;
44
+ color_id: string;
45
+ }
46
+
47
+ export interface LabelCreate {
48
+ workspace_id: string;
49
+ color_id: string;
50
+ }
51
+
52
+ export interface Priority extends BaseEntity, PriorityEntity {
53
+ id: string;
54
+ }
55
+
56
+ export interface PriorityEntity {
57
+ company_id: string;
58
+ workspace_id: string;
59
+ color_id: string;
60
+ name: string;
61
+ order_position: number;
62
+ }
63
+
64
+ export interface StoryPoint extends BaseEntity, StoryPointEntity {
65
+ id: string;
66
+ }
67
+
68
+ export interface StoryPointEntity {
69
+ story_point_type_id: string;
70
+ story_point_label: string;
71
+ story_point_value: number;
72
+ }
73
+
74
+ export interface StoryPointType {
75
+ id: string;
76
+ name: string;
77
+ }
78
+
79
+ export interface Subtask extends BaseEntity, SubtaskEntity {
80
+ id: string;
81
+ }
82
+
83
+ export interface SubtaskEntity {
84
+ task_id: string;
85
+ subtask_group_id: string;
86
+ name: string;
87
+ is_done: boolean;
88
+ completed_at?: Date;
89
+ completed_by?: string;
90
+ }
91
+
92
+ export interface SubtaskAssignee extends BaseEntity, SubtaskAssigneeEntity {
93
+ id: string;
94
+ }
95
+
96
+ export interface SubtaskAssigneeEntity {
97
+ subtask_id: string;
98
+ member_id: string;
99
+ }
100
+
101
+ export interface SubtaskGroup extends BaseEntity, SubtaskGroupEntity {
102
+ id: string;
103
+ }
104
+
105
+ export interface SubtaskGroupEntity {
106
+ company_id: string;
107
+ task_id: string;
108
+ name: string;
109
+ }
110
+
111
+ export interface Task extends BaseEntity, TaskEntity {
112
+ id: string;
113
+ }
114
+
115
+ export interface TaskEntity {
116
+ company_id: string;
117
+ workspace_id?: string;
118
+ board_id?: string;
119
+ priority_id?: string;
120
+ story_point_id?: string;
121
+ title: string;
122
+ description?: string;
123
+ start_end?: Date;
124
+ due_date?: Date;
125
+ is_due_date: boolean;
126
+ assignee_id?: string;
127
+ assigner_id?: string;
128
+ status_checklist?: number;
129
+ order_position?: string;
130
+ }
131
+
132
+ export interface TaskActivity extends BaseEntity, TaskActivityEntity {
133
+ id: string;
134
+ }
135
+
136
+ export interface TaskActivityEntity {
137
+ task_id: string;
138
+ message: string;
139
+ }
140
+
141
+ export interface TaskAttachment extends BaseEntity, TaskActivityEntity {
142
+ id: string;
143
+ }
144
+
145
+ export interface TaskAttachmentEntity {
146
+ task_id: string;
147
+ upload_id: string;
148
+ file_name: string;
149
+ file_type: string;
150
+ size: number;
151
+ }
152
+
153
+ export interface TaskLabel extends BaseEntity, TaskLabelEntity {
154
+ id: string;
155
+ }
156
+
157
+ export interface TaskLabelEntity {
158
+ task_id: string;
159
+ label_id: string;
160
+ }
161
+
162
+ export interface TaskMember extends BaseEntity, TaskMemberEntity {
163
+ id: string;
164
+ }
165
+
166
+ export interface TaskMemberEntity {
167
+ task_id: string;
168
+ member_id: string;
169
+ }
170
+
171
+ export interface Workspace extends BaseEntity, WorkspaceEntity {
172
+ id: string;
173
+ }
174
+
175
+ export interface WorkspaceEntity {
176
+ color_id: string;
177
+ company_id: string;
178
+ title: string;
179
+ description: string;
180
+ order_position: number;
181
+ project_manager_id: string;
182
+ story_point_type_id: string;
183
+ workspace_status: WorkspaceStatus;
184
+ }
185
+
186
+ export interface WorkspaceMember extends BaseEntity, WorkspaceMemberEntity {
187
+ id: string;
188
+ }
189
+
190
+ export interface WorkspaceMemberEntity {
191
+ workspace_id: string;
192
+ member_id: string;
193
+ position_id: string;
194
+ email: string;
195
+ role: string;
196
+ is_favorite: boolean;
197
+ workspace_member_status: WorkspaceMemberStatus;
198
+ }
199
+
200
+ export enum WorkspaceMemberStatus {
201
+ ACTIVE = "ACTIVE",
202
+ INACTIVE = "INACTIVE"
203
+ }
204
+
205
+ export interface WorkspaceSkill extends BaseEntity, WorkspaceSkillEntity {
206
+ id: string;
207
+ }
208
+
209
+ export interface WorkspaceSkillEntity {
210
+ workspace_id: string;
211
+ skill_id: string;
212
+ }
213
+
214
+ export enum WorkspaceStatus {
215
+ ACTIVE = "ACTIVE",
216
+ CLOSED = "CLOSED",
217
+ HOLD = "HOLD",
218
+ PLANNED = "PLANNED"
219
+ }