@intellegens/cornerstone-client 0.0.44 → 0.0.9999-alpha-1
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/{crud/CrudMetadata.js → PropertyPathDto.js} +0 -0
- package/data/api/dto/ReadOptionsDto.d.ts +8 -0
- package/data/api/dto/{read/ReadMetadata.js → ReadOptionsDto.js} +0 -0
- package/data/api/dto/ReadResultDto.d.ts +12 -0
- package/data/api/dto/{response/ApiError.js → ReadResultDto.js} +0 -0
- package/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
- package/data/api/dto/{response/ApiResponse.js → ReadResultMetadataDto.js} +0 -0
- package/data/api/dto/crud/{CrudMetadata.d.ts → CrudMetadataDto.d.ts} +1 -1
- package/data/api/dto/{response/ApiSuccessResponse.js → crud/CrudMetadataDto.js} +0 -0
- 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/{response/EmptyMetadata.js → read/ReadMetadataDto.js} +0 -0
- package/data/api/dto/read/ReadSelectedDefinitionDto.d.ts +0 -0
- package/data/api/dto/read/ReadSelectedDefinitionDto.js +0 -0
- package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.d.ts +0 -0
- package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.js +0 -0
- package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
- package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.js +0 -0
- package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.d.ts +0 -0
- package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.js +0 -0
- package/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +0 -0
- package/data/api/dto/read/ReadSelectedSearchDefinitionDto.js +0 -0
- package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +2 -2
- package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.js +0 -0
- 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/enum/index.d.ts +0 -0
- package/data/api/enum/index.js +0 -0
- package/data/api/enum/read/ReadSelectedComparisonOperator.d.ts +0 -0
- package/data/api/enum/read/ReadSelectedComparisonOperator.js +0 -0
- package/data/api/enum/read/ReadSelectedLogicalOperator.d.ts +0 -0
- package/data/api/enum/read/ReadSelectedLogicalOperator.js +0 -0
- package/data/api/enum/read/ReadSelectedOrderingDirection.d.ts +0 -0
- package/data/api/enum/read/ReadSelectedOrderingDirection.js +0 -0
- package/data/api/enum/read/ReadSelectedPropertyType.d.ts +0 -0
- package/data/api/enum/read/ReadSelectedPropertyType.js +0 -0
- package/data/api/enum/read/index.d.ts +0 -0
- package/data/api/enum/read/index.js +0 -0
- package/data/api/enum/response/ApiErrorCodes.d.ts +0 -0
- package/data/api/enum/response/ApiErrorCodes.js +0 -0
- package/data/api/enum/response/index.d.ts +0 -0
- package/data/api/enum/response/index.js +0 -0
- package/data/api/index.d.ts +0 -0
- package/data/api/index.js +0 -0
- 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/IIdentifiable.js +0 -0
- package/data/api/interface/IIdentifiableSecondary.d.ts +3 -3
- package/data/api/interface/IIdentifiableSecondary.js +0 -0
- package/data/api/interface/index.d.ts +1 -0
- package/data/api/interface/index.js +1 -0
- package/data/auth/dto/ClaimDto.d.ts +0 -0
- package/data/auth/dto/ClaimDto.js +0 -0
- package/data/auth/dto/RegisterRequestDto.d.ts +0 -0
- package/data/auth/dto/RegisterRequestDto.js +0 -0
- package/data/auth/dto/RoleDto.d.ts +0 -0
- package/data/auth/dto/RoleDto.js +0 -0
- package/data/auth/dto/SignInRequestDto.d.ts +0 -0
- package/data/auth/dto/SignInRequestDto.js +0 -0
- package/data/auth/dto/TokensDto.d.ts +0 -0
- package/data/auth/dto/TokensDto.js +0 -0
- package/data/auth/dto/UserDto.d.ts +0 -0
- package/data/auth/dto/UserDto.js +0 -0
- package/data/auth/dto/UserInfoDto.d.ts +0 -0
- package/data/auth/dto/UserInfoDto.js +0 -0
- package/data/auth/dto/index.d.ts +0 -0
- package/data/auth/dto/index.js +0 -0
- package/data/auth/index.d.ts +0 -0
- package/data/auth/index.js +0 -0
- package/data/index.d.ts +0 -0
- package/data/index.js +0 -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/HttpRequestConfig.js +0 -0
- package/services/api/HttpService/HttpResponse.d.ts +0 -0
- package/services/api/HttpService/HttpResponse.js +0 -0
- package/services/api/HttpService/IHttpService.d.ts +1 -1
- package/services/api/HttpService/IHttpService.js +0 -0
- 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/api/index.d.ts +0 -0
- package/services/api/index.js +0 -0
- 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/services/auth/client/index.d.ts +0 -0
- package/services/auth/client/index.js +0 -0
- package/services/auth/index.d.ts +0 -0
- package/services/auth/index.js +0 -0
- package/services/index.d.ts +0 -0
- package/services/index.js +0 -0
- 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
|
@@ -11,17 +11,21 @@ export class ApiInitializationService {
|
|
|
11
11
|
*
|
|
12
12
|
* This method calls all methods that need to be called during the API configuration phase:
|
|
13
13
|
* - Starts detection of API base URL.
|
|
14
|
+
* - Fetches shared settings from the server.
|
|
14
15
|
*
|
|
15
16
|
* @async
|
|
16
17
|
* @param httpService - HTTP service implementation to use for requests
|
|
18
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
17
19
|
* @return {Promise<void>} Resolves when initialization is complete.
|
|
18
20
|
*/
|
|
19
|
-
async
|
|
21
|
+
async initializeAsync({ httpService, signal } = {}) {
|
|
20
22
|
// Store configuration
|
|
21
23
|
if (httpService !== undefined)
|
|
22
24
|
this._httpService = httpService;
|
|
23
25
|
// (Pre)detect API base URL
|
|
24
|
-
await this.
|
|
26
|
+
await this._getApiBaseUrlAsync(signal);
|
|
27
|
+
// Initialize app config
|
|
28
|
+
await this._getAppConfigAsync();
|
|
25
29
|
}
|
|
26
30
|
// #region HTTP service
|
|
27
31
|
_httpService = defaultHttpService;
|
|
@@ -65,10 +69,11 @@ export class ApiInitializationService {
|
|
|
65
69
|
* IMPORTANT: This method is not meant to be used in normal cases - when ever possible use the .getApiUrl(relativeEndpointPath: string) method instead.
|
|
66
70
|
*
|
|
67
71
|
* @async
|
|
72
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
68
73
|
* @return {Promise<string | undefined>} Returns detected API base URL
|
|
69
74
|
* @throws {Error} Throws error if either of the detection methods fails
|
|
70
75
|
*/
|
|
71
|
-
async
|
|
76
|
+
async _getApiBaseUrlAsync(signal) {
|
|
72
77
|
// Check if API already detected; don't reattempt detection
|
|
73
78
|
if (this._apiBaseUrlDetected)
|
|
74
79
|
return this._apiBaseUrl;
|
|
@@ -84,7 +89,7 @@ export class ApiInitializationService {
|
|
|
84
89
|
this._apiBaseError = undefined;
|
|
85
90
|
// Check CORNERSTONE-API-BASEURL header for API base URL
|
|
86
91
|
try {
|
|
87
|
-
const currentUrlResponse = await this._httpService.
|
|
92
|
+
const currentUrlResponse = await this._httpService.requestAsync(window.location.href, { method: 'GET', signal });
|
|
88
93
|
const apiHeader = currentUrlResponse.headers['CORNERSTONE-API-BASEURL'] || currentUrlResponse.headers['cornerstone-api-baseurl'] || null;
|
|
89
94
|
if (apiHeader) {
|
|
90
95
|
this._apiBaseUrlDetected = true;
|
|
@@ -100,7 +105,7 @@ export class ApiInitializationService {
|
|
|
100
105
|
}
|
|
101
106
|
// Check ./websettings.json header for API base URL
|
|
102
107
|
try {
|
|
103
|
-
const webSettingsResponse = await this._httpService.
|
|
108
|
+
const webSettingsResponse = await this._httpService.requestAsync('./websettings.json', { method: 'GET', signal });
|
|
104
109
|
if (webSettingsResponse.status === 404)
|
|
105
110
|
return (this._apiBaseUrl = undefined);
|
|
106
111
|
const webSettings = await webSettingsResponse.json();
|
|
@@ -141,8 +146,8 @@ export class ApiInitializationService {
|
|
|
141
146
|
* @return {Promise<string | undefined>} Returns the API endpoint's URL
|
|
142
147
|
* @throws {Error} Throws error if API base URL detection fails
|
|
143
148
|
*/
|
|
144
|
-
async
|
|
145
|
-
const apiBaseUrl = await this.
|
|
149
|
+
async getApiUrlAsync(...relativeEndpointPathSections) {
|
|
150
|
+
const apiBaseUrl = await this._getApiBaseUrlAsync();
|
|
146
151
|
const domain = !apiBaseUrl ? '/' : `${this.removeEndsWithSlashChar(apiBaseUrl)}/`;
|
|
147
152
|
const path = relativeEndpointPathSections.map(section => this.removeStartsWithSlashChar(this.removeEndsWithSlashChar(section))).join('/');
|
|
148
153
|
return `${domain}${path}`;
|
|
@@ -163,6 +168,30 @@ export class ApiInitializationService {
|
|
|
163
168
|
removeEndsWithSlashChar(str) {
|
|
164
169
|
return !str.endsWith('/') ? str : str.substring(0, str.length - 1);
|
|
165
170
|
}
|
|
171
|
+
// #endregion
|
|
172
|
+
// #region config App
|
|
173
|
+
appConfig;
|
|
174
|
+
/**
|
|
175
|
+
* Fetches initialization info (shared settings) from the server
|
|
176
|
+
* @returns Promise that resolves to shared settings or undefined if the request fails
|
|
177
|
+
*/
|
|
178
|
+
async _getAppConfigAsync() {
|
|
179
|
+
try {
|
|
180
|
+
const response = await fetch(`${this._apiBaseUrl}/api/system/init`, { credentials: 'include' });
|
|
181
|
+
if (!response.ok)
|
|
182
|
+
throw new Error('Failed to get app config');
|
|
183
|
+
const apiResponse = await response.json();
|
|
184
|
+
// Check if the API response indicates success
|
|
185
|
+
if (!apiResponse.success || !apiResponse.result) {
|
|
186
|
+
throw new Error(apiResponse.error?.message || 'Server returned unsuccessful response');
|
|
187
|
+
}
|
|
188
|
+
// Return the settings from the nested structure
|
|
189
|
+
this.appConfig = apiResponse.result.settings;
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
this.appConfig = undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
166
195
|
}
|
|
167
196
|
/**
|
|
168
197
|
* Singleton instance of ApiInitializationService
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiSuccessResponseDto, EmptyMetadataDto, ReadMetadataDto, ReadSelectedDefinitionDto } from '../../../data/api/dto';
|
|
2
|
+
import { IIdentifiable } from '../../../data/api/interface';
|
|
2
3
|
import { IHttpService } from '../HttpService';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @export
|
|
7
|
-
* @class ApiReadControllerClient
|
|
8
|
-
* @template TKey - Type of the entity key (e.g., number, string, GUID, etc.)
|
|
9
|
-
* @template TDto - Data Transfer Object representing the entity
|
|
5
|
+
* Base client for read-only API controllers
|
|
10
6
|
*/
|
|
11
7
|
export declare class ApiReadControllerClient<TKey, TDto extends IIdentifiable<TKey>> {
|
|
12
8
|
protected readonly baseControllerPath: string;
|
|
@@ -23,19 +19,22 @@ export declare class ApiReadControllerClient<TKey, TDto extends IIdentifiable<TK
|
|
|
23
19
|
protected get httpService(): IHttpService;
|
|
24
20
|
/**
|
|
25
21
|
* Fetches all entities from the read controller.
|
|
26
|
-
* @
|
|
22
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
23
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
|
|
27
24
|
*/
|
|
28
|
-
|
|
25
|
+
readAllAsync(signal?: AbortSignal): Promise<ApiSuccessResponseDto<TDto[], ReadMetadataDto>>;
|
|
29
26
|
/**
|
|
30
27
|
* Fetches selected entities based on a filter definition.
|
|
31
28
|
* @param {any} definition - The filter definition object
|
|
32
|
-
* @
|
|
29
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
30
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} The result of the read operation with metadata
|
|
33
31
|
*/
|
|
34
|
-
|
|
32
|
+
readSelectedAsync(definition: ReadSelectedDefinitionDto, signal?: AbortSignal): Promise<ApiSuccessResponseDto<TDto[], ReadMetadataDto>>;
|
|
35
33
|
/**
|
|
36
34
|
* Fetches a single entity by its ID.
|
|
37
35
|
* @param {TKey} id - The ID of the entity
|
|
38
|
-
* @
|
|
36
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
37
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
readSingleAsync(id: TKey, signal?: AbortSignal): Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>;
|
|
41
40
|
}
|
|
@@ -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 = {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
}
|
|
File without changes
|
|
@@ -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;
|
package/services/api/index.d.ts
CHANGED
|
File without changes
|
package/services/api/index.js
CHANGED
|
File without changes
|
|
@@ -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',
|
|
File without changes
|
|
File without changes
|
package/services/auth/index.d.ts
CHANGED
|
File without changes
|
package/services/auth/index.js
CHANGED
|
File without changes
|
package/services/index.d.ts
CHANGED
|
File without changes
|
package/services/index.js
CHANGED
|
File without changes
|