@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.
Files changed (132) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +133 -12
  3. package/adapters/CollectionViewAdapter/index.d.ts +154 -0
  4. package/adapters/CollectionViewAdapter/index.js +281 -0
  5. package/adapters/index.d.ts +1 -0
  6. package/adapters/index.js +1 -0
  7. package/data/api/dto/PropertyPathDto.d.ts +4 -0
  8. package/data/api/dto/{crud/CrudMetadata.js → PropertyPathDto.js} +0 -0
  9. package/data/api/dto/ReadOptionsDto.d.ts +8 -0
  10. package/data/api/dto/{read/ReadMetadata.js → ReadOptionsDto.js} +0 -0
  11. package/data/api/dto/ReadResultDto.d.ts +12 -0
  12. package/data/api/dto/{response/ApiError.js → ReadResultDto.js} +0 -0
  13. package/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
  14. package/data/api/dto/{response/ApiResponse.js → ReadResultMetadataDto.js} +0 -0
  15. package/data/api/dto/crud/{CrudMetadata.d.ts → CrudMetadataDto.d.ts} +1 -1
  16. package/data/api/dto/{response/ApiSuccessResponse.js → crud/CrudMetadataDto.js} +0 -0
  17. package/data/api/dto/crud/index.d.ts +1 -1
  18. package/data/api/dto/crud/index.js +1 -1
  19. package/data/api/dto/index.d.ts +1 -0
  20. package/data/api/dto/index.js +1 -0
  21. package/data/api/dto/read/{ReadMetadata.d.ts → ReadMetadataDto.d.ts} +1 -1
  22. package/data/api/dto/{response/EmptyMetadata.js → read/ReadMetadataDto.js} +0 -0
  23. package/data/api/dto/read/ReadSelectedDefinitionDto.d.ts +0 -0
  24. package/data/api/dto/read/ReadSelectedDefinitionDto.js +0 -0
  25. package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.d.ts +0 -0
  26. package/data/api/dto/read/ReadSelectedOrderingDefinitionDto.js +0 -0
  27. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
  28. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.js +0 -0
  29. package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.d.ts +0 -0
  30. package/data/api/dto/read/ReadSelectedPaginationDefinitionDto.js +0 -0
  31. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +0 -0
  32. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.js +0 -0
  33. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +2 -2
  34. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.js +0 -0
  35. package/data/api/dto/read/index.d.ts +1 -1
  36. package/data/api/dto/read/index.js +1 -1
  37. package/data/api/dto/response/{ApiError.d.ts → ApiErrorDto.d.ts} +1 -1
  38. package/data/api/dto/response/ApiErrorDto.js +1 -0
  39. package/data/api/dto/response/{ApiResponse.d.ts → ApiResponseDto.d.ts} +3 -3
  40. package/data/api/dto/response/ApiResponseDto.js +1 -0
  41. package/data/api/dto/response/{ApiSuccessResponse.d.ts → ApiSuccessResponseDto.d.ts} +1 -1
  42. package/data/api/dto/response/ApiSuccessResponseDto.js +1 -0
  43. package/data/api/dto/response/EmptyMetadataDto.d.ts +4 -0
  44. package/data/api/dto/response/EmptyMetadataDto.js +1 -0
  45. package/data/api/dto/response/index.d.ts +4 -4
  46. package/data/api/dto/response/index.js +4 -4
  47. package/data/api/enum/index.d.ts +0 -0
  48. package/data/api/enum/index.js +0 -0
  49. package/data/api/enum/read/ReadSelectedComparisonOperator.d.ts +0 -0
  50. package/data/api/enum/read/ReadSelectedComparisonOperator.js +0 -0
  51. package/data/api/enum/read/ReadSelectedLogicalOperator.d.ts +0 -0
  52. package/data/api/enum/read/ReadSelectedLogicalOperator.js +0 -0
  53. package/data/api/enum/read/ReadSelectedOrderingDirection.d.ts +0 -0
  54. package/data/api/enum/read/ReadSelectedOrderingDirection.js +0 -0
  55. package/data/api/enum/read/ReadSelectedPropertyType.d.ts +0 -0
  56. package/data/api/enum/read/ReadSelectedPropertyType.js +0 -0
  57. package/data/api/enum/read/index.d.ts +0 -0
  58. package/data/api/enum/read/index.js +0 -0
  59. package/data/api/enum/response/ApiErrorCodes.d.ts +0 -0
  60. package/data/api/enum/response/ApiErrorCodes.js +0 -0
  61. package/data/api/enum/response/index.d.ts +0 -0
  62. package/data/api/enum/response/index.js +0 -0
  63. package/data/api/index.d.ts +0 -0
  64. package/data/api/index.js +0 -0
  65. package/data/api/interface/IConcurrencySafe.d.ts +9 -0
  66. package/data/api/interface/IConcurrencySafe.js +2 -0
  67. package/data/api/interface/IIdentifiable.d.ts +4 -3
  68. package/data/api/interface/IIdentifiable.js +0 -0
  69. package/data/api/interface/IIdentifiableSecondary.d.ts +3 -3
  70. package/data/api/interface/IIdentifiableSecondary.js +0 -0
  71. package/data/api/interface/index.d.ts +1 -0
  72. package/data/api/interface/index.js +1 -0
  73. package/data/auth/dto/ClaimDto.d.ts +0 -0
  74. package/data/auth/dto/ClaimDto.js +0 -0
  75. package/data/auth/dto/RegisterRequestDto.d.ts +0 -0
  76. package/data/auth/dto/RegisterRequestDto.js +0 -0
  77. package/data/auth/dto/RoleDto.d.ts +0 -0
  78. package/data/auth/dto/RoleDto.js +0 -0
  79. package/data/auth/dto/SignInRequestDto.d.ts +0 -0
  80. package/data/auth/dto/SignInRequestDto.js +0 -0
  81. package/data/auth/dto/TokensDto.d.ts +0 -0
  82. package/data/auth/dto/TokensDto.js +0 -0
  83. package/data/auth/dto/UserDto.d.ts +0 -0
  84. package/data/auth/dto/UserDto.js +0 -0
  85. package/data/auth/dto/UserInfoDto.d.ts +0 -0
  86. package/data/auth/dto/UserInfoDto.js +0 -0
  87. package/data/auth/dto/index.d.ts +0 -0
  88. package/data/auth/dto/index.js +0 -0
  89. package/data/auth/index.d.ts +0 -0
  90. package/data/auth/index.js +0 -0
  91. package/data/index.d.ts +0 -0
  92. package/data/index.js +0 -0
  93. package/index.d.ts +3 -0
  94. package/index.js +3 -0
  95. package/package.json +15 -10
  96. package/services/api/ApiCrudControllerClient/index.d.ts +9 -5
  97. package/services/api/ApiCrudControllerClient/index.js +15 -9
  98. package/services/api/ApiInitializationService/index.d.ts +21 -3
  99. package/services/api/ApiInitializationService/index.js +36 -7
  100. package/services/api/ApiReadControllerClient/index.d.ts +12 -13
  101. package/services/api/ApiReadControllerClient/index.js +17 -18
  102. package/services/api/HttpService/FetchHttpService.d.ts +1 -1
  103. package/services/api/HttpService/FetchHttpService.js +2 -1
  104. package/services/api/HttpService/HttpRequestConfig.d.ts +1 -0
  105. package/services/api/HttpService/HttpRequestConfig.js +0 -0
  106. package/services/api/HttpService/HttpResponse.d.ts +0 -0
  107. package/services/api/HttpService/HttpResponse.js +0 -0
  108. package/services/api/HttpService/IHttpService.d.ts +1 -1
  109. package/services/api/HttpService/IHttpService.js +0 -0
  110. package/services/api/HttpService/index.d.ts +0 -2
  111. package/services/api/HttpService/index.js +0 -2
  112. package/services/api/UserManagementControllerClient/index.d.ts +9 -5
  113. package/services/api/UserManagementControllerClient/index.js +20 -12
  114. package/services/api/index.d.ts +0 -0
  115. package/services/api/index.js +0 -0
  116. package/services/auth/client/AuthService/index.d.ts +5 -5
  117. package/services/auth/client/AuthService/index.js +9 -9
  118. package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +5 -5
  119. package/services/auth/client/AuthorizationManagementControllerClient/index.js +8 -8
  120. package/services/auth/client/index.d.ts +0 -0
  121. package/services/auth/client/index.js +0 -0
  122. package/services/auth/index.d.ts +0 -0
  123. package/services/auth/index.js +0 -0
  124. package/services/index.d.ts +0 -0
  125. package/services/index.js +0 -0
  126. package/utils/index.d.ts +37 -0
  127. package/utils/index.js +106 -0
  128. package/data/api/dto/response/EmptyMetadata.d.ts +0 -4
  129. package/services/api/HttpService/AngularHttpService.d.ts +0 -9
  130. package/services/api/HttpService/AngularHttpService.js +0 -86
  131. package/services/api/HttpService/AxiosHttpService.d.ts +0 -10
  132. 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 initialize({ httpService } = {}) {
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._getApiBaseUrl();
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 _getApiBaseUrl() {
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.request(window.location.href, { method: 'GET' });
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.request('./websettings.json', { method: 'GET' });
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 getApiUrl(...relativeEndpointPathSections) {
145
- const apiBaseUrl = await this._getApiBaseUrl();
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 { IIdentifiable, ApiSuccessResponse, ReadSelectedDefinitionDto, ReadMetadata, EmptyMetadata } from '../../../data';
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
- * Generic API client for consuming any Cornerstone ReadController
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
- * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} List of all entities with metadata
22
+ * @param {AbortSignal} [signal] - Optional cancellation signal
23
+ * @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
27
24
  */
28
- readAll(): Promise<ApiSuccessResponse<TDto[], ReadMetadata>>;
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
- * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} The result of the read operation with metadata
29
+ * @param {AbortSignal} [signal] - Optional cancellation signal
30
+ * @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} The result of the read operation with metadata
33
31
  */
34
- readSelected(definition: ReadSelectedDefinitionDto): Promise<ApiSuccessResponse<TDto[], ReadMetadata>>;
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
- * @returns {Promise<ApiSuccessResponse<TDto, EmptyMetadata>>} The requested entity
36
+ * @param {AbortSignal} [signal] - Optional cancellation signal
37
+ * @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
39
38
  */
40
- readSingle(id: TKey): Promise<ApiSuccessResponse<TDto, EmptyMetadata>>;
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
- * Generic API client for consuming any Cornerstone ReadController
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
- * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} List of all entities with metadata
28
+ * @param {AbortSignal} [signal] - Optional cancellation signal
29
+ * @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
34
30
  */
35
- async readAll() {
31
+ async readAllAsync(signal) {
36
32
  try {
37
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadAll`);
38
- const res = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
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
- * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} The result of the read operation with metadata
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 readSelected(definition) {
53
+ async readSelectedAsync(definition, signal) {
57
54
  try {
58
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSelected`);
59
- const res = await this.httpService.request(url, {
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
- * @returns {Promise<ApiSuccessResponse<TDto, EmptyMetadata>>} The requested entity
78
+ * @param {AbortSignal} [signal] - Optional cancellation signal
79
+ * @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
81
80
  */
82
- async readSingle(id) {
81
+ async readSingleAsync(id, signal) {
83
82
  try {
84
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSingle?id=${encodeURIComponent(String(id))}`);
85
- const res = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
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
- request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
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 request(url, config) {
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 = {};
@@ -6,4 +6,5 @@ export interface HttpRequestConfig {
6
6
  headers?: Record<string, string>;
7
7
  body?: string;
8
8
  credentials?: RequestCredentials;
9
+ signal?: AbortSignal;
9
10
  }
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
- request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
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, ReadMetadata, ApiSuccessResponse } from '../../../data';
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
- getUserRoles(id: TKey): Promise<ApiSuccessResponse<string[], ReadMetadata>>;
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
- getUserClaims(id: TKey): Promise<ApiSuccessResponse<ClaimDto[], ReadMetadata>>;
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
- getAllRoles(): Promise<ApiSuccessResponse<string[], ReadMetadata>>;
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
- changePassword(id: TKey, newPassword: string): Promise<void>;
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 getUserRoles(id) {
26
+ async getUserRolesAsync(id, signal) {
26
27
  try {
27
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetUserRoles', encodeURIComponent(String(id)));
28
- const res = await this.httpService.request(url, {
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 getUserClaims(id) {
52
+ async getUserClaimsAsync(id, signal) {
50
53
  try {
51
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetUserClaims', encodeURIComponent(String(id)));
52
- const res = await this.httpService.request(url, {
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 getAllRoles() {
77
+ async getAllRolesAsync(signal) {
73
78
  try {
74
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetAllRoles');
75
- const res = await this.httpService.request(url, {
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 changePassword(id, newPassword) {
104
+ async changePasswordAsync(id, newPassword, signal) {
98
105
  try {
99
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'ChangePassword', encodeURIComponent(String(id)));
100
- const response = await this.httpService.request(url, {
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;
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- import { ApiSuccessResponse, EmptyMetadata, UserDto, UserInfoDto } from '../../../../data';
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
- initialize(): Promise<void>;
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
- whoAmI(): Promise<ApiSuccessResponse<UserInfoDto<TKey, TUser> | undefined, EmptyMetadata>>;
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
- signin(username: string, password: string): Promise<ApiSuccessResponse<TUser, EmptyMetadata>>;
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
- signout(): Promise<void>;
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 initialize() {
20
+ async initializeAsync() {
21
21
  // Check user's authentication status
22
- await this.whoAmI();
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 whoAmI() {
30
+ async whoAmIAsync() {
31
31
  try {
32
- const url = await apiInitializationService.getApiUrl('/auth/whoami');
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 signin(username, password) {
61
+ async signinAsync(username, password) {
62
62
  try {
63
- const url = await apiInitializationService.getApiUrl('/auth/signin');
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.whoAmI();
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 signout() {
90
+ async signoutAsync() {
91
91
  try {
92
- const url = await apiInitializationService.getApiUrl('/auth/signout');
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 { ApiSuccessResponse, EmptyMetadata, ReadMetadata, RoleDto } from '../../../../data';
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
- getAllRoles(includeClaims: boolean): Promise<ApiSuccessResponse<RoleDto[], ReadMetadata>>;
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
- getRoleWithClaims(roleName: string): Promise<ApiSuccessResponse<RoleDto, ReadMetadata>>;
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
- upsertRole(roleDto: RoleDto): Promise<ApiSuccessResponse<RoleDto, EmptyMetadata>>;
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
- deleteRole(roleName: string): Promise<void>;
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 getAllRoles(includeClaims) {
22
+ async getAllRolesAsync(includeClaims) {
23
23
  try {
24
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/GetAllRoles?includeClaims=${includeClaims}`);
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 getRoleWithClaims(roleName) {
45
+ async getRoleWithClaimsAsync(roleName) {
46
46
  try {
47
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/GetRoleWithClaims/${encodeURIComponent(roleName)}`);
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 upsertRole(roleDto) {
68
+ async upsertRoleAsync(roleDto) {
69
69
  try {
70
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/UpsertRole`);
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 deleteRole(roleName) {
96
+ async deleteRoleAsync(roleName) {
97
97
  try {
98
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/DeleteRole/${encodeURIComponent(roleName)}`);
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
File without changes
File without changes
File without changes
package/services/index.js CHANGED
File without changes