@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.
Files changed (70) 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/ReadOptionsDto.d.ts +8 -0
  9. package/data/api/dto/ReadResultDto.d.ts +12 -0
  10. package/data/api/dto/ReadResultMetadataDto.d.ts +8 -0
  11. package/data/api/dto/crud/{CrudMetadata.d.ts → CrudMetadataDto.d.ts} +1 -1
  12. package/data/api/dto/crud/index.d.ts +1 -1
  13. package/data/api/dto/crud/index.js +1 -1
  14. package/data/api/dto/index.d.ts +1 -0
  15. package/data/api/dto/index.js +1 -0
  16. package/data/api/dto/read/{ReadMetadata.d.ts → ReadMetadataDto.d.ts} +1 -1
  17. package/data/api/dto/read/ReadSelectedOrderingPropertyDefinitionDto.d.ts +2 -2
  18. package/data/api/dto/read/ReadSelectedSearchPropertyDefinitionDto.d.ts +2 -2
  19. package/data/api/dto/read/index.d.ts +1 -1
  20. package/data/api/dto/read/index.js +1 -1
  21. package/data/api/dto/response/{ApiError.d.ts → ApiErrorDto.d.ts} +1 -1
  22. package/data/api/dto/response/ApiErrorDto.js +1 -0
  23. package/data/api/dto/response/{ApiResponse.d.ts → ApiResponseDto.d.ts} +3 -3
  24. package/data/api/dto/response/ApiResponseDto.js +1 -0
  25. package/data/api/dto/response/{ApiSuccessResponse.d.ts → ApiSuccessResponseDto.d.ts} +1 -1
  26. package/data/api/dto/response/ApiSuccessResponseDto.js +1 -0
  27. package/data/api/dto/response/EmptyMetadataDto.d.ts +4 -0
  28. package/data/api/dto/response/EmptyMetadataDto.js +1 -0
  29. package/data/api/dto/response/index.d.ts +4 -4
  30. package/data/api/dto/response/index.js +4 -4
  31. package/data/api/interface/IConcurrencySafe.d.ts +9 -0
  32. package/data/api/interface/IConcurrencySafe.js +2 -0
  33. package/data/api/interface/IIdentifiable.d.ts +4 -3
  34. package/data/api/interface/IIdentifiableSecondary.d.ts +3 -3
  35. package/data/api/interface/index.d.ts +1 -0
  36. package/data/api/interface/index.js +1 -0
  37. package/index.d.ts +3 -0
  38. package/index.js +3 -0
  39. package/package.json +15 -10
  40. package/services/api/ApiCrudControllerClient/index.d.ts +9 -5
  41. package/services/api/ApiCrudControllerClient/index.js +15 -9
  42. package/services/api/ApiInitializationService/index.d.ts +21 -3
  43. package/services/api/ApiInitializationService/index.js +36 -7
  44. package/services/api/ApiReadControllerClient/index.d.ts +12 -13
  45. package/services/api/ApiReadControllerClient/index.js +17 -18
  46. package/services/api/HttpService/FetchHttpService.d.ts +1 -1
  47. package/services/api/HttpService/FetchHttpService.js +2 -1
  48. package/services/api/HttpService/HttpRequestConfig.d.ts +1 -0
  49. package/services/api/HttpService/IHttpService.d.ts +1 -1
  50. package/services/api/HttpService/index.d.ts +0 -2
  51. package/services/api/HttpService/index.js +0 -2
  52. package/services/api/UserManagementControllerClient/index.d.ts +9 -5
  53. package/services/api/UserManagementControllerClient/index.js +20 -12
  54. package/services/auth/client/AuthService/index.d.ts +5 -5
  55. package/services/auth/client/AuthService/index.js +9 -9
  56. package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +5 -5
  57. package/services/auth/client/AuthorizationManagementControllerClient/index.js +8 -8
  58. package/utils/index.d.ts +37 -0
  59. package/utils/index.js +106 -0
  60. package/data/api/dto/response/EmptyMetadata.d.ts +0 -4
  61. package/services/api/HttpService/AngularHttpService.d.ts +0 -9
  62. package/services/api/HttpService/AngularHttpService.js +0 -86
  63. package/services/api/HttpService/AxiosHttpService.d.ts +0 -10
  64. package/services/api/HttpService/AxiosHttpService.js +0 -53
  65. /package/data/api/dto/{crud/CrudMetadata.js → PropertyPathDto.js} +0 -0
  66. /package/data/api/dto/{read/ReadMetadata.js → ReadOptionsDto.js} +0 -0
  67. /package/data/api/dto/{response/ApiError.js → ReadResultDto.js} +0 -0
  68. /package/data/api/dto/{response/ApiResponse.js → ReadResultMetadataDto.js} +0 -0
  69. /package/data/api/dto/{response/ApiSuccessResponse.js → crud/CrudMetadataDto.js} +0 -0
  70. /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
- * 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
  }
@@ -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
  }
@@ -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;
@@ -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',
@@ -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,4 +0,0 @@
1
- /**
2
- * Default, empty metadata.
3
- */
4
- export type EmptyMetadata = object;
@@ -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
- }