@drax/identity-front 0.5.3 → 0.5.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/package.json +4 -4
- package/src/factory/AuthSystemFactory.ts +32 -0
- package/src/factory/RoleSystemFactory.ts +32 -0
- package/src/factory/UserApiKeySystemFactory.ts +32 -0
- package/src/factory/UserSystemFactory.ts +32 -0
- package/src/i18n/identity-role-i18n.ts +18 -16
- package/src/i18n/identity-tenant-i18n.ts +2 -10
- package/src/i18n/identity-user-i18n.ts +53 -44
- package/src/index.ts +8 -2
- package/src/interfaces/IRoleProvider.ts +2 -2
- package/src/interfaces/IUserApiKeyProvider.ts +2 -3
- package/src/interfaces/IUserProvider.ts +2 -2
- package/src/providers/gql/RoleGqlProvider.ts +17 -4
- package/src/providers/gql/TenantGqlProvider.ts +15 -4
- package/src/providers/gql/UserApiKeyGqlProvider.ts +14 -3
- package/src/providers/gql/UserGqlProvider.ts +14 -3
- package/src/providers/rest/RoleRestProvider.ts +28 -1
- package/src/providers/rest/TenantRestProvider.ts +6 -0
- package/src/providers/rest/UserApiKeyRestProvider.ts +14 -9
- package/src/providers/rest/UserRestProvider.ts +30 -1
- package/src/system/AuthSystem.ts +1 -1
- package/src/system/RoleSystem.ts +46 -5
- package/src/system/TenantSystem.ts +13 -3
- package/src/system/UserApiKeySystem.ts +14 -5
- package/src/system/UserSystem.ts +45 -6
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
6
|
+
"version": "0.5.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"format": "prettier --write src/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drax/common-front": "^0.5.
|
|
28
|
-
"@drax/crud-share": "^0.5.
|
|
27
|
+
"@drax/common-front": "^0.5.5",
|
|
28
|
+
"@drax/crud-share": "^0.5.5",
|
|
29
29
|
"@drax/identity-share": "^0.5.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"vite-plugin-dts": "^3.9.1",
|
|
49
49
|
"vitest": "^1.4.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "c89751dd8eb2ede7d565b596f698c2b83e0c2fed"
|
|
52
52
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import AuthSystem from "../system/AuthSystem.js";
|
|
2
|
+
import AuthGqlProvider from "../providers/gql/AuthGqlProvider.js";
|
|
3
|
+
import AuthRestClientProvider from "../providers/rest/AuthRestProvider.js";
|
|
4
|
+
import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
|
|
5
|
+
const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
|
|
6
|
+
|
|
7
|
+
class AuthSystemFactory{
|
|
8
|
+
|
|
9
|
+
static singleton: AuthSystem
|
|
10
|
+
|
|
11
|
+
static getInstance(httpTransport: string = HTTP_TRANSPORT): AuthSystem {
|
|
12
|
+
if(!AuthSystemFactory.singleton){
|
|
13
|
+
if(httpTransport === 'GRAPHQL') {
|
|
14
|
+
const httpGqlClient = HttpGqlClientFactory.getInstance()
|
|
15
|
+
const provider = new AuthGqlProvider(httpGqlClient)
|
|
16
|
+
AuthSystemFactory.singleton = new AuthSystem(provider)
|
|
17
|
+
} else if(httpTransport === 'REST') {
|
|
18
|
+
const httpRestClient = HttpRestClientFactory.getInstance()
|
|
19
|
+
const provider = new AuthRestClientProvider(httpRestClient)
|
|
20
|
+
AuthSystemFactory.singleton = new AuthSystem(provider)
|
|
21
|
+
}else{
|
|
22
|
+
throw new Error('AuthSystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return AuthSystemFactory.singleton
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default AuthSystemFactory
|
|
32
|
+
export {AuthSystemFactory}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import RoleSystem from "../system/RoleSystem.js";
|
|
2
|
+
import RoleGqlProvider from "../providers/gql/RoleGqlProvider.js";
|
|
3
|
+
import RoleRestClientProvider from "../providers/rest/RoleRestProvider.js";
|
|
4
|
+
import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
|
|
5
|
+
const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
|
|
6
|
+
|
|
7
|
+
class RoleSystemFactory{
|
|
8
|
+
|
|
9
|
+
static singleton: RoleSystem
|
|
10
|
+
|
|
11
|
+
static getInstance(httpTransport: string = HTTP_TRANSPORT): RoleSystem {
|
|
12
|
+
if(!RoleSystemFactory.singleton){
|
|
13
|
+
if(httpTransport === 'GRAPHQL') {
|
|
14
|
+
const httpGqlClient = HttpGqlClientFactory.getInstance()
|
|
15
|
+
const provider = new RoleGqlProvider(httpGqlClient)
|
|
16
|
+
RoleSystemFactory.singleton = new RoleSystem(provider)
|
|
17
|
+
} else if(httpTransport === 'REST') {
|
|
18
|
+
const httpRestClient = HttpRestClientFactory.getInstance()
|
|
19
|
+
const provider = new RoleRestClientProvider(httpRestClient)
|
|
20
|
+
RoleSystemFactory.singleton = new RoleSystem(provider)
|
|
21
|
+
}else{
|
|
22
|
+
throw new Error('RoleSystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return RoleSystemFactory.singleton
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default RoleSystemFactory
|
|
32
|
+
export {RoleSystemFactory}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import UserApiKeySystem from "../system/UserApiKeySystem.js";
|
|
2
|
+
import UserApiKeyGqlProvider from "../providers/gql/UserApiKeyGqlProvider.js";
|
|
3
|
+
import UserApiKeyRestClientProvider from "../providers/rest/UserApiKeyRestProvider.js";
|
|
4
|
+
import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
|
|
5
|
+
const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
|
|
6
|
+
|
|
7
|
+
class UserApiKeySystemFactory{
|
|
8
|
+
|
|
9
|
+
static singleton: UserApiKeySystem
|
|
10
|
+
|
|
11
|
+
static getInstance(httpTransport: string = HTTP_TRANSPORT): UserApiKeySystem {
|
|
12
|
+
if(!UserApiKeySystemFactory.singleton){
|
|
13
|
+
if(httpTransport === 'GRAPHQL') {
|
|
14
|
+
const httpGqlClient = HttpGqlClientFactory.getInstance()
|
|
15
|
+
const provider = new UserApiKeyGqlProvider(httpGqlClient)
|
|
16
|
+
UserApiKeySystemFactory.singleton = new UserApiKeySystem(provider)
|
|
17
|
+
} else if(httpTransport === 'REST') {
|
|
18
|
+
const httpRestClient = HttpRestClientFactory.getInstance()
|
|
19
|
+
const provider = new UserApiKeyRestClientProvider(httpRestClient)
|
|
20
|
+
UserApiKeySystemFactory.singleton = new UserApiKeySystem(provider)
|
|
21
|
+
}else{
|
|
22
|
+
throw new Error('UserApiKeySystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return UserApiKeySystemFactory.singleton
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default UserApiKeySystemFactory
|
|
32
|
+
export {UserApiKeySystemFactory}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import UserSystem from "../system/UserSystem.js";
|
|
2
|
+
import UserGqlProvider from "../providers/gql/UserGqlProvider.js";
|
|
3
|
+
import UserRestClientProvider from "../providers/rest/UserRestProvider.js";
|
|
4
|
+
import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
|
|
5
|
+
const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
|
|
6
|
+
|
|
7
|
+
class UserSystemFactory{
|
|
8
|
+
|
|
9
|
+
static singleton: UserSystem
|
|
10
|
+
|
|
11
|
+
static getInstance(httpTransport: string = HTTP_TRANSPORT): UserSystem {
|
|
12
|
+
if(!UserSystemFactory.singleton){
|
|
13
|
+
if(httpTransport === 'GRAPHQL') {
|
|
14
|
+
const httpGqlClient = HttpGqlClientFactory.getInstance()
|
|
15
|
+
const provider = new UserGqlProvider(httpGqlClient)
|
|
16
|
+
UserSystemFactory.singleton = new UserSystem(provider)
|
|
17
|
+
} else if(httpTransport === 'REST') {
|
|
18
|
+
const httpRestClient = HttpRestClientFactory.getInstance()
|
|
19
|
+
const provider = new UserRestClientProvider(httpRestClient)
|
|
20
|
+
UserSystemFactory.singleton = new UserSystem(provider)
|
|
21
|
+
}else{
|
|
22
|
+
throw new Error('UserSystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return UserSystemFactory.singleton
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default UserSystemFactory
|
|
32
|
+
export {UserSystemFactory}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
const messages = {
|
|
2
2
|
en: {
|
|
3
3
|
role: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
entity: 'Role',
|
|
5
|
+
menu: 'Roles',
|
|
6
|
+
crud: 'Manage Roles',
|
|
7
|
+
field:{
|
|
8
|
+
name: "Name",
|
|
9
|
+
permissions: "Username",
|
|
10
|
+
childRoles: "ChildRoles",
|
|
11
|
+
readonly: "Read Only",
|
|
12
|
+
}
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
es: {
|
|
15
16
|
role:{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
entity: 'Rol',
|
|
18
|
+
menu: 'Roles',
|
|
19
|
+
crud: 'Gestionando Roles',
|
|
20
|
+
field:{
|
|
21
|
+
name: "Nombre",
|
|
22
|
+
permissions: "Permisos",
|
|
23
|
+
childRoles: "Roles gestionados",
|
|
24
|
+
readonly: "Solo lectura",
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -4,11 +4,7 @@ const messages = {
|
|
|
4
4
|
entity: "Tenant",
|
|
5
5
|
name: "Name",
|
|
6
6
|
createdAt: 'Created At',
|
|
7
|
-
|
|
8
|
-
creating: "Creating Tenant",
|
|
9
|
-
deleting: "Deleting Tenant",
|
|
10
|
-
managing: 'Managing Tenant',
|
|
11
|
-
fields:{
|
|
7
|
+
field:{
|
|
12
8
|
id: 'ID',
|
|
13
9
|
name: 'Name'
|
|
14
10
|
}
|
|
@@ -19,11 +15,7 @@ const messages = {
|
|
|
19
15
|
entity: "Tenant",
|
|
20
16
|
name: "Nombre",
|
|
21
17
|
createdAt: 'Creado',
|
|
22
|
-
|
|
23
|
-
creating: "Creando Tenant",
|
|
24
|
-
deleting: "Eliminando Tenant",
|
|
25
|
-
managing: 'Gestionando Tenant',
|
|
26
|
-
fields:{
|
|
18
|
+
field:{
|
|
27
19
|
id: 'ID',
|
|
28
20
|
name: 'Nombre'
|
|
29
21
|
}
|
|
@@ -1,58 +1,67 @@
|
|
|
1
1
|
const messages = {
|
|
2
2
|
en: {
|
|
3
3
|
user: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
email: "Email",
|
|
7
|
-
password: "Password",
|
|
8
|
-
phone: "Phone",
|
|
9
|
-
avatar: "Avatar",
|
|
10
|
-
role: "Role",
|
|
11
|
-
tenant: "Tenant",
|
|
12
|
-
active: "Active",
|
|
13
|
-
groups: "Groups",
|
|
4
|
+
entity: 'User',
|
|
5
|
+
profile:'Profile',
|
|
14
6
|
code: "Code",
|
|
15
|
-
currentPassword: "Current Password",
|
|
16
|
-
newPassword: "New Password",
|
|
17
|
-
confirmPassword: "Confirm Password",
|
|
18
|
-
changeOwnPassword: "Change Password",
|
|
19
7
|
passwordChanged: "Password Changed",
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
operation: {
|
|
9
|
+
changePassword: "Changing User Password",
|
|
10
|
+
},
|
|
11
|
+
action: {
|
|
12
|
+
changePassword: "Change Password",
|
|
13
|
+
changeOwnPassword: "Change Password",
|
|
14
|
+
login:'Login',
|
|
15
|
+
logout:'Logout',
|
|
16
|
+
},
|
|
17
|
+
field: {
|
|
18
|
+
name: "Name",
|
|
19
|
+
username: "Username",
|
|
20
|
+
email: "Email",
|
|
21
|
+
password: "Password",
|
|
22
|
+
phone: "Phone",
|
|
23
|
+
avatar: "Avatar",
|
|
24
|
+
role: "Role",
|
|
25
|
+
tenant: "Tenant",
|
|
26
|
+
active: "Active",
|
|
27
|
+
groups: "Groups",
|
|
28
|
+
currentPassword: "Current Password",
|
|
29
|
+
newPassword: "New Password",
|
|
30
|
+
confirmPassword: "Confirm Password",
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
es: {
|
|
31
35
|
user:{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
password: "Clave",
|
|
36
|
-
phone: "Télefono",
|
|
37
|
-
avatar: "Avatar",
|
|
38
|
-
role: "Rol",
|
|
39
|
-
tenant: "Tenant",
|
|
40
|
-
active: "Activo",
|
|
41
|
-
groups: "Grupos",
|
|
36
|
+
entity: 'Usuario',
|
|
37
|
+
|
|
38
|
+
profile:'Perfil',
|
|
42
39
|
code: "Codigo",
|
|
43
|
-
currentPassword: "Clave Actual",
|
|
44
|
-
newPassword: "Nueva Clave",
|
|
45
|
-
confirmPassword: "Confirmar Clave",
|
|
46
|
-
changeOwnPassword: "Cambiar Clave",
|
|
47
40
|
passwordChanged: "Clave Cambiada",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
operation: {
|
|
42
|
+
changePassword: "Cambiando Clave de Usuario",
|
|
43
|
+
},
|
|
44
|
+
action: {
|
|
45
|
+
changePassword: "Cambiar Clave",
|
|
46
|
+
changeOwnPassword: "Cambiar Clave",
|
|
47
|
+
login:'Iniciar Sesión',
|
|
48
|
+
logout:'Cerrar Sesión',
|
|
49
|
+
},
|
|
50
|
+
field: {
|
|
51
|
+
name: "Nombre",
|
|
52
|
+
username: "Usuario",
|
|
53
|
+
email: "Email",
|
|
54
|
+
password: "Clave",
|
|
55
|
+
phone: "Télefono",
|
|
56
|
+
avatar: "Avatar",
|
|
57
|
+
role: "Rol",
|
|
58
|
+
tenant: "Tenant",
|
|
59
|
+
active: "Activo",
|
|
60
|
+
groups: "Grupos",
|
|
61
|
+
currentPassword: "Clave Actual",
|
|
62
|
+
newPassword: "Nueva Clave",
|
|
63
|
+
confirmPassword: "Confirmar Clave",
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,22 +4,24 @@ import {jwtDecodeHelper} from "./helpers/JwtDecodeHelper.js"
|
|
|
4
4
|
import AuthRestProvider from "./providers/rest/AuthRestProvider.js";
|
|
5
5
|
import AuthGqlProvider from "./providers/gql/AuthGqlProvider.js";
|
|
6
6
|
import AuthSystem from "./system/AuthSystem.js"
|
|
7
|
-
|
|
7
|
+
import AuthSystemFactory from "./factory/AuthSystemFactory.js"
|
|
8
8
|
|
|
9
9
|
import UserRestProvider from "./providers/rest/UserRestProvider.js";
|
|
10
10
|
import UserGqlProvider from "./providers/gql/UserGqlProvider.js";
|
|
11
11
|
import UserSystem from "./system/UserSystem.js"
|
|
12
|
+
import UserSystemFactory from "./factory/UserSystemFactory.js"
|
|
12
13
|
|
|
13
14
|
import UserApiKeyRestProvider from "./providers/rest/UserApiKeyRestProvider.js";
|
|
14
15
|
import UserApiKeyGqlProvider from "./providers/gql/UserApiKeyGqlProvider.js";
|
|
15
16
|
import UserApiKeySystem from "./system/UserApiKeySystem.js"
|
|
17
|
+
import UserApiKeySystemFactory from "./factory/UserApiKeySystemFactory.js"
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
import RoleRestProvider from "./providers/rest/RoleRestProvider.js";
|
|
20
22
|
import RoleGqlProvider from "./providers/gql/RoleGqlProvider.js";
|
|
21
23
|
import RoleSystem from "./system/RoleSystem.js"
|
|
22
|
-
|
|
24
|
+
import RoleSystemFactory from "./factory/RoleSystemFactory.js"
|
|
23
25
|
|
|
24
26
|
import TenantRestProvider from "./providers/rest/TenantRestProvider.js";
|
|
25
27
|
import TenantGqlProvider from "./providers/gql/TenantGqlProvider.js";
|
|
@@ -75,7 +77,11 @@ export {
|
|
|
75
77
|
UserApiKeySystem,
|
|
76
78
|
|
|
77
79
|
//Factory
|
|
80
|
+
AuthSystemFactory,
|
|
81
|
+
UserSystemFactory,
|
|
82
|
+
RoleSystemFactory,
|
|
78
83
|
TenantSystemFactory,
|
|
84
|
+
UserApiKeySystemFactory,
|
|
79
85
|
|
|
80
86
|
//Helpers
|
|
81
87
|
AuthHelper,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {IRole, IRoleBase} from "@drax/identity-share";
|
|
2
|
-
import type {
|
|
2
|
+
import type {IDraxCrudProvider} from "@drax/crud-share";
|
|
3
3
|
|
|
4
|
-
interface IRoleProvider extends
|
|
4
|
+
interface IRoleProvider extends IDraxCrudProvider<IRole, IRoleBase, IRoleBase>{
|
|
5
5
|
fetchRole(): Promise<IRole[]>
|
|
6
6
|
fetchPermissions(): Promise<any>
|
|
7
7
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
|
|
2
|
-
import type {
|
|
2
|
+
import type {IDraxCrudProvider} from "@drax/crud-share";
|
|
3
3
|
|
|
4
|
-
interface IUserApiKeyProvider extends
|
|
5
|
-
//findBySecret(): Promise<IUserApiKey[]>
|
|
4
|
+
interface IUserApiKeyProvider extends IDraxCrudProvider<IUserApiKey, IUserApiKeyBase, IUserApiKeyBase> {
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
export type {IUserApiKeyProvider}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
2
|
-
import type {
|
|
2
|
+
import type {IDraxCrudProvider} from "@drax/crud-share";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
interface IUserProvider extends
|
|
5
|
+
interface IUserProvider extends IDraxCrudProvider<IUser, IUserCreate, IUserUpdate>{
|
|
6
6
|
changeUserPassword(id: string, newPassword: string): Promise<boolean>
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -20,6 +20,17 @@ class RoleGqlProvider implements IRoleProvider {
|
|
|
20
20
|
this.gqlClient.removeHeader('Authorization')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
get gqlFields(){
|
|
24
|
+
return `id name permissions childRoles{id name} readonly`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async search(value: any): Promise<any> {
|
|
28
|
+
const query: string = `query searchRole($value: String) { searchRole(value: $value) { ${this.gqlFields} } }`
|
|
29
|
+
const variables = {value}
|
|
30
|
+
let data = await this.gqlClient.query(query, variables)
|
|
31
|
+
return data.searchRole
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
async fetchPermissions(): Promise<any> {
|
|
24
35
|
const query: string = `query fetchPermissions { fetchPermissions }`
|
|
25
36
|
const variables = {}
|
|
@@ -28,15 +39,17 @@ class RoleGqlProvider implements IRoleProvider {
|
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
async fetchRole(): Promise<IRole[]> {
|
|
31
|
-
const query: string = `query fetchRole { fetchRole {
|
|
42
|
+
const query: string = `query fetchRole { fetchRole { ${this.gqlFields} } }`
|
|
32
43
|
const variables = {}
|
|
33
44
|
let data = await this.gqlClient.query(query, variables)
|
|
34
45
|
return data.fetchRole
|
|
35
46
|
}
|
|
36
47
|
|
|
48
|
+
|
|
49
|
+
|
|
37
50
|
async create(payload: IRoleBase): Promise<IRole> {
|
|
38
51
|
const query: string = `mutation createRole($input: RoleInput) {
|
|
39
|
-
createRole(input: $input) {
|
|
52
|
+
createRole(input: $input) { ${this.gqlFields} }
|
|
40
53
|
}`
|
|
41
54
|
const variables = {input: payload}
|
|
42
55
|
let data = await this.gqlClient.mutation(query, variables)
|
|
@@ -45,7 +58,7 @@ class RoleGqlProvider implements IRoleProvider {
|
|
|
45
58
|
|
|
46
59
|
async update(id: string, payload: IRoleBase): Promise<IRole> {
|
|
47
60
|
const query: string = `mutation updateRole($id: ID!, $input: RoleInput) { updateRole(id: $id, input: $input) {
|
|
48
|
-
|
|
61
|
+
${this.gqlFields} } }`
|
|
49
62
|
const variables = {id, input: payload}
|
|
50
63
|
let data = await this.gqlClient.mutation(query, variables)
|
|
51
64
|
return data.updateRole
|
|
@@ -61,7 +74,7 @@ class RoleGqlProvider implements IRoleProvider {
|
|
|
61
74
|
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IRole>> {
|
|
62
75
|
const query: string = `query paginateRole($options: PaginateOptions) {
|
|
63
76
|
paginateRole(options: $options) {
|
|
64
|
-
total, page, limit, items{
|
|
77
|
+
total, page, limit, items{ ${this.gqlFields} }
|
|
65
78
|
}
|
|
66
79
|
}`
|
|
67
80
|
const variables = {options: {page, limit, orderBy, order, search}}
|
|
@@ -20,17 +20,28 @@ class TenantGqlProvider implements ITenantProvider {
|
|
|
20
20
|
this.gqlClient.removeHeader('Authorization')
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
get gqlFields(){
|
|
24
|
+
return `id name createdAt updatedAt`
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
|
|
24
28
|
async fetchTenant(): Promise<ITenant[]> {
|
|
25
|
-
const query: string = `query fetchTenant { fetchTenant {
|
|
29
|
+
const query: string = `query fetchTenant { fetchTenant { ${this.gqlFields} } }`
|
|
26
30
|
const variables = {}
|
|
27
31
|
let data = await this.gqlClient.query(query, variables)
|
|
28
32
|
return data.fetchTenant
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
async search(value: any): Promise<any> {
|
|
36
|
+
const query: string = `query searchTenant($value: String) { searchTenant(value: $value) { ${this.gqlFields} } }`
|
|
37
|
+
const variables = {value}
|
|
38
|
+
let data = await this.gqlClient.query(query, variables)
|
|
39
|
+
return data.searchTenant
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
async create(payload: ITenantBase): Promise<any> {
|
|
32
43
|
const query: string = `mutation createTenant($input: TenantInput) {
|
|
33
|
-
createTenant(input: $input) {
|
|
44
|
+
createTenant(input: $input) { ${this.gqlFields} }
|
|
34
45
|
}`
|
|
35
46
|
const variables = {input: payload}
|
|
36
47
|
let data = await this.gqlClient.mutation(query, variables)
|
|
@@ -39,7 +50,7 @@ class TenantGqlProvider implements ITenantProvider {
|
|
|
39
50
|
|
|
40
51
|
async update(id: string, payload: ITenantBase): Promise<ITenant> {
|
|
41
52
|
const query: string = `mutation updateTenant($id: ID!, $input: TenantInput) { updateTenant(id: $id, input: $input) {
|
|
42
|
-
|
|
53
|
+
${this.gqlFields} } }`
|
|
43
54
|
const variables = {id, input: payload}
|
|
44
55
|
let data = await this.gqlClient.mutation(query, variables)
|
|
45
56
|
return data.updateTenant
|
|
@@ -55,7 +66,7 @@ class TenantGqlProvider implements ITenantProvider {
|
|
|
55
66
|
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<ITenant>> {
|
|
56
67
|
const query: string = `query paginateTenant($options: PaginateOptions) {
|
|
57
68
|
paginateTenant(options: $options) {
|
|
58
|
-
total page limit items{
|
|
69
|
+
total page limit items{ ${this.gqlFields} }
|
|
59
70
|
}
|
|
60
71
|
}`
|
|
61
72
|
const variables = {options: {page, limit, orderBy, order, search}}
|
|
@@ -19,9 +19,20 @@ class UserApiKeyGqlProvider implements IUserApiKeyProvider {
|
|
|
19
19
|
this.gqlClient.removeHeader('Authorization')
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
get gqlFields(){
|
|
23
|
+
return `id name secret ipv4 ipv6 createdAt updatedAt`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async search(value: any): Promise<IUserApiKey[]> {
|
|
27
|
+
const query: string = `query searchUserApiKey($value: String) { searchUserApiKey(value: $value) { ${this.gqlFields} } }`
|
|
28
|
+
const variables = {value}
|
|
29
|
+
let data = await this.gqlClient.query(query, variables)
|
|
30
|
+
return data.searchUserApiKey
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
async create(payload: IUserApiKeyBase): Promise<IUserApiKey> {
|
|
23
34
|
const query: string = `mutation createUserApiKey($input: UserApiKeyInput) {
|
|
24
|
-
createUserApiKey(input: $input) {
|
|
35
|
+
createUserApiKey(input: $input) { ${this.gqlFields} }
|
|
25
36
|
}`
|
|
26
37
|
const variables = {input: payload}
|
|
27
38
|
let data = await this.gqlClient.mutation(query, variables)
|
|
@@ -30,7 +41,7 @@ class UserApiKeyGqlProvider implements IUserApiKeyProvider {
|
|
|
30
41
|
|
|
31
42
|
async update(id: string, payload: IUserApiKeyBase): Promise<IUserApiKey> {
|
|
32
43
|
const query: string = `mutation updateUserApiKey($id: ID!, $input: UserApiKeyInput) {
|
|
33
|
-
updateUserApiKey(id: $id, input: $input) {
|
|
44
|
+
updateUserApiKey(id: $id, input: $input) { ${this.gqlFields} }
|
|
34
45
|
}`
|
|
35
46
|
const variables = {id, input: payload}
|
|
36
47
|
let data = await this.gqlClient.mutation(query, variables)
|
|
@@ -51,7 +62,7 @@ class UserApiKeyGqlProvider implements IUserApiKeyProvider {
|
|
|
51
62
|
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserApiKey>> {
|
|
52
63
|
const query: string = `query paginateUserApiKey($options: PaginateOptions) {
|
|
53
64
|
paginateUserApiKey(options: $options) {
|
|
54
|
-
total page limit items{
|
|
65
|
+
total page limit items{ ${this.gqlFields} }
|
|
55
66
|
}
|
|
56
67
|
}`
|
|
57
68
|
const variables = {options: {page, limit, orderBy, order, search}}
|
|
@@ -19,9 +19,20 @@ class UserGqlProvider implements IUserProvider {
|
|
|
19
19
|
this.gqlClient.removeHeader('Authorization')
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
get gqlFields(){
|
|
23
|
+
return `id username name email phone active role{id name} tenant{id name} createdAt updatedAt`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async search(value: any): Promise<IUser[]> {
|
|
27
|
+
const query: string = `query searchUser($value: String) { searchUser(value: $value) { ${this.gqlFields} } }`
|
|
28
|
+
const variables = {value}
|
|
29
|
+
let data = await this.gqlClient.query(query, variables)
|
|
30
|
+
return data.searchUser
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
async create(payload: IUserCreate): Promise<IUser> {
|
|
23
34
|
const query: string = `mutation createUser($input: UserCreateInput) { createUser(input: $input) {
|
|
24
|
-
|
|
35
|
+
${this.gqlFields} } }`
|
|
25
36
|
const variables = {input: payload}
|
|
26
37
|
let data = await this.gqlClient.mutation(query, variables)
|
|
27
38
|
return data.createUser
|
|
@@ -29,7 +40,7 @@ class UserGqlProvider implements IUserProvider {
|
|
|
29
40
|
|
|
30
41
|
async update(id: string, payload: IUserUpdate): Promise<IUser> {
|
|
31
42
|
const query: string = `mutation updateUser($id: ID!, $input: UserUpdateInput) { updateUser(id: $id, input: $input) {
|
|
32
|
-
|
|
43
|
+
${this.gqlFields} } }`
|
|
33
44
|
const variables = {id, input: payload}
|
|
34
45
|
let data = await this.gqlClient.mutation(query, variables)
|
|
35
46
|
return data.updateUser
|
|
@@ -52,7 +63,7 @@ class UserGqlProvider implements IUserProvider {
|
|
|
52
63
|
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}:IDraxPaginateOptions): Promise<IDraxPaginateResult<IUser>> {
|
|
53
64
|
const query: string = `query paginateUser($options: PaginateOptions) {
|
|
54
65
|
paginateUser(options: $options) {
|
|
55
|
-
total page limit items{
|
|
66
|
+
total page limit items{ ${this.gqlFields} createdAt updatedAt }
|
|
56
67
|
}
|
|
57
68
|
}`
|
|
58
69
|
const variables = {options: {page, limit, orderBy, order, search}}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type {IHttpClient} from '@drax/common-front'
|
|
2
2
|
import type {IRoleProvider} from "../../interfaces/IRoleProvider.ts";
|
|
3
3
|
import type {IRole, IRoleBase} from "@drax/identity-share";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
IDraxCrudProviderExportResult,
|
|
6
|
+
IDraxExportOptions, IDraxFieldFilter,
|
|
7
|
+
IDraxPaginateOptions,
|
|
8
|
+
IDraxPaginateResult
|
|
9
|
+
} from "@drax/crud-share";
|
|
5
10
|
|
|
6
11
|
class RoleRestProvider implements IRoleProvider {
|
|
7
12
|
|
|
@@ -49,6 +54,28 @@ class RoleRestProvider implements IRoleProvider {
|
|
|
49
54
|
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
async search(value: any): Promise<any> {
|
|
58
|
+
const url = '/api/roles/search'
|
|
59
|
+
let params = {value: value}
|
|
60
|
+
let roles = await this.httpClient.get(url, {params} )
|
|
61
|
+
return roles
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async export({
|
|
65
|
+
format = 'JSON',
|
|
66
|
+
headers = [],
|
|
67
|
+
separator = ';',
|
|
68
|
+
limit = 0,
|
|
69
|
+
orderBy = "",
|
|
70
|
+
order = false,
|
|
71
|
+
search = "",
|
|
72
|
+
filters = []
|
|
73
|
+
}: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
|
|
74
|
+
const url = '/api/roles/export'
|
|
75
|
+
const sFilters: string = filters.map((filter : IDraxFieldFilter ) => `${filter.field},${filter.operator},${filter.value}`).join('|')
|
|
76
|
+
const params: any = {format, headers, separator, limit, orderBy, order, search, filters: sFilters}
|
|
77
|
+
return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
|
|
78
|
+
}
|
|
52
79
|
|
|
53
80
|
}
|
|
54
81
|
|
|
@@ -63,7 +63,13 @@ class TenantRestProvider implements ITenantProvider {
|
|
|
63
63
|
const sFilters: string = filters.map((filter : IDraxFieldFilter ) => `${filter.field},${filter.operator},${filter.value}`).join('|')
|
|
64
64
|
const params: any = {format, headers, separator, limit, orderBy, order, search, filters: sFilters}
|
|
65
65
|
return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
|
|
66
|
+
}
|
|
66
67
|
|
|
68
|
+
async search(value: any): Promise<any> {
|
|
69
|
+
const url = '/api/tenants/search'
|
|
70
|
+
let params = {value: value}
|
|
71
|
+
let tenants = await this.httpClient.get(url, {params} )
|
|
72
|
+
return tenants
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
|
|
@@ -15,31 +15,36 @@ class UserApiKeyRestProvider implements IUserApiKeyProvider {
|
|
|
15
15
|
|
|
16
16
|
async create(data: IUserApiKeyBase): Promise<IUserApiKey> {
|
|
17
17
|
const url = '/api/user-api-keys'
|
|
18
|
-
let
|
|
19
|
-
return
|
|
18
|
+
let userApiKey = await this.httpClient.post(url, data)
|
|
19
|
+
return userApiKey as IUserApiKey
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async update(id: string, data: IUserApiKeyBase): Promise<IUserApiKey> {
|
|
23
23
|
const url = '/api/user-api-keys/' + id
|
|
24
|
-
let
|
|
25
|
-
return
|
|
24
|
+
let userApiKey = await this.httpClient.put(url, data)
|
|
25
|
+
return userApiKey as IUserApiKey
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async delete(id: string): Promise<any> {
|
|
29
29
|
const url = '/api/user-api-keys/' + id
|
|
30
|
-
let
|
|
31
|
-
return
|
|
30
|
+
let result = await this.httpClient.delete(url)
|
|
31
|
+
return result
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserApiKey>> {
|
|
35
35
|
const url = '/api/user-api-keys'
|
|
36
36
|
const params = {page, limit, orderBy, order, search}
|
|
37
|
-
let
|
|
38
|
-
return
|
|
37
|
+
let paginatedUserApiKeys = await this.httpClient.get(url, {params})
|
|
38
|
+
return paginatedUserApiKeys as IDraxPaginateResult<IUserApiKey>
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
async search(value: any): Promise<any> {
|
|
43
|
+
const url = '/api/user-api-keys/search'
|
|
44
|
+
let data = {value: value}
|
|
45
|
+
let userApiKeys = await this.httpClient.post(url, data )
|
|
46
|
+
return userApiKeys
|
|
47
|
+
}
|
|
43
48
|
|
|
44
49
|
|
|
45
50
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type {IHttpClient} from '@drax/common-front'
|
|
2
2
|
import type {IUserProvider} from "../../interfaces/IUserProvider.ts";
|
|
3
3
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
IDraxCrudProviderExportResult,
|
|
6
|
+
IDraxExportOptions, IDraxFieldFilter,
|
|
7
|
+
IDraxPaginateOptions,
|
|
8
|
+
IDraxPaginateResult
|
|
9
|
+
} from "@drax/crud-share";
|
|
5
10
|
|
|
6
11
|
|
|
7
12
|
class UserRestProvider implements IUserProvider {
|
|
@@ -39,6 +44,13 @@ class UserRestProvider implements IUserProvider {
|
|
|
39
44
|
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
async search(value: any): Promise<any> {
|
|
48
|
+
const url = '/api/users/search'
|
|
49
|
+
let data = {value: value}
|
|
50
|
+
let users = await this.httpClient.post(url, data )
|
|
51
|
+
return users
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
|
|
43
55
|
const url = '/api/password/' + userId
|
|
44
56
|
const data = {userId, newPassword}
|
|
@@ -47,6 +59,23 @@ class UserRestProvider implements IUserProvider {
|
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
|
|
62
|
+
async export({
|
|
63
|
+
format = 'JSON',
|
|
64
|
+
headers = [],
|
|
65
|
+
separator = ';',
|
|
66
|
+
limit = 0,
|
|
67
|
+
orderBy = "",
|
|
68
|
+
order = false,
|
|
69
|
+
search = "",
|
|
70
|
+
filters = []
|
|
71
|
+
}: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
|
|
72
|
+
const url = '/api/users/export'
|
|
73
|
+
const sFilters: string = filters.map((filter : IDraxFieldFilter ) => `${filter.field},${filter.operator},${filter.value}`).join('|')
|
|
74
|
+
const params: any = {format, headers, separator, limit, orderBy, order, search, filters: sFilters}
|
|
75
|
+
return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
50
79
|
}
|
|
51
80
|
|
|
52
81
|
export default UserRestProvider
|
package/src/system/AuthSystem.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {IAuthProvider} from "../interfaces/IAuthProvider";
|
|
|
2
2
|
import type {IAuthUser} from "../interfaces/IAuthUser";
|
|
3
3
|
import type {ILoginResponse} from "../interfaces/ILoginResponse";
|
|
4
4
|
|
|
5
|
-
class AuthSystem {
|
|
5
|
+
class AuthSystem implements IAuthProvider {
|
|
6
6
|
|
|
7
7
|
_provider : IAuthProvider
|
|
8
8
|
prototype: string;
|
package/src/system/RoleSystem.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type {IRoleProvider} from "../interfaces/IRoleProvider";
|
|
2
|
-
import type {IRole, IRoleBase} from "@drax/identity-share";
|
|
3
|
-
import type {
|
|
2
|
+
import type {IRole, IRoleBase, ITenant} from "@drax/identity-share";
|
|
3
|
+
import type {
|
|
4
|
+
IDraxCrudProviderExportResult,
|
|
5
|
+
IDraxExportOptions,
|
|
6
|
+
IDraxPaginateOptions,
|
|
7
|
+
IDraxPaginateResult
|
|
8
|
+
} from "@drax/crud-share";
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
class RoleSystem implements IRoleProvider {
|
|
@@ -13,7 +18,16 @@ class RoleSystem implements IRoleProvider {
|
|
|
13
18
|
this.prototype = 'RoleSystem'
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
async search(value: any):Promise<IRole[]> {
|
|
22
|
+
|
|
23
|
+
if(!this._provider.search){
|
|
24
|
+
throw new Error("Search method not implemented")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return this._provider.search(value)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fetchRole():Promise<IRole[]> {
|
|
17
31
|
return this._provider.fetchRole()
|
|
18
32
|
}
|
|
19
33
|
|
|
@@ -21,8 +35,8 @@ class RoleSystem implements IRoleProvider {
|
|
|
21
35
|
return this._provider.fetchPermissions()
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
async paginate({page= 1, limit= 5, orderBy="", order=false, search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IRole>> {
|
|
25
|
-
return this._provider.paginate({page, limit, orderBy, order, search})
|
|
38
|
+
async paginate({page= 1, limit= 5, orderBy="", order=false, search = "", filters = []}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IRole>> {
|
|
39
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
26
40
|
}
|
|
27
41
|
|
|
28
42
|
async create(userPayload: IRoleBase):Promise<IRole> {
|
|
@@ -37,6 +51,33 @@ class RoleSystem implements IRoleProvider {
|
|
|
37
51
|
return this._provider.delete(id)
|
|
38
52
|
}
|
|
39
53
|
|
|
54
|
+
async export({
|
|
55
|
+
format = 'JSON',
|
|
56
|
+
headers = [],
|
|
57
|
+
separator = ';',
|
|
58
|
+
limit = 0,
|
|
59
|
+
orderBy = "",
|
|
60
|
+
order = false,
|
|
61
|
+
search = "",
|
|
62
|
+
filters = []
|
|
63
|
+
}: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
|
|
64
|
+
|
|
65
|
+
if(!this._provider.export){
|
|
66
|
+
throw new Error(`RoleSystem.provider does not support export`) // assuming we have a custom error for this case // replace with actual error handling as needed // see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#error-handling-changes for more details on custom error classes in TypeScript 3.1+ // or use a library like 'ts-error' for a more robust and flexible error handling solution // or use a custom error type if you want to have a specific error type for this operation // or use a custom interface or class for the export result if you want to have a specific structure for the result // or use a custom function that returns the result if you want to have a specific function for the result // or use a custom interface or class if you want to have a specific structure for the result // or use a custom function that returns the result
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return this._provider.export({
|
|
70
|
+
format,
|
|
71
|
+
headers,
|
|
72
|
+
separator,
|
|
73
|
+
limit,
|
|
74
|
+
orderBy,
|
|
75
|
+
order,
|
|
76
|
+
search,
|
|
77
|
+
filters
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
40
81
|
}
|
|
41
82
|
|
|
42
83
|
export default RoleSystem
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {ITenantProvider} from "../interfaces/ITenantProvider";
|
|
2
|
-
import type {ITenant, ITenantBase} from "@drax/identity-share";
|
|
2
|
+
import type {ITenant, ITenantBase, IUser} from "@drax/identity-share";
|
|
3
3
|
import type {
|
|
4
4
|
IDraxCrudProvider,
|
|
5
5
|
IDraxCrudProviderExportResult,
|
|
@@ -22,14 +22,24 @@ class TenantSystem implements IDraxCrudProvider<ITenant, ITenantBase, ITenantBas
|
|
|
22
22
|
return this._provider.fetchTenant()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
async search(value: any):Promise<ITenant[]> {
|
|
26
|
+
|
|
27
|
+
if(!this._provider.search){
|
|
28
|
+
throw new Error("Search method not implemented")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return this._provider.search(value)
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
async paginate({
|
|
26
35
|
page = 1,
|
|
27
36
|
limit = 5,
|
|
28
37
|
orderBy = "",
|
|
29
38
|
order = false,
|
|
30
|
-
search = ""
|
|
39
|
+
search = "",
|
|
40
|
+
filters = []
|
|
31
41
|
}: IDraxPaginateOptions): Promise<IDraxPaginateResult<ITenant>> {
|
|
32
|
-
return this._provider.paginate({page, limit, orderBy, order, search})
|
|
42
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
async create(userPayload: ITenantBase): Promise<ITenant> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {IUserApiKeyProvider} from "../interfaces/IUserApiKeyProvider";
|
|
2
|
-
import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
|
|
3
|
-
import type {IDraxPaginateResult} from "@drax/crud-share";
|
|
2
|
+
import type {IRole, IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
|
|
3
|
+
import type {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class UserApiKeySystem {
|
|
6
|
+
class UserApiKeySystem implements IUserApiKeyProvider{
|
|
7
7
|
|
|
8
8
|
_provider: IUserApiKeyProvider
|
|
9
9
|
prototype: string;
|
|
@@ -13,8 +13,17 @@ class UserApiKeySystem {
|
|
|
13
13
|
this.prototype = 'UserSystem'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async
|
|
17
|
-
|
|
16
|
+
async search(value: any):Promise<IUserApiKey[]> {
|
|
17
|
+
|
|
18
|
+
if(!this._provider.search){
|
|
19
|
+
throw new Error("Search method not implemented")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return this._provider.search(value)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async paginate({page= 1, limit= 5, orderBy="", order=false, search = "", filters = []}: IDraxPaginateOptions):Promise<IDraxPaginateResult<IUserApiKey>> {
|
|
26
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
async create(userPayload: IUserApiKeyBase):Promise<IUserApiKey> {
|
package/src/system/UserSystem.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type {IUserProvider} from "../interfaces/IUserProvider";
|
|
2
2
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
IDraxCrudProviderExportResult,
|
|
5
|
+
IDraxExportOptions,
|
|
6
|
+
IDraxPaginateOptions,
|
|
7
|
+
IDraxPaginateResult
|
|
8
|
+
} from "@drax/crud-share";
|
|
4
9
|
|
|
5
10
|
|
|
6
|
-
class UserSystem {
|
|
11
|
+
class UserSystem implements IUserProvider{
|
|
7
12
|
|
|
8
13
|
_provider: IUserProvider
|
|
9
14
|
prototype: string;
|
|
@@ -13,8 +18,17 @@ class UserSystem {
|
|
|
13
18
|
this.prototype = 'UserSystem'
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
async
|
|
17
|
-
|
|
21
|
+
async search(value: any):Promise<IUser[]> {
|
|
22
|
+
|
|
23
|
+
if(!this._provider.search){
|
|
24
|
+
throw new Error("Search method not implemented")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return this._provider.search(value)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async paginate({page= 1, limit= 5, orderBy="", order=false, search = "", filters = []}: IDraxPaginateOptions):Promise<IDraxPaginateResult<IUser>> {
|
|
31
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
async create(userPayload: IUserCreate):Promise<IUser> {
|
|
@@ -25,16 +39,41 @@ class UserSystem {
|
|
|
25
39
|
return this._provider.update(id, userPayload)
|
|
26
40
|
}
|
|
27
41
|
|
|
42
|
+
async delete(id: string):Promise<any> {
|
|
43
|
+
return this._provider.delete(id)
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
async changeUserPassword(userId:string, newPassword:string):Promise<boolean> {
|
|
29
47
|
console.log("UserSystem",userId, newPassword)
|
|
30
48
|
const result: boolean = await this._provider.changeUserPassword(userId,newPassword)
|
|
31
49
|
return result
|
|
32
50
|
}
|
|
33
51
|
|
|
52
|
+
async export({
|
|
53
|
+
format = 'JSON',
|
|
54
|
+
headers = [],
|
|
55
|
+
separator = ';',
|
|
56
|
+
limit = 0,
|
|
57
|
+
orderBy = "",
|
|
58
|
+
order = false,
|
|
59
|
+
search = "",
|
|
60
|
+
filters = []
|
|
61
|
+
}: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
|
|
34
62
|
|
|
63
|
+
if(!this._provider.export){
|
|
64
|
+
throw new Error(`RoleSystem.provider does not support export`) // assuming we have a custom error for this case // replace with actual error handling as needed // see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#error-handling-changes for more details on custom error classes in TypeScript 3.1+ // or use a library like 'ts-error' for a more robust and flexible error handling solution // or use a custom error type if you want to have a specific error type for this operation // or use a custom interface or class for the export result if you want to have a specific structure for the result // or use a custom function that returns the result if you want to have a specific function for the result // or use a custom interface or class if you want to have a specific structure for the result // or use a custom function that returns the result
|
|
65
|
+
}
|
|
35
66
|
|
|
36
|
-
|
|
37
|
-
|
|
67
|
+
return this._provider.export({
|
|
68
|
+
format,
|
|
69
|
+
headers,
|
|
70
|
+
separator,
|
|
71
|
+
limit,
|
|
72
|
+
orderBy,
|
|
73
|
+
order,
|
|
74
|
+
search,
|
|
75
|
+
filters
|
|
76
|
+
})
|
|
38
77
|
}
|
|
39
78
|
|
|
40
79
|
}
|