@drax/identity-front 0.5.2 → 0.5.4
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/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 +6 -0
- package/src/providers/rest/TenantRestProvider.ts +7 -0
- package/src/providers/rest/UserApiKeyRestProvider.ts +14 -9
- package/src/providers/rest/UserRestProvider.ts +9 -0
- package/src/system/AuthSystem.ts +1 -1
- package/src/system/RoleSystem.ts +13 -4
- package/src/system/TenantSystem.ts +13 -3
- package/src/system/UserApiKeySystem.ts +14 -5
- package/src/system/UserSystem.ts +18 -7
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.4",
|
|
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.4",
|
|
28
|
+
"@drax/crud-share": "^0.5.4",
|
|
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": "6db0bebb2df9edecd2c3caa7288fb5c7001c4243"
|
|
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}
|
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}}
|
|
@@ -49,6 +49,12 @@ class RoleRestProvider implements IRoleProvider {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
async search(value: any): Promise<any> {
|
|
53
|
+
const url = '/api/roles/search'
|
|
54
|
+
let params = {value: value}
|
|
55
|
+
let roles = await this.httpClient.get(url, {params} )
|
|
56
|
+
return roles
|
|
57
|
+
}
|
|
52
58
|
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -66,6 +66,13 @@ class TenantRestProvider implements ITenantProvider {
|
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
async search(value: any): Promise<any> {
|
|
70
|
+
const url = '/api/tenants/search'
|
|
71
|
+
let params = {value: value}
|
|
72
|
+
let tenants = await this.httpClient.get(url, {params} )
|
|
73
|
+
return tenants
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
|
|
70
77
|
}
|
|
71
78
|
|
|
@@ -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
|
}
|
|
@@ -39,6 +39,13 @@ class UserRestProvider implements IUserProvider {
|
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
async search(value: any): Promise<any> {
|
|
43
|
+
const url = '/api/users/search'
|
|
44
|
+
let data = {value: value}
|
|
45
|
+
let users = await this.httpClient.post(url, data )
|
|
46
|
+
return users
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
|
|
43
50
|
const url = '/api/password/' + userId
|
|
44
51
|
const data = {userId, newPassword}
|
|
@@ -47,6 +54,8 @@ class UserRestProvider implements IUserProvider {
|
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
|
|
57
|
+
|
|
58
|
+
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
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,5 +1,5 @@
|
|
|
1
1
|
import type {IRoleProvider} from "../interfaces/IRoleProvider";
|
|
2
|
-
import type {IRole, IRoleBase} from "@drax/identity-share";
|
|
2
|
+
import type {IRole, IRoleBase, ITenant} from "@drax/identity-share";
|
|
3
3
|
import type {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
4
4
|
|
|
5
5
|
|
|
@@ -13,7 +13,16 @@ class RoleSystem implements IRoleProvider {
|
|
|
13
13
|
this.prototype = 'RoleSystem'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
async search(value: any):Promise<IRole[]> {
|
|
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
|
+
fetchRole():Promise<IRole[]> {
|
|
17
26
|
return this._provider.fetchRole()
|
|
18
27
|
}
|
|
19
28
|
|
|
@@ -21,8 +30,8 @@ class RoleSystem implements IRoleProvider {
|
|
|
21
30
|
return this._provider.fetchPermissions()
|
|
22
31
|
}
|
|
23
32
|
|
|
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})
|
|
33
|
+
async paginate({page= 1, limit= 5, orderBy="", order=false, search = "", filters = []}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IRole>> {
|
|
34
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
async create(userPayload: IRoleBase):Promise<IRole> {
|
|
@@ -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,9 @@
|
|
|
1
1
|
import type {IUserProvider} from "../interfaces/IUserProvider";
|
|
2
2
|
import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
|
|
3
|
-
import type {IDraxPaginateResult} from "@drax/crud-share";
|
|
3
|
+
import type { IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class UserSystem {
|
|
6
|
+
class UserSystem implements IUserProvider{
|
|
7
7
|
|
|
8
8
|
_provider: IUserProvider
|
|
9
9
|
prototype: string;
|
|
@@ -13,8 +13,17 @@ class UserSystem {
|
|
|
13
13
|
this.prototype = 'UserSystem'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async
|
|
17
|
-
|
|
16
|
+
async search(value: any):Promise<IUser[]> {
|
|
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<IUser>> {
|
|
26
|
+
return this._provider.paginate({page, limit, orderBy, order, search, filters})
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
async create(userPayload: IUserCreate):Promise<IUser> {
|
|
@@ -25,6 +34,10 @@ class UserSystem {
|
|
|
25
34
|
return this._provider.update(id, userPayload)
|
|
26
35
|
}
|
|
27
36
|
|
|
37
|
+
async delete(id: string):Promise<any> {
|
|
38
|
+
return this._provider.delete(id)
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
async changeUserPassword(userId:string, newPassword:string):Promise<boolean> {
|
|
29
42
|
console.log("UserSystem",userId, newPassword)
|
|
30
43
|
const result: boolean = await this._provider.changeUserPassword(userId,newPassword)
|
|
@@ -33,9 +46,7 @@ class UserSystem {
|
|
|
33
46
|
|
|
34
47
|
|
|
35
48
|
|
|
36
|
-
|
|
37
|
-
return this._provider.delete(id)
|
|
38
|
-
}
|
|
49
|
+
|
|
39
50
|
|
|
40
51
|
}
|
|
41
52
|
|