@mitreka/coreflow-types 0.0.6 → 0.0.9

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 CHANGED
@@ -63,6 +63,11 @@ export type AuthorizationRequest = {
63
63
  redirect_uri: string;
64
64
  }
65
65
 
66
+ export type ClientDetail = {
67
+ name: string;
68
+ description?: string;
69
+ }
70
+
66
71
  export type IDToken = {
67
72
  iss: string;
68
73
  aud: string; // Client ID
@@ -91,14 +96,27 @@ export interface OAuthClientEntity {
91
96
  expired_at: Date;
92
97
  }
93
98
 
94
- export interface OAuthGrant {
99
+ export interface OAuthGrant extends OAuthGrantEntity {
95
100
  id: string;
101
+ }
102
+
103
+ export interface OAuthGrantEntity {
96
104
  client_id: string;
97
105
  user_id: string;
106
+ code: string;
98
107
  scopes: string;
99
- is_granted: boolean;
100
- expires_at?: Date;
101
- granted_at: Date;
108
+ auth_code: string;
109
+ redirect_uri: string;
110
+ expired_at?: Date;
111
+ granted_at?: Date;
112
+ }
113
+
114
+ export type OAuthLogin = {
115
+ username: string;
116
+ password: string;
117
+ client_id: string;
118
+ redirect_uri: string;
119
+ scope: string;
102
120
  }
103
121
 
104
122
  export interface OAuthScope extends BaseEntity, OAuthScopeEntity {
@@ -110,6 +128,17 @@ export interface OAuthScopeEntity {
110
128
  description?: string;
111
129
  }
112
130
 
131
+ export interface OAuthSession extends OAuthSessionEntity {
132
+ id: string;
133
+ }
134
+
135
+ export interface OAuthSessionEntity {
136
+ user_id: string;
137
+ ip_address: string;
138
+ user_agent: string;
139
+ expires_at?: Date;
140
+ }
141
+
113
142
  export type RedirectUriOptions = {
114
143
  client_id: string;
115
144
  code_challenge: string;
@@ -133,6 +162,11 @@ export type RefreshTokenOptions = {
133
162
  scope?: string;
134
163
  }
135
164
 
165
+ export type SessionList = {
166
+ active: string;
167
+ list: string[];
168
+ }
169
+
136
170
  export type TokenExpires = {
137
171
  accessExpiresIn: string;
138
172
  refreshExpiresIn: string;
@@ -143,11 +177,6 @@ export type TokenPair = {
143
177
  refresh_token: string;
144
178
  }
145
179
 
146
- export type UserCredentials = {
147
- username: string;
148
- password: string;
149
- }
150
-
151
180
  export type UserSession = {
152
181
  company: AccessCompany;
153
182
  roles: AccessRole[];
package/error.ts ADDED
@@ -0,0 +1,30 @@
1
+ export class HttpError extends Error {
2
+ public readonly status: number;
3
+
4
+ constructor(status: number, message: string) {
5
+ super(message);
6
+ this.name = 'HttpError';
7
+ this.status = status;
8
+ }
9
+ }
10
+
11
+ export class BadRequestError extends HttpError {
12
+ constructor(message: string = 'Bad Request') {
13
+ super(400, message);
14
+ this.name = 'BadRequestError';
15
+ }
16
+ }
17
+
18
+ export class UnauthorizedError extends HttpError {
19
+ constructor(message = 'Unauthorized') {
20
+ super(401, message);
21
+ this.name = 'UnauthorizedError';
22
+ }
23
+ }
24
+
25
+ export class NotFoundError extends HttpError {
26
+ constructor(message: string = 'Not Found') {
27
+ super(404, message);
28
+ this.name = 'NotFoundError';
29
+ }
30
+ }
package/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './company.js';
4
4
  export * from './coreflow.js';
5
5
  export * from './cryptor.js';
6
6
  export * from './entity.js';
7
+ export * from './error.js';
7
8
  export * from './find.js';
8
9
  export * from './hr.js';
9
10
  export * from './resource.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitreka/coreflow-types",
3
- "version": "0.0.6",
3
+ "version": "0.0.9",
4
4
  "description": "CoreFlow Types Definition",
5
5
  "author": {
6
6
  "name": "Riyan Widiyanto",
package/resource.ts CHANGED
@@ -1,12 +1,22 @@
1
+ export type PageMetaData = {
2
+ page: number;
3
+ limit: number;
4
+ total: number;
5
+ total_pages: number;
6
+ }
7
+
1
8
  export type ResourceCollection<T> = {
2
9
  message: string;
3
10
  data: T[];
4
- meta: {
5
- page: number;
6
- limit: number;
7
- total: number;
8
- total_pages: number;
9
- };
11
+ meta: PageMetaData;
12
+ }
13
+
14
+ export type ResourceListRequest = {
15
+ order: string;
16
+ page: number;
17
+ limit: number;
18
+ search: string;
19
+ where: string;
10
20
  }
11
21
 
12
22
  export type ResourceEntity<T> = {