@drax/identity-front 0.0.30 → 0.1.0

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.30",
6
+ "version": "0.1.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -24,9 +24,9 @@
24
24
  "format": "prettier --write src/"
25
25
  },
26
26
  "dependencies": {
27
- "@drax/common-front": "^0.0.30",
28
- "@drax/common-share": "^0.0.30",
29
- "@drax/identity-share": "^0.0.30"
27
+ "@drax/common-front": "^0.1.0",
28
+ "@drax/common-share": "^0.1.0",
29
+ "@drax/identity-share": "^0.1.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@rushstack/eslint-patch": "^1.8.0",
@@ -48,5 +48,5 @@
48
48
  "vite-plugin-dts": "^3.9.1",
49
49
  "vitest": "^1.4.0"
50
50
  },
51
- "gitHead": "b0882d3ace0d0004cbc850e8d86381b9d6432535"
51
+ "gitHead": "bec2a22554155ef5deab5a55245878a4449932ad"
52
52
  }
@@ -5,12 +5,20 @@ const messages = {
5
5
  'role':'Role',
6
6
  'tenant':'Tenant',
7
7
  'permissions': 'Permissions',
8
+
8
9
  'user:view': 'View User',
9
10
  'user:create': 'Create User',
10
11
  'user:update': 'Edit User',
11
12
  'user:delete': 'Delete User',
12
13
  'user:manage': 'Manage User',
13
14
 
15
+ 'userApiKey:view': 'View ApiKey',
16
+ 'userApiKey:myView': 'View My ApiKey',
17
+ 'userApiKey:create': 'Create ApiKey',
18
+ 'userApiKey:update': 'Edit ApiKey',
19
+ 'userApiKey:delete': 'Delete ApiKey',
20
+ 'userApiKey:manage': 'Manage ApiKey',
21
+
14
22
  'role:view': 'View Role',
15
23
  'role:create': 'Create Role',
16
24
  'role:update': 'Edit Role',
@@ -32,12 +40,20 @@ const messages = {
32
40
  'role':'Rol',
33
41
  'tenant':'Tenant',
34
42
  'permissions': 'Permisos',
43
+
35
44
  'user:view': 'Ver Usuario',
36
45
  'user:create': 'Crear Usuario',
37
46
  'user:update': 'Editar Usuario',
38
47
  'user:delete': 'Eliminar Usuario',
39
48
  'user:manage': 'Administrar Usuario',
40
49
 
50
+ 'userApiKey:view': 'Ver ApiKey',
51
+ 'userApiKey:myView': 'Ver mis ApiKey',
52
+ 'userApiKey:create': 'Crear ApiKey',
53
+ 'userApiKey:update': 'Editar ApiKey',
54
+ 'userApiKey:delete': 'Eliminar ApiKey',
55
+ 'userApiKey:manage': 'Administrar ApiKey',
56
+
41
57
  'role:view': 'Ver Rol',
42
58
  'role:create': 'Crear Rol',
43
59
  'role:update': 'Editar Rol',
@@ -2,6 +2,7 @@ const messages = {
2
2
  en: {
3
3
  tenant: {
4
4
  name: "Name",
5
+ createdAt: 'Created At',
5
6
  updating: "Updating Tenant",
6
7
  creating: "Creating Tenant",
7
8
  deleting: "Deleting Tenant",
@@ -11,6 +12,7 @@ const messages = {
11
12
  es: {
12
13
  tenant:{
13
14
  name: "Nombre",
15
+ createdAt: 'Creado',
14
16
  updating: "Actualizando Tenant",
15
17
  creating: "Creando Tenant",
16
18
  deleting: "Eliminando Tenant",
@@ -0,0 +1,35 @@
1
+ const messages = {
2
+ en: {
3
+ userApiKey: {
4
+ name: "Reference Name",
5
+ secret: "Secret",
6
+ secretWarning: "ApiKey only shows once. Keep the ApiKey securely.",
7
+ ipv4: "Allowed IPV4",
8
+ ipv6: "Allowed IPV6",
9
+ user: "User",
10
+ createdAt: 'Created At',
11
+ updating: "Updating API Key",
12
+ creating: "Creating API Key",
13
+ deleting: "Deleting API Key",
14
+ managing: 'Managing API Key',
15
+ }
16
+ },
17
+ es: {
18
+ userApiKey:{
19
+ name: "Nombre de referencia",
20
+ secret: "Secreto",
21
+ secretWarning: "La ApiKey solo se muestra una vez. Guarde la ApiKey de forma segura.",
22
+ ipv4: "IPv4 permitidos",
23
+ ipv6: "IPv6 permitidos",
24
+ user: "Usuario",
25
+ createdAt: 'Creado',
26
+ updating: "Actualizando API Key",
27
+ creating: "Creando API Key",
28
+ deleting: "Eliminando API Key",
29
+ managing: 'Administrando API Key',
30
+ }
31
+ }
32
+ }
33
+
34
+
35
+ export default messages
package/src/i18n/index.ts CHANGED
@@ -3,10 +3,19 @@ import identityAuthI18n from "./identity-auth-i18n.js";
3
3
  import identityValidationI18n from "./identity-validation-i18n.js";
4
4
  import identityPermissionI18n from "./identity-permissions-i18n.js";
5
5
  import identityUserI18n from "./identity-user-i18n.js";
6
+ import identityUserApiKyI18n from "./identity-userApiKey-i18n.js";
6
7
  import identityRoleI18n from "./identity-role-i18n.js";
7
8
  import identityTenantI18n from "./identity-tenant-i18n.js";
8
9
 
9
- const IdentityI18nMessages = merge.all([identityAuthI18n, identityValidationI18n, identityUserI18n, identityRoleI18n, identityTenantI18n, identityPermissionI18n])
10
+ const IdentityI18nMessages = merge.all([
11
+ identityAuthI18n,
12
+ identityValidationI18n,
13
+ identityUserI18n,
14
+ identityRoleI18n,
15
+ identityTenantI18n,
16
+ identityPermissionI18n,
17
+ identityUserApiKyI18n
18
+ ])
10
19
 
11
20
  export default IdentityI18nMessages
12
21
  export {IdentityI18nMessages}
package/src/index.ts CHANGED
@@ -10,6 +10,11 @@ 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
12
 
13
+ import UserApiKeyRestProvider from "./providers/rest/UserApiKeyRestProvider.js";
14
+ import UserApiKeyGqlProvider from "./providers/gql/UserApiKeyGqlProvider.js";
15
+ import UserApiKeySystem from "./system/UserApiKeySystem.js"
16
+
17
+
13
18
 
14
19
  import RoleRestProvider from "./providers/rest/RoleRestProvider.js";
15
20
  import RoleGqlProvider from "./providers/gql/RoleGqlProvider.js";
@@ -27,6 +32,7 @@ import type {IAuthProvider} from "./interfaces/IAuthProvider"
27
32
  import type {IUserProvider} from "./interfaces/IUserProvider"
28
33
  import type {IRoleProvider} from "./interfaces/IRoleProvider"
29
34
  import type {ITenantProvider} from "./interfaces/ITenantProvider"
35
+ import type {IUserApiKeyProvider} from "./interfaces/IUserApiKeyProvider"
30
36
  import type {IAuthUser} from "./interfaces/IAuthUser"
31
37
  import type {IUserPassword} from "./interfaces/IUserPassword"
32
38
  import type {ILoginResponse} from "./interfaces/ILoginResponse"
@@ -36,6 +42,7 @@ export type {
36
42
  IUserProvider,
37
43
  IRoleProvider,
38
44
  ITenantProvider,
45
+ IUserApiKeyProvider,
39
46
  IAuthUser,
40
47
  IUserPassword,
41
48
  ILoginResponse
@@ -55,11 +62,16 @@ export {
55
62
  TenantGqlProvider,
56
63
  TenantRestProvider,
57
64
 
65
+
66
+ UserApiKeyRestProvider,
67
+ UserApiKeyGqlProvider,
68
+
58
69
  //Systems
59
70
  AuthSystem,
60
71
  UserSystem,
61
72
  RoleSystem,
62
73
  TenantSystem,
74
+ UserApiKeySystem,
63
75
 
64
76
  //Helpers
65
77
  AuthHelper,
@@ -0,0 +1,8 @@
1
+ import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
2
+ import type {IDraxCrud} from "@drax/common-share";
3
+
4
+ interface IUserApiKeyProvider extends IDraxCrud<IUserApiKey, IUserApiKeyBase, IUserApiKeyBase> {
5
+ //findBySecret(): Promise<IUserApiKey[]>
6
+ }
7
+
8
+ export type {IUserApiKeyProvider}
@@ -48,14 +48,14 @@ class RoleGqlProvider implements IRoleProvider {
48
48
  id name permissions childRoles{id name} readonly } }`
49
49
  const variables = {id, input: payload}
50
50
  let data = await this.gqlClient.mutation(query, variables)
51
- return data.createRole
51
+ return data.updateRole
52
52
  }
53
53
 
54
54
  async delete(id: string): Promise<any> {
55
55
  const query: string = `mutation deleteRole($id: ID!) { deleteRole(id: $id) }`
56
56
  const variables = {id: id}
57
57
  let data = await this.gqlClient.mutation(query, variables)
58
- return data.createRole
58
+ return data.deleteRole
59
59
  }
60
60
 
61
61
  async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IRole>> {
@@ -42,20 +42,20 @@ class TenantGqlProvider implements ITenantProvider {
42
42
  id name } }`
43
43
  const variables = {id, input: payload}
44
44
  let data = await this.gqlClient.mutation(query, variables)
45
- return data.createTenant
45
+ return data.updateTenant
46
46
  }
47
47
 
48
48
  async delete(id: string): Promise<any> {
49
49
  const query: string = `mutation deleteTenant($id: ID!) { deleteTenant(id: $id) }`
50
50
  const variables = {id: id}
51
51
  let data = await this.gqlClient.mutation(query, variables)
52
- return data.createTenant
52
+ return data.deleteTenant
53
53
  }
54
54
 
55
55
  async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<ITenant>> {
56
56
  const query: string = `query paginateTenant($options: PaginateOptions) {
57
57
  paginateTenant(options: $options) {
58
- total, page, limit, items{id, name }
58
+ total page limit items{ id name createdAt updatedAt }
59
59
  }
60
60
  }`
61
61
  const variables = {options: {page, limit, orderBy, orderDesc, search}}
@@ -0,0 +1,63 @@
1
+ import type {IGqlClient} from '@drax/common-front'
2
+ import type {IUserApiKeyProvider} from "../../interfaces/IUserApiKeyProvider";
3
+ import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
4
+ import type {IDraxPaginateResult} from "@drax/common-share";
5
+
6
+ class UserApiKeyGqlProvider implements IUserApiKeyProvider {
7
+
8
+ gqlClient: IGqlClient
9
+
10
+ constructor(gqlClient: IGqlClient) {
11
+ this.gqlClient = gqlClient
12
+ }
13
+
14
+ setHttpClientToken(token: string): void {
15
+ this.gqlClient.addHeader('Authorization', `Bearer ${token}`)
16
+ }
17
+
18
+ removeHttpClientToken(): void {
19
+ this.gqlClient.removeHeader('Authorization')
20
+ }
21
+
22
+ async create(payload: IUserApiKeyBase): Promise<IUserApiKey> {
23
+ const query: string = `mutation createUserApiKey($input: UserApiKeyInput) {
24
+ createUserApiKey(input: $input) { id name secret ipv4 ipv6 createdAt updatedAt }
25
+ }`
26
+ const variables = {input: payload}
27
+ let data = await this.gqlClient.mutation(query, variables)
28
+ return data.createUserApiKey
29
+ }
30
+
31
+ async update(id: string, payload: IUserApiKeyBase): Promise<IUserApiKey> {
32
+ const query: string = `mutation updateUserApiKey($id: ID!, $input: UserApiKeyInput) {
33
+ updateUserApiKey(id: $id, input: $input) { id name ipv4 ipv6 createdAt updatedAt }
34
+ }`
35
+ const variables = {id, input: payload}
36
+ let data = await this.gqlClient.mutation(query, variables)
37
+ return data.updateUserApiKey
38
+ }
39
+
40
+
41
+
42
+ async delete(id: string): Promise<any> {
43
+ const query: string = `mutation deleteUserApiKey($id: ID!) {
44
+ deleteUserApiKey(id: $id)
45
+ }`
46
+ const variables = {id: id}
47
+ let data = await this.gqlClient.mutation(query, variables)
48
+ return data.deleteUserApiKey
49
+ }
50
+
51
+ async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IUserApiKey>> {
52
+ const query: string = `query paginateUserApiKey($options: PaginateOptions) {
53
+ paginateUserApiKey(options: $options) {
54
+ total page limit items{ id name ipv4 ipv6 user{id username} createdAt updatedAt }
55
+ }
56
+ }`
57
+ const variables = {options: {page, limit, orderBy, orderDesc, search}}
58
+ let data = await this.gqlClient.query(query, variables)
59
+ return data.paginateUserApiKey
60
+ }
61
+ }
62
+
63
+ export default UserApiKeyGqlProvider
@@ -32,7 +32,7 @@ class UserGqlProvider implements IUserProvider {
32
32
  id username name email phone active role{id name} tenant{id name} } }`
33
33
  const variables = {id, input: payload}
34
34
  let data = await this.gqlClient.mutation(query, variables)
35
- return data.createUser
35
+ return data.updateUser
36
36
  }
37
37
 
38
38
  async changeUserPassword(userId: string, newPassword: string): Promise<boolean> {
@@ -46,13 +46,13 @@ class UserGqlProvider implements IUserProvider {
46
46
  const query: string = `mutation deleteUser($id: ID!) { deleteUser(id: $id) }`
47
47
  const variables = {id: id}
48
48
  let data = await this.gqlClient.mutation(query, variables)
49
- return data.createUser
49
+ return data.deleteUser
50
50
  }
51
51
 
52
52
  async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IUser>> {
53
53
  const query: string = `query paginateUser($options: PaginateOptions) {
54
54
  paginateUser(options: $options) {
55
- total, page, limit, items{ id, name username, email, phone, active, role{id, name} tenant{id name} }
55
+ total page limit items{ id name username email phone active role{id, name} tenant{id name} createdAt updatedAt }
56
56
  }
57
57
  }`
58
58
  const variables = {options: {page, limit, orderBy, orderDesc, search}}
@@ -0,0 +1,47 @@
1
+ import type {IHttpClient} from '@drax/common-front'
2
+ import type {IUserApiKeyProvider} from "../../interfaces/IUserApiKeyProvider";
3
+ import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
4
+ import type {IDraxPaginateResult} from "@drax/common-share";
5
+
6
+
7
+ class UserApiKeyRestProvider implements IUserApiKeyProvider {
8
+
9
+ httpClient: IHttpClient
10
+
11
+ constructor(httpClient: IHttpClient) {
12
+ this.httpClient = httpClient
13
+ }
14
+
15
+
16
+ async create(data: IUserApiKeyBase): Promise<IUserApiKey> {
17
+ const url = '/api/user-api-keys'
18
+ let user = await this.httpClient.post(url, data)
19
+ return user as IUserApiKey
20
+ }
21
+
22
+ async update(id: string, data: IUserApiKeyBase): Promise<IUserApiKey> {
23
+ const url = '/api/user-api-keys/' + id
24
+ let user = await this.httpClient.put(url, data)
25
+ return user as IUserApiKey
26
+ }
27
+
28
+ async delete(id: string): Promise<any> {
29
+ const url = '/api/user-api-keys/' + id
30
+ let user = await this.httpClient.delete(url)
31
+ return user
32
+ }
33
+
34
+ async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}): Promise<IDraxPaginateResult<IUserApiKey>> {
35
+ const url = '/api/user-api-keys'
36
+ const params = {page, limit, orderBy, orderDesc, search}
37
+ let paginatedUsers = await this.httpClient.get(url, {params})
38
+ return paginatedUsers as IDraxPaginateResult<IUserApiKey>
39
+
40
+ }
41
+
42
+
43
+
44
+
45
+ }
46
+
47
+ export default UserApiKeyRestProvider
@@ -0,0 +1,35 @@
1
+ import type {IUserApiKeyProvider} from "../interfaces/IUserApiKeyProvider";
2
+ import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
3
+ import type {IDraxPaginateResult} from "@drax/common-share";
4
+
5
+
6
+ class UserApiKeySystem {
7
+
8
+ _provider: IUserApiKeyProvider
9
+ prototype: string;
10
+
11
+ constructor(provider: IUserApiKeyProvider) {
12
+ this._provider = provider;
13
+ this.prototype = 'UserSystem'
14
+ }
15
+
16
+ async paginate({page= 1, limit= 5, orderBy="", orderDesc=false, search = ""}):Promise<IDraxPaginateResult<IUserApiKey>> {
17
+ return this._provider.paginate({page, limit, orderBy, orderDesc, search})
18
+ }
19
+
20
+ async create(userPayload: IUserApiKeyBase):Promise<IUserApiKey> {
21
+ return this._provider.create(userPayload)
22
+ }
23
+
24
+ async update(id:string, userPayload: IUserApiKeyBase):Promise<IUserApiKey> {
25
+ return this._provider.update(id, userPayload)
26
+ }
27
+
28
+ async delete(id: string):Promise<any> {
29
+ return this._provider.delete(id)
30
+ }
31
+
32
+ }
33
+
34
+ export default UserApiKeySystem
35
+ export {UserApiKeySystem}