@intellegens/cornerstone-client 0.0.45 → 0.0.9999-alpha-2
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/LICENSE.md +0 -0
- package/README.md +133 -12
- package/adapters/CollectionViewAdapter/index.d.ts +154 -0
- package/adapters/CollectionViewAdapter/index.js +281 -0
- package/adapters/index.d.ts +1 -0
- package/adapters/index.js +1 -0
- package/data/api/dto/PropertyPathDto.d.ts +4 -0
- package/data/api/dto/ReadOptionsDto.d.ts +8 -0
- package/data/api/dto/ReadResultDto.d.ts +12 -0
- package/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
- package/data/api/dto/crud/{CrudMetadata.d.ts → CrudMetadataDto.d.ts} +1 -1
- package/data/api/dto/crud/index.d.ts +1 -1
- package/data/api/dto/crud/index.js +1 -1
- package/data/api/dto/index.d.ts +1 -0
- package/data/api/dto/index.js +1 -0
- package/data/api/dto/read/{ReadMetadata.d.ts → ReadMetadataDto.d.ts} +1 -1
- package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
- package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +2 -2
- package/data/api/dto/read/index.d.ts +1 -1
- package/data/api/dto/read/index.js +1 -1
- package/data/api/dto/response/{ApiError.d.ts → ApiErrorDto.d.ts} +1 -1
- package/data/api/dto/response/ApiErrorDto.js +1 -0
- package/data/api/dto/response/{ApiResponse.d.ts → ApiResponseDto.d.ts} +3 -3
- package/data/api/dto/response/ApiResponseDto.js +1 -0
- package/data/api/dto/response/{ApiSuccessResponse.d.ts → ApiSuccessResponseDto.d.ts} +1 -1
- package/data/api/dto/response/ApiSuccessResponseDto.js +1 -0
- package/data/api/dto/response/EmptyMetadataDto.d.ts +4 -0
- package/data/api/dto/response/EmptyMetadataDto.js +1 -0
- package/data/api/dto/response/index.d.ts +4 -4
- package/data/api/dto/response/index.js +4 -4
- package/data/api/interface/IConcurrencySafe.d.ts +9 -0
- package/data/api/interface/IConcurrencySafe.js +2 -0
- package/data/api/interface/IIdentifiable.d.ts +4 -3
- package/data/api/interface/IIdentifiableSecondary.d.ts +3 -3
- package/data/api/interface/index.d.ts +1 -0
- package/data/api/interface/index.js +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +15 -10
- package/services/api/ApiCrudControllerClient/index.d.ts +9 -5
- package/services/api/ApiCrudControllerClient/index.js +15 -9
- package/services/api/ApiInitializationService/index.d.ts +21 -3
- package/services/api/ApiInitializationService/index.js +36 -7
- package/services/api/ApiReadControllerClient/index.d.ts +12 -13
- package/services/api/ApiReadControllerClient/index.js +17 -18
- package/services/api/HttpService/FetchHttpService.d.ts +1 -1
- package/services/api/HttpService/FetchHttpService.js +2 -1
- package/services/api/HttpService/HttpRequestConfig.d.ts +1 -0
- package/services/api/HttpService/IHttpService.d.ts +1 -1
- package/services/api/HttpService/index.d.ts +0 -2
- package/services/api/HttpService/index.js +0 -2
- package/services/api/UserManagementControllerClient/index.d.ts +9 -5
- package/services/api/UserManagementControllerClient/index.js +20 -12
- package/services/auth/client/AuthService/index.d.ts +5 -5
- package/services/auth/client/AuthService/index.js +9 -9
- package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +5 -5
- package/services/auth/client/AuthorizationManagementControllerClient/index.js +8 -8
- package/utils/index.d.ts +37 -0
- package/utils/index.js +106 -0
- package/data/api/dto/response/EmptyMetadata.d.ts +0 -4
- package/services/api/HttpService/AngularHttpService.d.ts +0 -9
- package/services/api/HttpService/AngularHttpService.js +0 -86
- package/services/api/HttpService/AxiosHttpService.d.ts +0 -10
- package/services/api/HttpService/AxiosHttpService.js +0 -53
- /package/data/api/dto/{crud/CrudMetadata.js → PropertyPathDto.js} +0 -0
- /package/data/api/dto/{read/ReadMetadata.js → ReadOptionsDto.js} +0 -0
- /package/data/api/dto/{response/ApiError.js → ReadResultDto.js} +0 -0
- /package/data/api/dto/{response/ApiResponse.js → ReadResultMetadataDto.js} +0 -0
- /package/data/api/dto/{response/ApiSuccessResponse.js → crud/CrudMetadataDto.js} +0 -0
- /package/data/api/dto/{response/EmptyMetadata.js → read/ReadMetadataDto.js} +0 -0
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { apiInitializationService } from '../ApiInitializationService';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @class ApiReadControllerClient
|
|
7
|
-
* @template TKey - Type of the entity key (e.g., number, string, GUID, etc.)
|
|
8
|
-
* @template TDto - Data Transfer Object representing the entity
|
|
3
|
+
* Base client for read-only API controllers
|
|
9
4
|
*/
|
|
10
5
|
export class ApiReadControllerClient {
|
|
11
6
|
baseControllerPath;
|
|
@@ -30,12 +25,13 @@ export class ApiReadControllerClient {
|
|
|
30
25
|
// #region API
|
|
31
26
|
/**
|
|
32
27
|
* Fetches all entities from the read controller.
|
|
33
|
-
* @
|
|
28
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
29
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
|
|
34
30
|
*/
|
|
35
|
-
async
|
|
31
|
+
async readAllAsync(signal) {
|
|
36
32
|
try {
|
|
37
|
-
const url = await apiInitializationService.
|
|
38
|
-
const res = await this.httpService.
|
|
33
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/ReadAll`);
|
|
34
|
+
const res = await this.httpService.requestAsync(url, { method: 'GET', credentials: 'include', signal });
|
|
39
35
|
if (!res.ok)
|
|
40
36
|
throw undefined;
|
|
41
37
|
const { success, result, metadata, error } = (await res.json());
|
|
@@ -51,16 +47,18 @@ export class ApiReadControllerClient {
|
|
|
51
47
|
/**
|
|
52
48
|
* Fetches selected entities based on a filter definition.
|
|
53
49
|
* @param {any} definition - The filter definition object
|
|
54
|
-
* @
|
|
50
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
51
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} The result of the read operation with metadata
|
|
55
52
|
*/
|
|
56
|
-
async
|
|
53
|
+
async readSelectedAsync(definition, signal) {
|
|
57
54
|
try {
|
|
58
|
-
const url = await apiInitializationService.
|
|
59
|
-
const res = await this.httpService.
|
|
55
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/ReadSelected`);
|
|
56
|
+
const res = await this.httpService.requestAsync(url, {
|
|
60
57
|
method: 'POST',
|
|
61
58
|
headers: { 'Content-Type': 'application/json' },
|
|
62
59
|
body: JSON.stringify(definition),
|
|
63
60
|
credentials: 'include',
|
|
61
|
+
signal,
|
|
64
62
|
});
|
|
65
63
|
if (!res.ok)
|
|
66
64
|
throw undefined;
|
|
@@ -77,12 +75,13 @@ export class ApiReadControllerClient {
|
|
|
77
75
|
/**
|
|
78
76
|
* Fetches a single entity by its ID.
|
|
79
77
|
* @param {TKey} id - The ID of the entity
|
|
80
|
-
* @
|
|
78
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
79
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
|
|
81
80
|
*/
|
|
82
|
-
async
|
|
81
|
+
async readSingleAsync(id, signal) {
|
|
83
82
|
try {
|
|
84
|
-
const url = await apiInitializationService.
|
|
85
|
-
const res = await this.httpService.
|
|
83
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/ReadSingle?id=${encodeURIComponent(String(id))}`);
|
|
84
|
+
const res = await this.httpService.requestAsync(url, { method: 'GET', credentials: 'include', signal });
|
|
86
85
|
if (!res.ok)
|
|
87
86
|
throw undefined;
|
|
88
87
|
const { success, result, metadata, error } = (await res.json());
|
|
@@ -3,5 +3,5 @@ import { HttpRequestConfig, HttpResponse, IHttpService } from '../../../services
|
|
|
3
3
|
* Default HTTP service implementation using the Fetch API
|
|
4
4
|
*/
|
|
5
5
|
export declare class FetchHttpService implements IHttpService {
|
|
6
|
-
|
|
6
|
+
requestAsync<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
7
7
|
}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* Default HTTP service implementation using the Fetch API
|
|
5
5
|
*/
|
|
6
6
|
export class FetchHttpService {
|
|
7
|
-
async
|
|
7
|
+
async requestAsync(url, config) {
|
|
8
8
|
const response = await fetch(url, {
|
|
9
9
|
method: config?.method || 'GET',
|
|
10
10
|
headers: config?.headers,
|
|
11
11
|
body: config?.body,
|
|
12
12
|
credentials: config?.credentials || 'include',
|
|
13
|
+
signal: config?.signal,
|
|
13
14
|
});
|
|
14
15
|
// Convert Headers to a plain object
|
|
15
16
|
const headers = {};
|
|
@@ -9,5 +9,5 @@ export interface IHttpService {
|
|
|
9
9
|
* @param config - Request configuration
|
|
10
10
|
* @returns Promise that resolves to the HTTP response
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
requestAsync<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
13
|
}
|
|
@@ -3,8 +3,6 @@ import { FetchHttpService } from './FetchHttpService';
|
|
|
3
3
|
* Default HTTP service instance
|
|
4
4
|
*/
|
|
5
5
|
export declare const defaultHttpService: FetchHttpService;
|
|
6
|
-
export * from './AxiosHttpService';
|
|
7
|
-
export * from './AngularHttpService';
|
|
8
6
|
export * from './FetchHttpService';
|
|
9
7
|
export * from './HttpRequestConfig';
|
|
10
8
|
export * from './HttpResponse';
|
|
@@ -4,8 +4,6 @@ import { FetchHttpService } from './FetchHttpService';
|
|
|
4
4
|
*/
|
|
5
5
|
export const defaultHttpService = new FetchHttpService();
|
|
6
6
|
// Export additional HTTP service implementations
|
|
7
|
-
export * from './AxiosHttpService';
|
|
8
|
-
export * from './AngularHttpService';
|
|
9
7
|
export * from './FetchHttpService';
|
|
10
8
|
export * from './HttpRequestConfig';
|
|
11
9
|
export * from './HttpResponse';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiCrudControllerClient } from '../ApiCrudControllerClient';
|
|
2
2
|
import { IHttpService } from '../HttpService';
|
|
3
|
-
import { UserDto, ClaimDto,
|
|
3
|
+
import { UserDto, ClaimDto, ReadMetadataDto, ApiSuccessResponseDto } from '../../../data';
|
|
4
4
|
/**
|
|
5
5
|
* Client for user management operations
|
|
6
6
|
*
|
|
@@ -19,25 +19,29 @@ export declare class UserManagementControllerClient<TKey, TUser extends UserDto<
|
|
|
19
19
|
/**
|
|
20
20
|
* Gets the roles assigned to a user
|
|
21
21
|
* @param id - The ID of the user
|
|
22
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
22
23
|
* @returns List of role names assigned to the user
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
getUserRolesAsync(id: TKey, signal?: AbortSignal): Promise<ApiSuccessResponseDto<string[], ReadMetadataDto>>;
|
|
25
26
|
/**
|
|
26
27
|
* Gets the claims assigned to a user
|
|
27
28
|
* @param id - The ID of the user
|
|
29
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
28
30
|
* @returns List of claims assigned to the user
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
getUserClaimsAsync(id: TKey, signal?: AbortSignal): Promise<ApiSuccessResponseDto<ClaimDto[], ReadMetadataDto>>;
|
|
31
33
|
/**
|
|
32
34
|
* Gets all available roles in the system
|
|
35
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
33
36
|
* @returns List of all role names
|
|
34
37
|
*/
|
|
35
|
-
|
|
38
|
+
getAllRolesAsync(signal?: AbortSignal): Promise<ApiSuccessResponseDto<string[], ReadMetadataDto>>;
|
|
36
39
|
/**
|
|
37
40
|
* Changes the password for a user
|
|
38
41
|
* @param id - The ID of the user
|
|
39
42
|
* @param newPassword - The new password to set
|
|
43
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
40
44
|
* @returns Promise that resolves when the password is changed successfully
|
|
41
45
|
*/
|
|
42
|
-
|
|
46
|
+
changePasswordAsync(id: TKey, newPassword: string, signal?: AbortSignal): Promise<void>;
|
|
43
47
|
}
|
|
@@ -20,14 +20,16 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
|
|
|
20
20
|
/**
|
|
21
21
|
* Gets the roles assigned to a user
|
|
22
22
|
* @param id - The ID of the user
|
|
23
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
23
24
|
* @returns List of role names assigned to the user
|
|
24
25
|
*/
|
|
25
|
-
async
|
|
26
|
+
async getUserRolesAsync(id, signal) {
|
|
26
27
|
try {
|
|
27
|
-
const url = await apiInitializationService.
|
|
28
|
-
const res = await this.httpService.
|
|
28
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, 'GetUserRoles', encodeURIComponent(String(id)));
|
|
29
|
+
const res = await this.httpService.requestAsync(url, {
|
|
29
30
|
method: 'GET',
|
|
30
31
|
credentials: 'include',
|
|
32
|
+
signal,
|
|
31
33
|
});
|
|
32
34
|
if (!res.ok)
|
|
33
35
|
throw undefined;
|
|
@@ -44,14 +46,16 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
|
|
|
44
46
|
/**
|
|
45
47
|
* Gets the claims assigned to a user
|
|
46
48
|
* @param id - The ID of the user
|
|
49
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
47
50
|
* @returns List of claims assigned to the user
|
|
48
51
|
*/
|
|
49
|
-
async
|
|
52
|
+
async getUserClaimsAsync(id, signal) {
|
|
50
53
|
try {
|
|
51
|
-
const url = await apiInitializationService.
|
|
52
|
-
const res = await this.httpService.
|
|
54
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, 'GetUserClaims', encodeURIComponent(String(id)));
|
|
55
|
+
const res = await this.httpService.requestAsync(url, {
|
|
53
56
|
method: 'GET',
|
|
54
57
|
credentials: 'include',
|
|
58
|
+
signal,
|
|
55
59
|
});
|
|
56
60
|
if (!res.ok)
|
|
57
61
|
throw undefined;
|
|
@@ -67,14 +71,16 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
|
|
|
67
71
|
}
|
|
68
72
|
/**
|
|
69
73
|
* Gets all available roles in the system
|
|
74
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
70
75
|
* @returns List of all role names
|
|
71
76
|
*/
|
|
72
|
-
async
|
|
77
|
+
async getAllRolesAsync(signal) {
|
|
73
78
|
try {
|
|
74
|
-
const url = await apiInitializationService.
|
|
75
|
-
const res = await this.httpService.
|
|
79
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, 'GetAllRoles');
|
|
80
|
+
const res = await this.httpService.requestAsync(url, {
|
|
76
81
|
method: 'GET',
|
|
77
82
|
credentials: 'include',
|
|
83
|
+
signal,
|
|
78
84
|
});
|
|
79
85
|
if (!res.ok)
|
|
80
86
|
throw undefined;
|
|
@@ -92,18 +98,20 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
|
|
|
92
98
|
* Changes the password for a user
|
|
93
99
|
* @param id - The ID of the user
|
|
94
100
|
* @param newPassword - The new password to set
|
|
101
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
95
102
|
* @returns Promise that resolves when the password is changed successfully
|
|
96
103
|
*/
|
|
97
|
-
async
|
|
104
|
+
async changePasswordAsync(id, newPassword, signal) {
|
|
98
105
|
try {
|
|
99
|
-
const url = await apiInitializationService.
|
|
100
|
-
const response = await this.httpService.
|
|
106
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, 'ChangePassword', encodeURIComponent(String(id)));
|
|
107
|
+
const response = await this.httpService.requestAsync(url, {
|
|
101
108
|
method: 'POST',
|
|
102
109
|
headers: {
|
|
103
110
|
'Content-Type': 'application/json',
|
|
104
111
|
},
|
|
105
112
|
body: JSON.stringify(newPassword),
|
|
106
113
|
credentials: 'include',
|
|
114
|
+
signal,
|
|
107
115
|
});
|
|
108
116
|
if (!response.ok)
|
|
109
117
|
throw undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiSuccessResponseDto, EmptyMetadataDto, UserDto, UserInfoDto } from '../../../../data';
|
|
2
2
|
export { UserDto, UserInfoDto };
|
|
3
3
|
/**
|
|
4
4
|
* AuthService class is responsible for managing user authentication operations.
|
|
@@ -18,14 +18,14 @@ export declare class AuthService<TKey, TUser extends UserDto<TKey> = UserDto<TKe
|
|
|
18
18
|
* @async
|
|
19
19
|
* @return {Promise<void>} Resolves when initialization is complete.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
initializeAsync(): Promise<void>;
|
|
22
22
|
/**
|
|
23
23
|
* Checks if user is authenticated and retrieves the current user's details if they are
|
|
24
24
|
*
|
|
25
25
|
* @return {Promise<UserInfoDto<TKey, TUser>>} Currently logged in user's details
|
|
26
26
|
* @throws {Error} Error if fetch fails
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
whoAmIAsync(): Promise<ApiSuccessResponseDto<UserInfoDto<TKey, TUser> | undefined, EmptyMetadataDto>>;
|
|
29
29
|
/**
|
|
30
30
|
* Authenticates a user using their username and password, and retrieves user's details
|
|
31
31
|
*
|
|
@@ -34,14 +34,14 @@ export declare class AuthService<TKey, TUser extends UserDto<TKey> = UserDto<TKe
|
|
|
34
34
|
* @return {Promise<TUser>} Currently logged in user's details
|
|
35
35
|
* @throws {Error} Error if fetch fails
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
signinAsync(username: string, password: string): Promise<ApiSuccessResponseDto<TUser, EmptyMetadataDto>>;
|
|
38
38
|
/**
|
|
39
39
|
* Deauthenticates current user
|
|
40
40
|
*
|
|
41
41
|
* @return {Promise<void>}
|
|
42
42
|
* @throws {Error} Error if fetch fails
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
signoutAsync(): Promise<void>;
|
|
45
45
|
/**
|
|
46
46
|
* If any API response returns an "Unauthenticated" response, call this method
|
|
47
47
|
* to update local authentication state to unauthenticated
|
|
@@ -17,9 +17,9 @@ export class AuthService {
|
|
|
17
17
|
* @async
|
|
18
18
|
* @return {Promise<void>} Resolves when initialization is complete.
|
|
19
19
|
*/
|
|
20
|
-
async
|
|
20
|
+
async initializeAsync() {
|
|
21
21
|
// Check user's authentication status
|
|
22
|
-
await this.
|
|
22
|
+
await this.whoAmIAsync();
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Checks if user is authenticated and retrieves the current user's details if they are
|
|
@@ -27,9 +27,9 @@ export class AuthService {
|
|
|
27
27
|
* @return {Promise<UserInfoDto<TKey, TUser>>} Currently logged in user's details
|
|
28
28
|
* @throws {Error} Error if fetch fails
|
|
29
29
|
*/
|
|
30
|
-
async
|
|
30
|
+
async whoAmIAsync() {
|
|
31
31
|
try {
|
|
32
|
-
const url = await apiInitializationService.
|
|
32
|
+
const url = await apiInitializationService.getApiUrlAsync('/auth/whoami');
|
|
33
33
|
const res = await fetch(url, { credentials: 'include' });
|
|
34
34
|
if (!res.ok && res.status !== 401) {
|
|
35
35
|
this.user = undefined;
|
|
@@ -58,9 +58,9 @@ export class AuthService {
|
|
|
58
58
|
* @return {Promise<TUser>} Currently logged in user's details
|
|
59
59
|
* @throws {Error} Error if fetch fails
|
|
60
60
|
*/
|
|
61
|
-
async
|
|
61
|
+
async signinAsync(username, password) {
|
|
62
62
|
try {
|
|
63
|
-
const url = await apiInitializationService.
|
|
63
|
+
const url = await apiInitializationService.getApiUrlAsync('/auth/signin');
|
|
64
64
|
const res = await fetch(url, {
|
|
65
65
|
method: 'POST',
|
|
66
66
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -70,7 +70,7 @@ export class AuthService {
|
|
|
70
70
|
if (!res.ok)
|
|
71
71
|
throw undefined;
|
|
72
72
|
// TODO: Handle tokens if not using cookies
|
|
73
|
-
const { result, metadata } = await this.
|
|
73
|
+
const { result, metadata } = await this.whoAmIAsync();
|
|
74
74
|
if (result === undefined)
|
|
75
75
|
throw undefined;
|
|
76
76
|
this.user = result.user;
|
|
@@ -87,9 +87,9 @@ export class AuthService {
|
|
|
87
87
|
* @return {Promise<void>}
|
|
88
88
|
* @throws {Error} Error if fetch fails
|
|
89
89
|
*/
|
|
90
|
-
async
|
|
90
|
+
async signoutAsync() {
|
|
91
91
|
try {
|
|
92
|
-
const url = await apiInitializationService.
|
|
92
|
+
const url = await apiInitializationService.getApiUrlAsync('/auth/signout');
|
|
93
93
|
const res = await fetch(url, { credentials: 'include' });
|
|
94
94
|
if (!res.ok)
|
|
95
95
|
throw undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiSuccessResponseDto, EmptyMetadataDto, ReadMetadataDto, RoleDto } from '../../../../data';
|
|
2
2
|
/**
|
|
3
3
|
* Client for authorization management operations
|
|
4
4
|
*
|
|
@@ -17,23 +17,23 @@ export declare class AuthorizationManagementControllerClient {
|
|
|
17
17
|
* @param includeClaims - Whether to include claims in the response
|
|
18
18
|
* @returns List of all roles
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
getAllRolesAsync(includeClaims: boolean): Promise<ApiSuccessResponseDto<RoleDto[], ReadMetadataDto>>;
|
|
21
21
|
/**
|
|
22
22
|
* Gets a role with its claims
|
|
23
23
|
* @param roleName - The name of the role
|
|
24
24
|
* @returns The role with its claims
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
getRoleWithClaimsAsync(roleName: string): Promise<ApiSuccessResponseDto<RoleDto, ReadMetadataDto>>;
|
|
27
27
|
/**
|
|
28
28
|
* Creates or updates a role
|
|
29
29
|
* @param roleDto - The role to create or update
|
|
30
30
|
* @returns The created or updated role
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
upsertRoleAsync(roleDto: RoleDto): Promise<ApiSuccessResponseDto<RoleDto, EmptyMetadataDto>>;
|
|
33
33
|
/**
|
|
34
34
|
* Deletes a role
|
|
35
35
|
* @param roleName - The name of the role to delete
|
|
36
36
|
* @returns Promise that resolves when the role is deleted successfully
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
deleteRoleAsync(roleName: string): Promise<void>;
|
|
39
39
|
}
|
|
@@ -19,9 +19,9 @@ export class AuthorizationManagementControllerClient {
|
|
|
19
19
|
* @param includeClaims - Whether to include claims in the response
|
|
20
20
|
* @returns List of all roles
|
|
21
21
|
*/
|
|
22
|
-
async
|
|
22
|
+
async getAllRolesAsync(includeClaims) {
|
|
23
23
|
try {
|
|
24
|
-
const url = await apiInitializationService.
|
|
24
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/GetAllRoles?includeClaims=${includeClaims}`);
|
|
25
25
|
const res = await fetch(url, {
|
|
26
26
|
credentials: 'include',
|
|
27
27
|
});
|
|
@@ -42,9 +42,9 @@ export class AuthorizationManagementControllerClient {
|
|
|
42
42
|
* @param roleName - The name of the role
|
|
43
43
|
* @returns The role with its claims
|
|
44
44
|
*/
|
|
45
|
-
async
|
|
45
|
+
async getRoleWithClaimsAsync(roleName) {
|
|
46
46
|
try {
|
|
47
|
-
const url = await apiInitializationService.
|
|
47
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/GetRoleWithClaims/${encodeURIComponent(roleName)}`);
|
|
48
48
|
const res = await fetch(url, {
|
|
49
49
|
credentials: 'include',
|
|
50
50
|
});
|
|
@@ -65,9 +65,9 @@ export class AuthorizationManagementControllerClient {
|
|
|
65
65
|
* @param roleDto - The role to create or update
|
|
66
66
|
* @returns The created or updated role
|
|
67
67
|
*/
|
|
68
|
-
async
|
|
68
|
+
async upsertRoleAsync(roleDto) {
|
|
69
69
|
try {
|
|
70
|
-
const url = await apiInitializationService.
|
|
70
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/UpsertRole`);
|
|
71
71
|
const res = await fetch(url, {
|
|
72
72
|
method: 'PUT',
|
|
73
73
|
headers: {
|
|
@@ -93,9 +93,9 @@ export class AuthorizationManagementControllerClient {
|
|
|
93
93
|
* @param roleName - The name of the role to delete
|
|
94
94
|
* @returns Promise that resolves when the role is deleted successfully
|
|
95
95
|
*/
|
|
96
|
-
async
|
|
96
|
+
async deleteRoleAsync(roleName) {
|
|
97
97
|
try {
|
|
98
|
-
const url = await apiInitializationService.
|
|
98
|
+
const url = await apiInitializationService.getApiUrlAsync(this.baseControllerPath, `/DeleteRole/${encodeURIComponent(roleName)}`);
|
|
99
99
|
const response = await fetch(url, {
|
|
100
100
|
method: 'DELETE',
|
|
101
101
|
credentials: 'include',
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PropertyPathDto, ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType, ReadSelectedSearchDefinitionDto } from '../data';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a ReadSelectedSearchDefinitionDto ready to be used with the CollectionViewAdapter
|
|
4
|
+
*
|
|
5
|
+
* @param logicalOperator - specify `ReadSelectedLogicalOperator` that will apply to all `ReadSelectedSearchPropertyDefinitionDto` property definitions included in this search definition
|
|
6
|
+
* @param conditions - Variable number of condition objects containing:
|
|
7
|
+
* - path: The property name from the DTO to search on
|
|
8
|
+
* - operator: The `ReadSelectedComparisonOperator` enum
|
|
9
|
+
* - value: The value to compare against
|
|
10
|
+
* - valueType: The `ReadSelectedPropertyType` being compared
|
|
11
|
+
*/
|
|
12
|
+
export declare function condition(logicalOperator: ReadSelectedLogicalOperator, ...conditions: Array<{
|
|
13
|
+
path: PropertyPathDto;
|
|
14
|
+
operator: ReadSelectedComparisonOperator;
|
|
15
|
+
value: any;
|
|
16
|
+
valueType: ReadSelectedPropertyType;
|
|
17
|
+
}>): ReadSelectedSearchDefinitionDto;
|
|
18
|
+
/**
|
|
19
|
+
* Combines multiple ReadSelectedSearchDefinitionDto with AND logic
|
|
20
|
+
*/
|
|
21
|
+
export declare function and(...definitions: ReadSelectedSearchDefinitionDto[]): ReadSelectedSearchDefinitionDto;
|
|
22
|
+
/**
|
|
23
|
+
* Combines multiple ReadSelectedSearchDefinitionDto with OR logic
|
|
24
|
+
*/
|
|
25
|
+
export declare function or(...definitions: ReadSelectedSearchDefinitionDto[]): ReadSelectedSearchDefinitionDto;
|
|
26
|
+
/**
|
|
27
|
+
* Preset implementation for filtering by `searchTerm`. String types will search by provided `textSearchablePaths` with `ReadSelectedComparisonOperator.Contains`. Numeric types will search by provided `numericSearchablePaths`, `parseInt` the search term and use `ReadSelectedComparisonOperator.Equal`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function searchTerm(searchTerm: string, textSearchablePaths: string[][], numericSearchablePaths: string[][]): void | ReadSelectedSearchDefinitionDto;
|
|
30
|
+
/**
|
|
31
|
+
* Preset implementation for filtering a date range. User may select desired `ReadSelectedComparisonOperator` and `ReadSelectedPropertyType` for the from and to dates. Valid object property must be provided for `searchablePath`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function dateInterval(fromDate: Date, toDate: Date, fromDateComparisonOperator: ReadSelectedComparisonOperator, toDateComparisonOperator: ReadSelectedComparisonOperator, valueType: ReadSelectedPropertyType, searchablePath: PropertyPathDto): void | ReadSelectedSearchDefinitionDto;
|
|
34
|
+
/**
|
|
35
|
+
* Converts the camel case used on the TS client to Pascal case expected by the API
|
|
36
|
+
*/
|
|
37
|
+
export declare function toPascalCase(str: PropertyPathDto): PropertyPathDto;
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType, } from '../data';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a ReadSelectedSearchDefinitionDto ready to be used with the CollectionViewAdapter
|
|
4
|
+
*
|
|
5
|
+
* @param logicalOperator - specify `ReadSelectedLogicalOperator` that will apply to all `ReadSelectedSearchPropertyDefinitionDto` property definitions included in this search definition
|
|
6
|
+
* @param conditions - Variable number of condition objects containing:
|
|
7
|
+
* - path: The property name from the DTO to search on
|
|
8
|
+
* - operator: The `ReadSelectedComparisonOperator` enum
|
|
9
|
+
* - value: The value to compare against
|
|
10
|
+
* - valueType: The `ReadSelectedPropertyType` being compared
|
|
11
|
+
*/
|
|
12
|
+
export function condition(logicalOperator, ...conditions) {
|
|
13
|
+
return {
|
|
14
|
+
logicalOperator: logicalOperator,
|
|
15
|
+
propertyCriteria: conditions.map(condition => ({
|
|
16
|
+
propertyPath: toPascalCase(condition.path),
|
|
17
|
+
comparisonOperator: condition.operator,
|
|
18
|
+
valueType: condition.valueType,
|
|
19
|
+
value: condition.value,
|
|
20
|
+
})),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Combines multiple ReadSelectedSearchDefinitionDto with AND logic
|
|
25
|
+
*/
|
|
26
|
+
export function and(...definitions) {
|
|
27
|
+
return {
|
|
28
|
+
logicalOperator: ReadSelectedLogicalOperator.And,
|
|
29
|
+
nestedSearchCriteria: definitions,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Combines multiple ReadSelectedSearchDefinitionDto with OR logic
|
|
34
|
+
*/
|
|
35
|
+
export function or(...definitions) {
|
|
36
|
+
return {
|
|
37
|
+
logicalOperator: ReadSelectedLogicalOperator.Or,
|
|
38
|
+
nestedSearchCriteria: definitions,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Preset implementation for filtering by `searchTerm`. String types will search by provided `textSearchablePaths` with `ReadSelectedComparisonOperator.Contains`. Numeric types will search by provided `numericSearchablePaths`, `parseInt` the search term and use `ReadSelectedComparisonOperator.Equal`.
|
|
43
|
+
*/
|
|
44
|
+
export function searchTerm(searchTerm, textSearchablePaths, numericSearchablePaths) {
|
|
45
|
+
let comparisonOperator;
|
|
46
|
+
let valueType;
|
|
47
|
+
let searchablePaths;
|
|
48
|
+
let searchValue;
|
|
49
|
+
try {
|
|
50
|
+
const numericValue = parseInt(searchTerm);
|
|
51
|
+
if (!Number.isNaN(numericValue) && String(numericValue) === searchTerm.trim()) {
|
|
52
|
+
comparisonOperator = ReadSelectedComparisonOperator.Equal;
|
|
53
|
+
valueType = ReadSelectedPropertyType.Int;
|
|
54
|
+
searchablePaths = numericSearchablePaths;
|
|
55
|
+
searchValue = numericValue;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
comparisonOperator = ReadSelectedComparisonOperator.Contains;
|
|
59
|
+
valueType = ReadSelectedPropertyType.String;
|
|
60
|
+
searchablePaths = textSearchablePaths;
|
|
61
|
+
searchValue = searchTerm;
|
|
62
|
+
}
|
|
63
|
+
const searchConditions = searchablePaths.map(path => ({
|
|
64
|
+
path: toPascalCase(path),
|
|
65
|
+
operator: comparisonOperator,
|
|
66
|
+
value: searchValue,
|
|
67
|
+
valueType: valueType,
|
|
68
|
+
}));
|
|
69
|
+
return condition(ReadSelectedLogicalOperator.Or, ...searchConditions);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Preset implementation for filtering a date range. User may select desired `ReadSelectedComparisonOperator` and `ReadSelectedPropertyType` for the from and to dates. Valid object property must be provided for `searchablePath`.
|
|
77
|
+
*/
|
|
78
|
+
export function dateInterval(fromDate, toDate, fromDateComparisonOperator, toDateComparisonOperator, valueType, searchablePath) {
|
|
79
|
+
try {
|
|
80
|
+
if (!(valueType === ReadSelectedPropertyType.DateOnly ||
|
|
81
|
+
valueType === ReadSelectedPropertyType.DateTime ||
|
|
82
|
+
valueType === ReadSelectedPropertyType.DateTimeOffset)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
return condition(ReadSelectedLogicalOperator.And, {
|
|
86
|
+
path: toPascalCase(searchablePath),
|
|
87
|
+
operator: fromDateComparisonOperator,
|
|
88
|
+
value: fromDate,
|
|
89
|
+
valueType: valueType,
|
|
90
|
+
}, {
|
|
91
|
+
path: toPascalCase(searchablePath),
|
|
92
|
+
operator: toDateComparisonOperator,
|
|
93
|
+
value: toDate,
|
|
94
|
+
valueType: valueType,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Converts the camel case used on the TS client to Pascal case expected by the API
|
|
103
|
+
*/
|
|
104
|
+
export function toPascalCase(str) {
|
|
105
|
+
return str.map(part => part.charAt(0).toUpperCase() + part.slice(1));
|
|
106
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IHttpService, HttpRequestConfig, HttpResponse } from './index';
|
|
2
|
-
/**
|
|
3
|
-
* Angular HttpClient-based HTTP service implementation
|
|
4
|
-
*/
|
|
5
|
-
export declare class AngularHttpService implements IHttpService {
|
|
6
|
-
private httpClient;
|
|
7
|
-
constructor(httpClient: any);
|
|
8
|
-
request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
9
|
-
}
|