@drax/identity-front 0.37.0 → 0.38.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.37.0",
6
+ "version": "0.38.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -25,9 +25,9 @@
25
25
  "format": "prettier --write src/"
26
26
  },
27
27
  "dependencies": {
28
- "@drax/common-front": "^0.37.0",
29
- "@drax/crud-share": "^0.37.0",
30
- "@drax/identity-share": "^0.37.0"
28
+ "@drax/common-front": "^0.38.0",
29
+ "@drax/crud-share": "^0.38.0",
30
+ "@drax/identity-share": "^0.38.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rushstack/eslint-patch": "^1.8.0",
@@ -49,5 +49,5 @@
49
49
  "vite-plugin-dts": "^3.9.1",
50
50
  "vitest": "^1.4.0"
51
51
  },
52
- "gitHead": "0bca48d4b686fd9536a78d84f5befe6801238000"
52
+ "gitHead": "43c90f3c12165e7527edefbc80dd327a59236dd5"
53
53
  }
package/src/index.ts CHANGED
@@ -47,7 +47,7 @@ import type {IUserProvider} from "./interfaces/IUserProvider"
47
47
  import type {IRoleProvider} from "./interfaces/IRoleProvider"
48
48
  import type {ITenantProvider} from "./interfaces/ITenantProvider"
49
49
  import type {IUserApiKeyProvider} from "./interfaces/IUserApiKeyProvider"
50
- import type {IAuthUser} from "./interfaces/IAuthUser"
50
+ import type {IAuthFullUser} from "./interfaces/IAuthFullUser"
51
51
  import type {IUserPassword} from "./interfaces/IUserPassword"
52
52
  import type {ILoginResponse} from "./interfaces/ILoginResponse"
53
53
  import type {IUserRegistration} from "./interfaces/IUserRegistration"
@@ -58,7 +58,7 @@ export type {
58
58
  IRoleProvider,
59
59
  ITenantProvider,
60
60
  IUserApiKeyProvider,
61
- IAuthUser,
61
+ IAuthFullUser,
62
62
  IUserPassword,
63
63
  ILoginResponse,
64
64
  IUserRegistration
@@ -1,6 +1,6 @@
1
1
  import type {IRole, ITenant} from "@drax/identity-share";
2
2
 
3
- interface IAuthUser {
3
+ interface IAuthFullUser {
4
4
  id: string
5
5
  username: string
6
6
  email: string
@@ -12,4 +12,4 @@ interface IAuthUser {
12
12
  tenant?: ITenant
13
13
  }
14
14
 
15
- export type {IAuthUser}
15
+ export type {IAuthFullUser}
@@ -1,10 +1,10 @@
1
- import type {IAuthUser} from "./IAuthUser";
1
+ import type {IAuthFullUser} from "./IAuthFullUser";
2
2
  import type {ILoginResponse} from "./ILoginResponse";
3
3
  import type {IUserRegistration} from "./IUserRegistration";
4
4
 
5
5
  interface IAuthProvider {
6
6
  login(username: string, password: string): Promise<ILoginResponse>
7
- me(): Promise<IAuthUser>
7
+ me(): Promise<IAuthFullUser>
8
8
  switchTenant(tenantId: string): Promise<ILoginResponse>
9
9
  logout(): void
10
10
  changeOwnPassword(currentPassword:string, newPassword:string):Promise<boolean>
@@ -1,6 +1,6 @@
1
1
  import type {IGqlClient} from '@drax/common-front'
2
2
  import type {IAuthProvider} from "../../interfaces/IAuthProvider.ts";
3
- import type {IAuthUser} from "../../interfaces/IAuthUser";
3
+ import type {IAuthFullUser} from "../../interfaces/IAuthFullUser";
4
4
  import type {ILoginResponse} from "../../interfaces/ILoginResponse";
5
5
  import type {IUserRegistration} from "../../interfaces/IUserRegistration";
6
6
 
@@ -43,7 +43,7 @@ class AuthGqlProvider implements IAuthProvider {
43
43
  return {accessToken}
44
44
  }
45
45
 
46
- async me(): Promise<IAuthUser> {
46
+ async me(): Promise<IAuthFullUser> {
47
47
  const query: string = `query me { me {id, username, email, phone, role {id, name, permissions}, avatar} }`
48
48
  let data = await this.gqlClient.query(query)
49
49
  return data.me
@@ -1,7 +1,7 @@
1
1
 
2
2
  import type {IHttpClient} from '@drax/common-front'
3
3
  import type {IAuthProvider} from "../../interfaces/IAuthProvider";
4
- import type {IAuthUser} from "../../interfaces/IAuthUser";
4
+ import type {IAuthFullUser} from "../../interfaces/IAuthFullUser";
5
5
  import type {ILoginResponse} from "../../interfaces/ILoginResponse";
6
6
  import type {IUserRegistration} from "../../interfaces/IUserRegistration";
7
7
 
@@ -42,9 +42,9 @@ class AuthRestProvider implements IAuthProvider {
42
42
  this.removeHttpClientToken()
43
43
  }
44
44
 
45
- async me(): Promise<IAuthUser> {
45
+ async me(): Promise<IAuthFullUser> {
46
46
  const url = '/api/auth/me'
47
- let r = await this.httpClient.get(url) as IAuthUser
47
+ let r = await this.httpClient.get(url) as IAuthFullUser
48
48
  return r
49
49
  }
50
50
 
@@ -3,7 +3,7 @@ import type {IRoleProvider} from "../../interfaces/IRoleProvider.ts";
3
3
  import type {IRole, IRoleBase} from "@drax/identity-share";
4
4
  import type {
5
5
  IDraxCrudProviderExportResult,
6
- IDraxExportOptions, IDraxFieldFilter,
6
+ IDraxExportOptions,
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
@@ -3,7 +3,7 @@ import type {ITenantProvider} from "../../interfaces/ITenantProvider.ts";
3
3
  import type {ITenant, ITenantBase} from "@drax/identity-share";
4
4
  import type {
5
5
  IDraxCrudProviderExportResult,
6
- IDraxExportOptions, IDraxFieldFilter,
6
+ IDraxExportOptions,
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
@@ -2,7 +2,6 @@ import type {IHttpClient} from "@drax/common-front";
2
2
  import type {
3
3
  IDraxCrudProviderExportResult,
4
4
  IDraxExportOptions,
5
- IDraxFieldFilter,
6
5
  IDraxGroupByOptions,
7
6
  IDraxPaginateOptions,
8
7
  IDraxPaginateResult
@@ -3,7 +3,7 @@ import type {IUserProvider} from "../../interfaces/IUserProvider.ts";
3
3
  import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
4
4
  import type {
5
5
  IDraxCrudProviderExportResult,
6
- IDraxExportOptions, IDraxFieldFilter, IDraxGroupByOptions,
6
+ IDraxExportOptions, IDraxGroupByOptions,
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
@@ -1,5 +1,5 @@
1
1
  import type {IAuthProvider} from "../interfaces/IAuthProvider";
2
- import type {IAuthUser} from "../interfaces/IAuthUser";
2
+ import type {IAuthFullUser} from "../interfaces/IAuthFullUser";
3
3
  import type {ILoginResponse} from "../interfaces/ILoginResponse";
4
4
  import type {IUserRegistration} from "../interfaces/IUserRegistration";
5
5
 
@@ -26,8 +26,8 @@ class AuthSystem implements IAuthProvider {
26
26
  this._provider.logout()
27
27
  }
28
28
 
29
- async me():Promise<IAuthUser> {
30
- const authUser: IAuthUser = await this._provider.me()
29
+ async me():Promise<IAuthFullUser> {
30
+ const authUser: IAuthFullUser = await this._provider.me()
31
31
  return authUser
32
32
  }
33
33
 
@@ -40,14 +40,26 @@ class RoleSystem implements IRoleProvider {
40
40
  }
41
41
 
42
42
  async create(userPayload: IRoleBase):Promise<IRole> {
43
+ if(!this._provider.create){
44
+ throw new Error("Create method not implemented")
45
+ }
46
+
43
47
  return this._provider.create(userPayload)
44
48
  }
45
49
 
46
50
  async update(id:string, userPayload: IRoleBase):Promise<IRole> {
51
+ if(!this._provider.update){
52
+ throw new Error("Update method not implemented")
53
+ }
54
+
47
55
  return this._provider.update(id, userPayload)
48
56
  }
49
57
 
50
58
  async delete(id: string):Promise<any> {
59
+ if(!this._provider.delete){
60
+ throw new Error("Delete method not implemented")
61
+ }
62
+
51
63
  return this._provider.delete(id)
52
64
  }
53
65
 
@@ -63,7 +75,7 @@ class RoleSystem implements IRoleProvider {
63
75
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
64
76
 
65
77
  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
78
+ throw new Error(`RoleSystem.provider does not support export`)
67
79
  }
68
80
 
69
81
  return this._provider.export({
@@ -43,14 +43,26 @@ class TenantSystem implements IDraxCrudProvider<ITenant, ITenantBase, ITenantBas
43
43
  }
44
44
 
45
45
  async create(userPayload: ITenantBase): Promise<ITenant> {
46
+ if(!this._provider.create){
47
+ throw new Error("Create method not implemented")
48
+ }
49
+
46
50
  return this._provider.create(userPayload)
47
51
  }
48
52
 
49
53
  async update(id: string, userPayload: ITenantBase): Promise<ITenant> {
54
+ if(!this._provider.update){
55
+ throw new Error("Update method not implemented")
56
+ }
57
+
50
58
  return this._provider.update(id, userPayload)
51
59
  }
52
60
 
53
61
  async delete(id: string): Promise<any> {
62
+ if(!this._provider.delete){
63
+ throw new Error("Delete method not implemented")
64
+ }
65
+
54
66
  return this._provider.delete(id)
55
67
  }
56
68
 
@@ -66,7 +78,7 @@ class TenantSystem implements IDraxCrudProvider<ITenant, ITenantBase, ITenantBas
66
78
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
67
79
 
68
80
  if(!this._provider.export){
69
- throw new Error(`TenantSystem.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
81
+ throw new Error(`TenantSystem.provider does not support export`)
70
82
  }
71
83
 
72
84
  return this._provider.export({
@@ -27,14 +27,26 @@ class UserApiKeySystem implements IUserApiKeyProvider{
27
27
  }
28
28
 
29
29
  async create(userPayload: IUserApiKeyBase):Promise<IUserApiKey> {
30
+ if(!this._provider.create){
31
+ throw new Error("Create method not implemented")
32
+ }
33
+
30
34
  return this._provider.create(userPayload)
31
35
  }
32
36
 
33
37
  async update(id:string, userPayload: IUserApiKeyBase):Promise<IUserApiKey> {
38
+ if(!this._provider.update){
39
+ throw new Error("Update method not implemented")
40
+ }
41
+
34
42
  return this._provider.update(id, userPayload)
35
43
  }
36
44
 
37
45
  async delete(id: string):Promise<any> {
46
+ if(!this._provider.delete){
47
+ throw new Error("Delete method not implemented")
48
+ }
49
+
38
50
  return this._provider.delete(id)
39
51
  }
40
52
 
@@ -32,18 +32,34 @@ class UserSystem implements IUserProvider{
32
32
  }
33
33
 
34
34
  async create(userPayload: IUserCreate):Promise<IUser> {
35
+ if(!this._provider.create){
36
+ throw new Error("Create method not implemented")
37
+ }
38
+
35
39
  return this._provider.create(userPayload)
36
40
  }
37
41
 
38
42
  async update(id:string, userPayload: IUserUpdate):Promise<IUser> {
43
+ if(!this._provider.update){
44
+ throw new Error("Update method not implemented")
45
+ }
46
+
39
47
  return this._provider.update(id, userPayload)
40
48
  }
41
49
 
42
50
  async delete(id: string):Promise<any> {
51
+ if(!this._provider.delete){
52
+ throw new Error("Delete method not implemented")
53
+ }
54
+
43
55
  return this._provider.delete(id)
44
56
  }
45
57
 
46
58
  async changeUserPassword(userId:string, newPassword:string):Promise<boolean> {
59
+ if(!this._provider.changeUserPassword){
60
+ throw new Error("changeUserPassword method not implemented")
61
+ }
62
+
47
63
  const result: boolean = await this._provider.changeUserPassword(userId,newPassword)
48
64
  return result
49
65
  }
@@ -69,7 +85,7 @@ class UserSystem implements IUserProvider{
69
85
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
70
86
 
71
87
  if(!this._provider.export){
72
- throw new Error(`export method not implemented`) // 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
88
+ throw new Error(`export method not implemented`)
73
89
  }
74
90
 
75
91
  return this._provider.export({