@drax/identity-front 0.35.0 → 0.37.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.35.0",
6
+ "version": "0.37.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.35.0",
29
- "@drax/crud-share": "^0.35.0",
30
- "@drax/identity-share": "^0.35.0"
28
+ "@drax/common-front": "^0.37.0",
29
+ "@drax/crud-share": "^0.37.0",
30
+ "@drax/identity-share": "^0.37.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": "d8e9ad20ff3a5bd9e9d4383ef0926b79eac335d8"
52
+ "gitHead": "0bca48d4b686fd9536a78d84f5befe6801238000"
53
53
  }
@@ -0,0 +1,32 @@
1
+ import UserLoginFailSystem from "../system/UserLoginFailSystem.js";
2
+ import UserLoginFailGqlProvider from "../providers/gql/UserLoginFailGqlProvider.js";
3
+ import UserLoginFailRestClientProvider from "../providers/rest/UserLoginFailRestProvider.js";
4
+ import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
5
+ const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
6
+
7
+ class UserLoginFailSystemFactory{
8
+
9
+ static singleton: UserLoginFailSystem
10
+
11
+ static getInstance(httpTransport: string = HTTP_TRANSPORT): UserLoginFailSystem {
12
+ if(!UserLoginFailSystemFactory.singleton){
13
+ if(httpTransport === 'GRAPHQL') {
14
+ const httpGqlClient = HttpGqlClientFactory.getInstance()
15
+ const provider = new UserLoginFailGqlProvider(httpGqlClient)
16
+ UserLoginFailSystemFactory.singleton = new UserLoginFailSystem(provider)
17
+ } else if(httpTransport === 'REST') {
18
+ const httpRestClient = HttpRestClientFactory.getInstance()
19
+ const provider = new UserLoginFailRestClientProvider(httpRestClient)
20
+ UserLoginFailSystemFactory.singleton = new UserLoginFailSystem(provider)
21
+ }else{
22
+ throw new Error('UserLoginFailSystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
23
+ }
24
+ }
25
+ return UserLoginFailSystemFactory.singleton
26
+ }
27
+
28
+ }
29
+
30
+
31
+ export default UserLoginFailSystemFactory
32
+ export {UserLoginFailSystemFactory}
@@ -0,0 +1,32 @@
1
+ import UserSessionSystem from "../system/UserSessionSystem.js";
2
+ import UserSessionGqlProvider from "../providers/gql/UserSessionGqlProvider.js";
3
+ import UserSessionRestClientProvider from "../providers/rest/UserSessionRestProvider.js";
4
+ import {HttpGqlClientFactory, HttpRestClientFactory} from "@drax/common-front"
5
+ const HTTP_TRANSPORT = import.meta.env.VITE_HTTP_TRANSPORT || 'REST';
6
+
7
+ class UserSessionSystemFactory{
8
+
9
+ static singleton: UserSessionSystem
10
+
11
+ static getInstance(httpTransport: string = HTTP_TRANSPORT): UserSessionSystem {
12
+ if(!UserSessionSystemFactory.singleton){
13
+ if(httpTransport === 'GRAPHQL') {
14
+ const httpGqlClient = HttpGqlClientFactory.getInstance()
15
+ const provider = new UserSessionGqlProvider(httpGqlClient)
16
+ UserSessionSystemFactory.singleton = new UserSessionSystem(provider)
17
+ } else if(httpTransport === 'REST') {
18
+ const httpRestClient = HttpRestClientFactory.getInstance()
19
+ const provider = new UserSessionRestClientProvider(httpRestClient)
20
+ UserSessionSystemFactory.singleton = new UserSessionSystem(provider)
21
+ }else{
22
+ throw new Error('UserSessionSystemFactory ERROR: Invalid HTTP_TRANSPORT environment variable')
23
+ }
24
+ }
25
+ return UserSessionSystemFactory.singleton
26
+ }
27
+
28
+ }
29
+
30
+
31
+ export default UserSessionSystemFactory
32
+ export {UserSessionSystemFactory}
package/src/index.ts CHANGED
@@ -29,6 +29,17 @@ import TenantSystem from "./system/TenantSystem.js"
29
29
  import TenantSystemFactory from "./factory/TenantSystemFactory.js"
30
30
 
31
31
 
32
+ import UserSessionRestProvider from "./providers/rest/UserSessionRestProvider.js";
33
+ import UserSessionGqlProvider from "./providers/gql/UserSessionGqlProvider.js";
34
+ import UserSessionSystem from "./system/UserSessionSystem.js"
35
+ import UserSessionSystemFactory from "./factory/UserSessionSystemFactory.js"
36
+
37
+ import UserLoginFailRestProvider from "./providers/rest/UserLoginFailRestProvider.js";
38
+ import UserLoginFailGqlProvider from "./providers/gql/UserLoginFailGqlProvider.js";
39
+ import UserLoginFailSystem from "./system/UserLoginFailSystem.js"
40
+ import UserLoginFailSystemFactory from "./factory/UserLoginFailSystemFactory.js"
41
+
42
+
32
43
  import {IdentityI18nMessages} from "./i18n/index.js"
33
44
 
34
45
  import type {IAuthProvider} from "./interfaces/IAuthProvider"
@@ -71,12 +82,21 @@ export {
71
82
  UserApiKeyRestProvider,
72
83
  UserApiKeyGqlProvider,
73
84
 
85
+ UserSessionRestProvider,
86
+ UserSessionGqlProvider,
87
+
88
+ UserLoginFailRestProvider,
89
+ UserLoginFailGqlProvider,
90
+
91
+
74
92
  //Systems
75
93
  AuthSystem,
76
94
  UserSystem,
77
95
  RoleSystem,
78
96
  TenantSystem,
79
97
  UserApiKeySystem,
98
+ UserSessionSystem,
99
+ UserLoginFailSystem,
80
100
 
81
101
  //Factory
82
102
  AuthSystemFactory,
@@ -84,6 +104,8 @@ export {
84
104
  RoleSystemFactory,
85
105
  TenantSystemFactory,
86
106
  UserApiKeySystemFactory,
107
+ UserSessionSystemFactory,
108
+ UserLoginFailSystemFactory,
87
109
 
88
110
  //Helpers
89
111
  AuthHelper,
@@ -0,0 +1,17 @@
1
+ import type {IUserLoginFail} from "@drax/identity-share";
2
+ import type {
3
+ IDraxCrudProviderExportResult,
4
+ IDraxExportOptions,
5
+ IDraxPaginateOptions,
6
+ IDraxPaginateResult,
7
+ IDraxGroupByOptions
8
+ } from "@drax/crud-share";
9
+
10
+
11
+ interface IUserLoginFailProvider{
12
+ paginate(options: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserLoginFail>>
13
+ groupBy?(options: IDraxGroupByOptions): Promise<Array<any>>
14
+ export?(options: IDraxExportOptions): Promise<IDraxCrudProviderExportResult>
15
+ }
16
+
17
+ export type {IUserLoginFailProvider}
@@ -0,0 +1,17 @@
1
+ import type {IUserSession} from "@drax/identity-share";
2
+ import type {
3
+ IDraxCrudProviderExportResult,
4
+ IDraxExportOptions,
5
+ IDraxPaginateOptions,
6
+ IDraxPaginateResult,
7
+ IDraxGroupByOptions
8
+ } from "@drax/crud-share";
9
+
10
+
11
+ interface IUserSessionProvider{
12
+ paginate(options: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserSession>>
13
+ groupBy?(options: IDraxGroupByOptions): Promise<Array<any>>
14
+ export?(options: IDraxExportOptions): Promise<IDraxCrudProviderExportResult>
15
+ }
16
+
17
+ export type {IUserSessionProvider}
@@ -0,0 +1,43 @@
1
+ import type {IGqlClient} from '@drax/common-front'
2
+ import type {IUserLoginFailProvider} from "../../interfaces/IUserLoginFailProvider";
3
+ import type {IUserLoginFail} from "@drax/identity-share";
4
+ import type {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
5
+
6
+
7
+ class UserLoginFailGqlProvider implements IUserLoginFailProvider {
8
+
9
+ gqlClient: IGqlClient
10
+
11
+ constructor(gqlClient: IGqlClient) {
12
+ this.gqlClient = gqlClient
13
+ }
14
+
15
+ setHttpClientToken(token: string): void {
16
+ this.gqlClient.addHeader('Authorization', `Bearer ${token}`)
17
+ }
18
+
19
+ removeHttpClientToken(): void {
20
+ this.gqlClient.removeHeader('Authorization')
21
+ }
22
+
23
+ get gqlFields(){
24
+ return `_id user{_id username} agent ip createdAt`
25
+ }
26
+
27
+
28
+
29
+ async paginate({page= 1, limit= 5, orderBy="", order='asc', search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserLoginFail>> {
30
+ const query: string = `query paginateUserLoginFail($options: PaginateOptions) {
31
+ paginateUserLoginFail(options: $options) {
32
+ total, page, limit, items{ ${this.gqlFields} }
33
+ }
34
+ }`
35
+ const variables = {options: {page, limit, orderBy, order, search}}
36
+ let data = await this.gqlClient.query(query, variables)
37
+ return data.paginateUserLoginFail
38
+ }
39
+
40
+
41
+ }
42
+
43
+ export default UserLoginFailGqlProvider
@@ -0,0 +1,42 @@
1
+ import type {IGqlClient} from '@drax/common-front'
2
+ import type {IUserSessionProvider} from "../../interfaces/IUserSessionProvider";
3
+ import type {IUserSession} from "@drax/identity-share";
4
+ import type {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
5
+
6
+
7
+ class UserSessionProvider implements IUserSessionProvider {
8
+
9
+ gqlClient: IGqlClient
10
+
11
+ constructor(gqlClient: IGqlClient) {
12
+ this.gqlClient = gqlClient
13
+ }
14
+
15
+ setHttpClientToken(token: string): void {
16
+ this.gqlClient.addHeader('Authorization', `Bearer ${token}`)
17
+ }
18
+
19
+ removeHttpClientToken(): void {
20
+ this.gqlClient.removeHeader('Authorization')
21
+ }
22
+
23
+ get gqlFields(){
24
+ return `_id uuid user{_id username} agent ip createdAt`
25
+ }
26
+
27
+
28
+ async paginate({page= 1, limit= 5, orderBy="", order='asc', search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserSession>> {
29
+ const query: string = `query paginateUserSession($options: PaginateOptions) {
30
+ paginateUserLoginFail(options: $options) {
31
+ total, page, limit, items{ ${this.gqlFields} }
32
+ }
33
+ }`
34
+ const variables = {options: {page, limit, orderBy, order, search}}
35
+ let data = await this.gqlClient.query(query, variables)
36
+ return data.paginateUserLoginFail
37
+ }
38
+
39
+
40
+ }
41
+
42
+ export default UserSessionProvider
@@ -7,12 +7,14 @@ import type {
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
10
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
10
11
 
11
- class RoleRestProvider implements IRoleProvider {
12
+ class RoleRestProvider extends AbstractBaseRestProvider implements IRoleProvider {
12
13
 
13
14
  httpClient: IHttpClient
14
15
 
15
16
  constructor(httpClient: IHttpClient) {
17
+ super('/api/roles');
16
18
  this.httpClient = httpClient
17
19
  }
18
20
 
@@ -72,8 +74,7 @@ class RoleRestProvider implements IRoleProvider {
72
74
  filters = []
73
75
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
74
76
  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
+ const params: any = {format, headers, separator, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
77
78
  return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
78
79
  }
79
80
 
@@ -7,17 +7,17 @@ import type {
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
10
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
10
11
 
11
- class TenantRestProvider implements ITenantProvider {
12
+ class TenantRestProvider extends AbstractBaseRestProvider implements ITenantProvider {
12
13
 
13
14
  httpClient: IHttpClient
14
15
 
15
16
  constructor(httpClient: IHttpClient) {
17
+ super('/api/tenants');
16
18
  this.httpClient = httpClient
17
19
  }
18
20
 
19
-
20
-
21
21
  async fetchTenant(): Promise<any> {
22
22
  const url = '/api/tenants/all'
23
23
  let tenant = await this.httpClient.get(url)
@@ -41,9 +41,9 @@ class TenantRestProvider implements ITenantProvider {
41
41
  return user
42
42
  }
43
43
 
44
- async paginate({page= 1, limit= 5, orderBy="", order= "asc", search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<ITenant>> {
44
+ async paginate({page= 1, limit= 5, orderBy="", order= "asc", search = "", filters= []}: IDraxPaginateOptions): Promise<IDraxPaginateResult<ITenant>> {
45
45
  const url = '/api/tenants'
46
- const params = {page, limit, orderBy, order, search}
46
+ const params = {page, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
47
47
  let paginatedTenants = await this.httpClient.get(url, {params})
48
48
  return paginatedTenants as IDraxPaginateResult<ITenant>
49
49
 
@@ -60,8 +60,7 @@ class TenantRestProvider implements ITenantProvider {
60
60
  filters = []
61
61
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
62
62
  const url = '/api/tenants/export'
63
- const sFilters: string = filters.map((filter : IDraxFieldFilter ) => `${filter.field},${filter.operator},${filter.value}`).join('|')
64
- const params: any = {format, headers, separator, limit, orderBy, order, search, filters: sFilters}
63
+ const params: any = {format, headers, separator, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
65
64
  return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
66
65
  }
67
66
 
@@ -2,13 +2,15 @@ import type {IHttpClient} from '@drax/common-front'
2
2
  import type {IUserApiKeyProvider} from "../../interfaces/IUserApiKeyProvider";
3
3
  import type {IUserApiKey, IUserApiKeyBase} from "@drax/identity-share";
4
4
  import type {IDraxPaginateOptions, IDraxPaginateResult} from "@drax/crud-share";
5
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
5
6
 
6
7
 
7
- class UserApiKeyRestProvider implements IUserApiKeyProvider {
8
+ class UserApiKeyRestProvider extends AbstractBaseRestProvider implements IUserApiKeyProvider {
8
9
 
9
10
  httpClient: IHttpClient
10
11
 
11
12
  constructor(httpClient: IHttpClient) {
13
+ super('/api/user-api-keys');
12
14
  this.httpClient = httpClient
13
15
  }
14
16
 
@@ -31,9 +33,9 @@ class UserApiKeyRestProvider implements IUserApiKeyProvider {
31
33
  return result
32
34
  }
33
35
 
34
- async paginate({page= 1, limit= 5, orderBy="", order="asc", search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserApiKey>> {
36
+ async paginate({page= 1, limit= 5, orderBy="", order="asc", search = "", filters=[]}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserApiKey>> {
35
37
  const url = '/api/user-api-keys'
36
- const params = {page, limit, orderBy, order, search}
38
+ const params = {page, limit, orderBy, order, search, filters: this.prepareFilters(filters) }
37
39
  let paginatedUserApiKeys = await this.httpClient.get(url, {params})
38
40
  return paginatedUserApiKeys as IDraxPaginateResult<IUserApiKey>
39
41
 
@@ -0,0 +1,55 @@
1
+ import type {IHttpClient} from "@drax/common-front";
2
+ import type {
3
+ IDraxCrudProviderExportResult,
4
+ IDraxExportOptions,
5
+ IDraxFieldFilter,
6
+ IDraxGroupByOptions,
7
+ IDraxPaginateOptions,
8
+ IDraxPaginateResult
9
+ } from "@drax/crud-share";
10
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
11
+ import type {IUserLoginFail} from "@drax/identity-share";
12
+ import type {IUserLoginFailProvider} from "../../interfaces/IUserLoginFailProvider";
13
+
14
+ class UserLoginFailRestProvider extends AbstractBaseRestProvider implements IUserLoginFailProvider {
15
+
16
+ httpClient: IHttpClient
17
+
18
+ constructor(httpClient: IHttpClient) {
19
+ super('/api/user-login-fails');
20
+ this.httpClient = httpClient
21
+ }
22
+
23
+ async paginate({page= 1, limit= 5, orderBy="",order= "asc", search = "", filters= []}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserLoginFail>> {
24
+ const url = '/api/user-login-fails'
25
+ const params = {page, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
26
+ let paginatedUsers = await this.httpClient.get(url, {params})
27
+ return paginatedUsers as IDraxPaginateResult<IUserLoginFail>
28
+ }
29
+
30
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
31
+ const url = '/api/user-login-fails/group-by'
32
+ const params = {fields: fields ? fields.join(',') : '',filters: this.prepareFilters(filters)}
33
+ const items = await this.httpClient.get(url, {params})
34
+ return items as any[]
35
+ }
36
+
37
+ async export({
38
+ format = 'JSON',
39
+ headers = [],
40
+ separator = ';',
41
+ limit = 0,
42
+ orderBy = "",
43
+ order = false,
44
+ search = "",
45
+ filters = []
46
+ }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
47
+ const url = '/api/user-login-fails/export'
48
+ const params: any = {format, headers, separator, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
49
+ return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
50
+ }
51
+
52
+ }
53
+
54
+ export default UserLoginFailRestProvider
55
+
@@ -3,17 +3,19 @@ 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,
6
+ IDraxExportOptions, IDraxFieldFilter, IDraxGroupByOptions,
7
7
  IDraxPaginateOptions,
8
8
  IDraxPaginateResult
9
9
  } from "@drax/crud-share";
10
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
10
11
 
11
12
 
12
- class UserRestProvider implements IUserProvider {
13
+ class UserRestProvider extends AbstractBaseRestProvider implements IUserProvider {
13
14
 
14
15
  httpClient: IHttpClient
15
16
 
16
17
  constructor(httpClient: IHttpClient) {
18
+ super('/api/users');
17
19
  this.httpClient = httpClient
18
20
  }
19
21
 
@@ -36,9 +38,9 @@ class UserRestProvider implements IUserProvider {
36
38
  return user
37
39
  }
38
40
 
39
- async paginate({page= 1, limit= 5, orderBy="",order= "asc", search = ""}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUser>> {
41
+ async paginate({page= 1, limit= 5, orderBy="",order= "asc", search = "", filters=[]}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUser>> {
40
42
  const url = '/api/users'
41
- const params = {page, limit, orderBy, order, search}
43
+ const params = {page, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
42
44
  let paginatedUsers = await this.httpClient.get(url, {params})
43
45
  return paginatedUsers as IDraxPaginateResult<IUser>
44
46
 
@@ -70,11 +72,17 @@ class UserRestProvider implements IUserProvider {
70
72
  filters = []
71
73
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
72
74
  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
+ const params: any = {format, headers, separator, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
75
76
  return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
76
77
  }
77
78
 
79
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
80
+ const url = '/api/users/group-by'
81
+ const params = {fields: fields ? fields.join(',') : '',filters: this.prepareFilters(filters)}
82
+ const items = await this.httpClient.get(url, {params})
83
+ return items as any[]
84
+ }
85
+
78
86
 
79
87
  }
80
88
 
@@ -0,0 +1,55 @@
1
+ import type {IHttpClient} from "@drax/common-front";
2
+ import type {
3
+ IDraxCrudProviderExportResult,
4
+ IDraxExportOptions,
5
+ IDraxGroupByOptions,
6
+ IDraxPaginateOptions,
7
+ IDraxPaginateResult
8
+ } from "@drax/crud-share";
9
+ import type {IUserSession} from "@drax/identity-share";
10
+ import type {IUserSessionProvider} from "../../interfaces/IUserSessionProvider";
11
+ import {AbstractBaseRestProvider} from "@drax/crud-front";
12
+
13
+ class UserSessionRestProvider extends AbstractBaseRestProvider implements IUserSessionProvider {
14
+
15
+ httpClient: IHttpClient
16
+
17
+ constructor(httpClient: IHttpClient) {
18
+ super('/api/user-sessions');
19
+ this.httpClient = httpClient
20
+ }
21
+
22
+
23
+ async paginate({page= 1, limit= 5, orderBy="",order= "asc", search = "", filters=[]}: IDraxPaginateOptions): Promise<IDraxPaginateResult<IUserSession>> {
24
+ const url = '/api/user-sessions'
25
+ const params = {page, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
26
+ let paginatedUsers = await this.httpClient.get(url, {params})
27
+ return paginatedUsers as IDraxPaginateResult<IUserSession>
28
+ }
29
+
30
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
31
+ const url = '/api/user-sessions/group-by'
32
+ const params = {fields: fields ? fields.join(',') : '',filters: this.prepareFilters(filters)}
33
+ const items = await this.httpClient.get(url, {params})
34
+ return items as any[]
35
+ }
36
+
37
+ async export({
38
+ format = 'JSON',
39
+ headers = [],
40
+ separator = ';',
41
+ limit = 0,
42
+ orderBy = "",
43
+ order = false,
44
+ search = "",
45
+ filters = []
46
+ }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
47
+ const url = '/api/user-sessions/export'
48
+ const params: any = {format, headers, separator, limit, orderBy, order, search, filters: this.prepareFilters(filters)}
49
+ return await this.httpClient.get(url, {params}) as IDraxCrudProviderExportResult
50
+ }
51
+
52
+ }
53
+
54
+ export default UserSessionRestProvider
55
+
@@ -0,0 +1,64 @@
1
+ import type {IUserLoginFailProvider} from "../interfaces/IUserLoginFailProvider";
2
+ import type {IUserLoginFail} from "@drax/identity-share";
3
+ import type {
4
+ IDraxCrudProviderExportResult,
5
+ IDraxExportOptions, IDraxGroupByOptions,
6
+ IDraxPaginateOptions,
7
+ IDraxPaginateResult
8
+ } from "@drax/crud-share";
9
+
10
+
11
+ class UserLoginFailSystem implements IUserLoginFailProvider{
12
+
13
+ _provider: IUserLoginFailProvider
14
+ prototype: string;
15
+
16
+ constructor(provider: IUserLoginFailProvider) {
17
+ this._provider = provider;
18
+ this.prototype = 'UserLoginFailSystem'
19
+ }
20
+
21
+ async paginate({page= 1, limit= 5, orderBy= "", order= "asc", search = "", filters = []}: IDraxPaginateOptions):Promise<IDraxPaginateResult<IUserLoginFail>> {
22
+ return this._provider.paginate({page, limit, orderBy, order, search, filters})
23
+ }
24
+
25
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
26
+ if(!this._provider.groupBy){
27
+ throw new Error("groupBy method not implemented")
28
+ }
29
+
30
+ const result: any[] = await this._provider.groupBy({fields,filters})
31
+ return result
32
+ }
33
+
34
+ async export({
35
+ format = 'JSON',
36
+ headers = [],
37
+ separator = ';',
38
+ limit = 0,
39
+ orderBy = "",
40
+ order = false,
41
+ search = "",
42
+ filters = []
43
+ }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
44
+
45
+ if(!this._provider.export){
46
+ 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
47
+ }
48
+
49
+ return this._provider.export({
50
+ format,
51
+ headers,
52
+ separator,
53
+ limit,
54
+ orderBy,
55
+ order,
56
+ search,
57
+ filters
58
+ })
59
+ }
60
+
61
+ }
62
+
63
+ export default UserLoginFailSystem
64
+ export {UserLoginFailSystem}
@@ -0,0 +1,64 @@
1
+ import type {IUserSessionProvider} from "../interfaces/IUserSessionProvider";
2
+ import type {IUserSession} from "@drax/identity-share";
3
+ import type {
4
+ IDraxCrudProviderExportResult,
5
+ IDraxExportOptions, IDraxGroupByOptions,
6
+ IDraxPaginateOptions,
7
+ IDraxPaginateResult
8
+ } from "@drax/crud-share";
9
+
10
+
11
+ class UserSessionSystem implements IUserSessionProvider{
12
+
13
+ _provider: IUserSessionProvider
14
+ prototype: string;
15
+
16
+ constructor(provider: IUserSessionProvider) {
17
+ this._provider = provider;
18
+ this.prototype = 'UserSessionSystem'
19
+ }
20
+
21
+ async paginate({page= 1, limit= 5, orderBy= "", order= "asc", search = "", filters = []}: IDraxPaginateOptions):Promise<IDraxPaginateResult<IUserSession>> {
22
+ return this._provider.paginate({page, limit, orderBy, order, search, filters})
23
+ }
24
+
25
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
26
+ if(!this._provider.groupBy){
27
+ throw new Error("groupBy method not implemented")
28
+ }
29
+
30
+ const result: any[] = await this._provider.groupBy({fields,filters})
31
+ return result
32
+ }
33
+
34
+ async export({
35
+ format = 'JSON',
36
+ headers = [],
37
+ separator = ';',
38
+ limit = 0,
39
+ orderBy = "",
40
+ order = false,
41
+ search = "",
42
+ filters = []
43
+ }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
44
+
45
+ if(!this._provider.export){
46
+ 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
47
+ }
48
+
49
+ return this._provider.export({
50
+ format,
51
+ headers,
52
+ separator,
53
+ limit,
54
+ orderBy,
55
+ order,
56
+ search,
57
+ filters
58
+ })
59
+ }
60
+
61
+ }
62
+
63
+ export default UserSessionSystem
64
+ export {UserSessionSystem}
@@ -2,7 +2,7 @@ import type {IUserProvider} from "../interfaces/IUserProvider";
2
2
  import type {IUser, IUserCreate, IUserUpdate} from "@drax/identity-share";
3
3
  import type {
4
4
  IDraxCrudProviderExportResult,
5
- IDraxExportOptions,
5
+ IDraxExportOptions, IDraxGroupByOptions,
6
6
  IDraxPaginateOptions,
7
7
  IDraxPaginateResult
8
8
  } from "@drax/crud-share";
@@ -21,7 +21,7 @@ class UserSystem implements IUserProvider{
21
21
  async search(value: any):Promise<IUser[]> {
22
22
 
23
23
  if(!this._provider.search){
24
- throw new Error("Search method not implemented")
24
+ throw new Error("search method not implemented")
25
25
  }
26
26
 
27
27
  return this._provider.search(value)
@@ -44,11 +44,19 @@ class UserSystem implements IUserProvider{
44
44
  }
45
45
 
46
46
  async changeUserPassword(userId:string, newPassword:string):Promise<boolean> {
47
- console.log("UserSystem",userId, newPassword)
48
47
  const result: boolean = await this._provider.changeUserPassword(userId,newPassword)
49
48
  return result
50
49
  }
51
50
 
51
+ async groupBy({fields = [], filters = []}: IDraxGroupByOptions): Promise<Array<any>> {
52
+ if(!this._provider.groupBy){
53
+ throw new Error("groupBy method not implemented")
54
+ }
55
+
56
+ const result: any[] = await this._provider.groupBy({fields,filters})
57
+ return result
58
+ }
59
+
52
60
  async export({
53
61
  format = 'JSON',
54
62
  headers = [],
@@ -61,7 +69,7 @@ class UserSystem implements IUserProvider{
61
69
  }: IDraxExportOptions): Promise<IDraxCrudProviderExportResult> {
62
70
 
63
71
  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
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
65
73
  }
66
74
 
67
75
  return this._provider.export({