@intellegens/cornerstone-client 0.0.34 → 0.0.36

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 (71) hide show
  1. package/data/api/dto/crud/CrudMetadata.d.ts +4 -0
  2. package/data/api/dto/crud/index.d.ts +1 -0
  3. package/data/api/dto/crud/index.js +1 -0
  4. package/data/api/dto/index.d.ts +3 -9
  5. package/data/api/dto/index.js +3 -9
  6. package/data/api/dto/read/ReadMetadata.d.ts +8 -0
  7. package/data/api/dto/{ReadSelectedDefinitionDto.d.ts → read/ReadSelectedDefinitionDto.d.ts} +1 -1
  8. package/data/api/dto/{ReadSelectedOrderingDefinitionDto.d.ts → read/ReadSelectedOrderingDefinitionDto.d.ts} +1 -1
  9. package/data/api/dto/{ReadSelectedOrderingPropertyDefinitionDto.d.ts → read/ReadSelectedOrderingPropertyDefinitionDto.d.ts} +1 -1
  10. package/data/api/dto/read/ReadSelectedSearchDefinitionDto.d.ts +18 -0
  11. package/data/api/dto/{ReadSelectedSearchPropertyDefinitionDto.d.ts → read/ReadSelectedSearchPropertyDefinitionDto.d.ts} +2 -2
  12. package/data/api/dto/read/index.d.ts +7 -0
  13. package/data/api/dto/read/index.js +7 -0
  14. package/data/api/dto/response/ApiError.d.ts +8 -0
  15. package/data/api/dto/response/ApiResponse.d.ts +15 -0
  16. package/data/api/dto/response/ApiSuccessResponse.d.ts +12 -0
  17. package/data/api/dto/response/EmptyMetadata.d.ts +4 -0
  18. package/data/api/dto/response/EmptyMetadata.js +1 -0
  19. package/data/api/dto/response/index.d.ts +4 -0
  20. package/data/api/dto/response/index.js +4 -0
  21. package/data/api/enum/index.d.ts +2 -4
  22. package/data/api/enum/index.js +2 -4
  23. package/data/api/enum/{ReadSelectedComparisonOperator.d.ts → read/ReadSelectedComparisonOperator.d.ts} +21 -1
  24. package/data/api/enum/{ReadSelectedComparisonOperator.js → read/ReadSelectedComparisonOperator.js} +20 -0
  25. package/data/api/enum/read/index.d.ts +4 -0
  26. package/data/api/enum/read/index.js +4 -0
  27. package/data/api/enum/response/ApiErrorCodes.d.ts +7 -0
  28. package/data/api/enum/response/ApiErrorCodes.js +8 -0
  29. package/data/api/enum/response/index.d.ts +1 -0
  30. package/data/api/enum/response/index.js +1 -0
  31. package/data/api/index.d.ts +1 -1
  32. package/data/api/index.js +1 -1
  33. package/data/api/interface/IIdentifiableSecondary.d.ts +9 -0
  34. package/data/api/interface/IIdentifiableSecondary.js +1 -0
  35. package/data/api/interface/index.d.ts +1 -2
  36. package/data/api/interface/index.js +1 -2
  37. package/package.json +1 -1
  38. package/services/api/ApiCrudControllerClient/index.d.ts +3 -3
  39. package/services/api/ApiCrudControllerClient/index.js +18 -9
  40. package/services/api/ApiReadControllerClient/index.d.ts +12 -22
  41. package/services/api/ApiReadControllerClient/index.js +42 -47
  42. package/services/api/UserManagementControllerClient/index.d.ts +4 -4
  43. package/services/api/UserManagementControllerClient/index.js +27 -16
  44. package/services/auth/client/AuthService/index.d.ts +4 -4
  45. package/services/auth/client/AuthService/index.js +35 -37
  46. package/services/auth/client/AuthorizationManagementControllerClient/index.d.ts +9 -9
  47. package/services/auth/client/AuthorizationManagementControllerClient/index.js +42 -33
  48. package/data/api/dto/ReadOptions.d.ts +0 -8
  49. package/data/api/dto/ReadResult.d.ts +0 -12
  50. package/data/api/dto/ReadResultMetadata.d.ts +0 -8
  51. package/data/api/dto/ReadSelectedSearchDefinitionDto.d.ts +0 -18
  52. package/data/api/interface/IIdentifiableByGuid.d.ts +0 -9
  53. package/data/api/interface/IOptionallyIdentifiable.d.ts +0 -11
  54. /package/data/api/dto/{ReadOptions.js → crud/CrudMetadata.js} +0 -0
  55. /package/data/api/dto/{ReadResult.js → read/ReadMetadata.js} +0 -0
  56. /package/data/api/dto/{ReadSelectedDefinitionDto.js → read/ReadSelectedDefinitionDto.js} +0 -0
  57. /package/data/api/dto/{ReadSelectedOrderingDefinitionDto.js → read/ReadSelectedOrderingDefinitionDto.js} +0 -0
  58. /package/data/api/dto/{ReadSelectedOrderingPropertyDefinitionDto.js → read/ReadSelectedOrderingPropertyDefinitionDto.js} +0 -0
  59. /package/data/api/dto/{ReadSelectedPaginationDefinitionDto.d.ts → read/ReadSelectedPaginationDefinitionDto.d.ts} +0 -0
  60. /package/data/api/dto/{ReadSelectedPaginationDefinitionDto.js → read/ReadSelectedPaginationDefinitionDto.js} +0 -0
  61. /package/data/api/dto/{ReadSelectedSearchDefinitionDto.js → read/ReadSelectedSearchDefinitionDto.js} +0 -0
  62. /package/data/api/dto/{ReadSelectedSearchPropertyDefinitionDto.js → read/ReadSelectedSearchPropertyDefinitionDto.js} +0 -0
  63. /package/data/api/dto/{ReadResultMetadata.js → response/ApiError.js} +0 -0
  64. /package/data/api/{interface/IIdentifiableByGuid.js → dto/response/ApiResponse.js} +0 -0
  65. /package/data/api/{interface/IOptionallyIdentifiable.js → dto/response/ApiSuccessResponse.js} +0 -0
  66. /package/data/api/enum/{ReadSelectedLogicalOperator.d.ts → read/ReadSelectedLogicalOperator.d.ts} +0 -0
  67. /package/data/api/enum/{ReadSelectedLogicalOperator.js → read/ReadSelectedLogicalOperator.js} +0 -0
  68. /package/data/api/enum/{ReadSelectedOrderingDirection.d.ts → read/ReadSelectedOrderingDirection.d.ts} +0 -0
  69. /package/data/api/enum/{ReadSelectedOrderingDirection.js → read/ReadSelectedOrderingDirection.js} +0 -0
  70. /package/data/api/enum/{ReadSelectedPropertyType.d.ts → read/ReadSelectedPropertyType.d.ts} +0 -0
  71. /package/data/api/enum/{ReadSelectedPropertyType.js → read/ReadSelectedPropertyType.js} +0 -0
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Metadata associated with a crud result.
3
+ */
4
+ export type CrudMetadata = object;
@@ -0,0 +1 @@
1
+ export * from './CrudMetadata';
@@ -0,0 +1 @@
1
+ export * from './CrudMetadata';
@@ -1,9 +1,3 @@
1
- export * from './ReadSelectedDefinitionDto';
2
- export * from './ReadSelectedSearchDefinitionDto';
3
- export * from './ReadSelectedSearchPropertyDefinitionDto';
4
- export * from './ReadSelectedOrderingDefinitionDto';
5
- export * from './ReadSelectedOrderingPropertyDefinitionDto';
6
- export * from './ReadSelectedPaginationDefinitionDto';
7
- export * from './ReadOptions';
8
- export * from './ReadResult';
9
- export * from './ReadResultMetadata';
1
+ export * from './response';
2
+ export * from './read';
3
+ export * from './crud';
@@ -1,9 +1,3 @@
1
- export * from './ReadSelectedDefinitionDto';
2
- export * from './ReadSelectedSearchDefinitionDto';
3
- export * from './ReadSelectedSearchPropertyDefinitionDto';
4
- export * from './ReadSelectedOrderingDefinitionDto';
5
- export * from './ReadSelectedOrderingPropertyDefinitionDto';
6
- export * from './ReadSelectedPaginationDefinitionDto';
7
- export * from './ReadOptions';
8
- export * from './ReadResult';
9
- export * from './ReadResultMetadata';
1
+ export * from './response';
2
+ export * from './read';
3
+ export * from './crud';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Metadata associated with a read result.
3
+ *
4
+ * @property {number} [totalCount] - The total number of items available.
5
+ */
6
+ export type ReadMetadata = {
7
+ totalCount?: number;
8
+ };
@@ -1,4 +1,4 @@
1
- import { ReadSelectedPaginationDefinitionDto, ReadSelectedOrderingDefinitionDto, ReadSelectedSearchDefinitionDto } from '../..';
1
+ import { ReadSelectedPaginationDefinitionDto, ReadSelectedOrderingDefinitionDto, ReadSelectedSearchDefinitionDto } from '../../..';
2
2
  /**
3
3
  * Defines the selection criteria for a controller to fetch multiple records
4
4
  */
@@ -1,4 +1,4 @@
1
- import { ReadSelectedOrderingPropertyDefinitionDto } from '../..';
1
+ import { ReadSelectedOrderingPropertyDefinitionDto } from '../../..';
2
2
  /**
3
3
  * Represents the ordering definition for a controller.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { ReadSelectedOrderingDirection } from '../..';
1
+ import { ReadSelectedOrderingDirection } from '../../..';
2
2
  /**
3
3
  * Defines the ordering property for a controller.
4
4
  */
@@ -0,0 +1,18 @@
1
+ import { ReadSelectedLogicalOperator, ReadSelectedSearchPropertyDefinitionDto } from '../../..';
2
+ /**
3
+ * Defines the filtering options for a controller, including the logical operator and an array of property definitions.
4
+ */
5
+ export type ReadSelectedSearchDefinitionDto = {
6
+ /**
7
+ * Logical operator to be used when applying the filters.
8
+ */
9
+ logicalOperator: ReadSelectedLogicalOperator;
10
+ /**
11
+ * Property-based search criteria.
12
+ */
13
+ propertyCriteria?: ReadSelectedSearchPropertyDefinitionDto[];
14
+ /**
15
+ * Nested search definitions for complex queries.
16
+ */
17
+ nestedSearchCriteria?: ReadSelectedSearchPropertyDefinitionDto[];
18
+ };
@@ -1,4 +1,4 @@
1
- import { ReadSelectedComparisonOperator, ReadSelectedPropertyType } from '../..';
1
+ import { ReadSelectedComparisonOperator, ReadSelectedPropertyType } from '../../..';
2
2
  /**
3
3
  * Defines a property used for searching in a controller.
4
4
  */
@@ -93,7 +93,7 @@ type Partial_ReadSelectedSearchPropertyDefinition_TypedComparisonOperators = {
93
93
  /**
94
94
  * The comparison operator to use for the search.
95
95
  */
96
- comparisonOperator: ReadSelectedComparisonOperator.Equal | ReadSelectedComparisonOperator.NotEqual | ReadSelectedComparisonOperator.Contains | ReadSelectedComparisonOperator.StartsWith | ReadSelectedComparisonOperator.EndsWith;
96
+ comparisonOperator: ReadSelectedComparisonOperator.Equal | ReadSelectedComparisonOperator.NotEqual | ReadSelectedComparisonOperator.Contains | ReadSelectedComparisonOperator.StartsWith | ReadSelectedComparisonOperator.EndsWith | ReadSelectedComparisonOperator.IContains | ReadSelectedComparisonOperator.IStartsWith | ReadSelectedComparisonOperator.IEndsWith | ReadSelectedComparisonOperator.IEqual | ReadSelectedComparisonOperator.INotEqual;
97
97
  } | {
98
98
  /**
99
99
  * The type of the property value being searched.
@@ -0,0 +1,7 @@
1
+ export * from './ReadMetadata';
2
+ export * from './ReadSelectedSearchPropertyDefinitionDto';
3
+ export * from './ReadSelectedOrderingDefinitionDto';
4
+ export * from './ReadSelectedOrderingPropertyDefinitionDto';
5
+ export * from './ReadSelectedPaginationDefinitionDto';
6
+ export * from './ReadSelectedDefinitionDto';
7
+ export * from './ReadSelectedSearchDefinitionDto';
@@ -0,0 +1,7 @@
1
+ export * from './ReadMetadata';
2
+ export * from './ReadSelectedSearchPropertyDefinitionDto';
3
+ export * from './ReadSelectedOrderingDefinitionDto';
4
+ export * from './ReadSelectedOrderingPropertyDefinitionDto';
5
+ export * from './ReadSelectedPaginationDefinitionDto';
6
+ export * from './ReadSelectedDefinitionDto';
7
+ export * from './ReadSelectedSearchDefinitionDto';
@@ -0,0 +1,8 @@
1
+ import { ApiErrorCodes } from '../../..';
2
+ /**
3
+ * Default, empty metadata.
4
+ */
5
+ export type ApiError = {
6
+ code: ApiErrorCodes;
7
+ message: string;
8
+ };
@@ -0,0 +1,15 @@
1
+ import { ApiError } from '../../..';
2
+ /**
3
+ * Represents an API response containing a result and metadata, or an error.
4
+ *
5
+ * @template T The type of result
6
+ * @template TMetadata The type of metadata
7
+ * @property {T} result - The result returned
8
+ * @property {TMetadata} metadata - Metadata about the result
9
+ */
10
+ export type ApiResponse<T, TMetadata> = {
11
+ success: boolean;
12
+ result: T;
13
+ metadata: TMetadata;
14
+ error: ApiError;
15
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Represents an successful API response containing a result and metadata.
3
+ *
4
+ * @template T The type of result
5
+ * @template TMetadata The type of metadata
6
+ * @property {T} result - The result returned
7
+ * @property {TMetadata} metadata - Metadata about the result
8
+ */
9
+ export type ApiSuccessResponse<T, TMetadata> = {
10
+ result: T;
11
+ metadata: TMetadata;
12
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Default, empty metadata.
3
+ */
4
+ export type EmptyMetadata = object;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './ApiResponse';
2
+ export * from './ApiSuccessResponse';
3
+ export * from './ApiError';
4
+ export * from './EmptyMetadata';
@@ -0,0 +1,4 @@
1
+ export * from './ApiResponse';
2
+ export * from './ApiSuccessResponse';
3
+ export * from './ApiError';
4
+ export * from './EmptyMetadata';
@@ -1,4 +1,2 @@
1
- export * from './ReadSelectedComparisonOperator';
2
- export * from './ReadSelectedLogicalOperator';
3
- export * from './ReadSelectedOrderingDirection';
4
- export * from './ReadSelectedPropertyType';
1
+ export * from './response';
2
+ export * from './read';
@@ -1,4 +1,2 @@
1
- export * from './ReadSelectedComparisonOperator';
2
- export * from './ReadSelectedLogicalOperator';
3
- export * from './ReadSelectedOrderingDirection';
4
- export * from './ReadSelectedPropertyType';
1
+ export * from './response';
2
+ export * from './read';
@@ -45,5 +45,25 @@ export declare enum ReadSelectedComparisonOperator {
45
45
  /**
46
46
  * Represents the ends with comparison operator.
47
47
  */
48
- EndsWith = 202
48
+ EndsWith = 202,
49
+ /**
50
+ * Represents the contains comparison operator (case-insensitive).
51
+ */
52
+ IContains = 203,
53
+ /**
54
+ * Represents the starts with comparison operator (case-insensitive).
55
+ */
56
+ IStartsWith = 204,
57
+ /**
58
+ * Represents the ends with comparison operator (case-insensitive).
59
+ */
60
+ IEndsWith = 205,
61
+ /**
62
+ * Represents the equal comparison operator (case-insensitive).
63
+ */
64
+ IEqual = 206,
65
+ /**
66
+ * Represents the not equal comparison operator (case-insensitive).
67
+ */
68
+ INotEqual = 207
49
69
  }
@@ -52,5 +52,25 @@ export var ReadSelectedComparisonOperator;
52
52
  * Represents the ends with comparison operator.
53
53
  */
54
54
  ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["EndsWith"] = 202] = "EndsWith";
55
+ /**
56
+ * Represents the contains comparison operator (case-insensitive).
57
+ */
58
+ ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["IContains"] = 203] = "IContains";
59
+ /**
60
+ * Represents the starts with comparison operator (case-insensitive).
61
+ */
62
+ ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["IStartsWith"] = 204] = "IStartsWith";
63
+ /**
64
+ * Represents the ends with comparison operator (case-insensitive).
65
+ */
66
+ ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["IEndsWith"] = 205] = "IEndsWith";
67
+ /**
68
+ * Represents the equal comparison operator (case-insensitive).
69
+ */
70
+ ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["IEqual"] = 206] = "IEqual";
71
+ /**
72
+ * Represents the not equal comparison operator (case-insensitive).
73
+ */
74
+ ReadSelectedComparisonOperator[ReadSelectedComparisonOperator["INotEqual"] = 207] = "INotEqual";
55
75
  //#endregion
56
76
  })(ReadSelectedComparisonOperator || (ReadSelectedComparisonOperator = {}));
@@ -0,0 +1,4 @@
1
+ export * from './ReadSelectedComparisonOperator';
2
+ export * from './ReadSelectedLogicalOperator';
3
+ export * from './ReadSelectedOrderingDirection';
4
+ export * from './ReadSelectedPropertyType';
@@ -0,0 +1,4 @@
1
+ export * from './ReadSelectedComparisonOperator';
2
+ export * from './ReadSelectedLogicalOperator';
3
+ export * from './ReadSelectedOrderingDirection';
4
+ export * from './ReadSelectedPropertyType';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Represents available error codes to be returned as part of the ApiResponse object
3
+ */
4
+ export declare enum ApiErrorCodes {
5
+ NotFound = 404,
6
+ BadRequest = 400
7
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Represents available error codes to be returned as part of the ApiResponse object
3
+ */
4
+ export var ApiErrorCodes;
5
+ (function (ApiErrorCodes) {
6
+ ApiErrorCodes[ApiErrorCodes["NotFound"] = 404] = "NotFound";
7
+ ApiErrorCodes[ApiErrorCodes["BadRequest"] = 400] = "BadRequest";
8
+ })(ApiErrorCodes || (ApiErrorCodes = {}));
@@ -0,0 +1 @@
1
+ export * from './ApiErrorCodes';
@@ -0,0 +1 @@
1
+ export * from './ApiErrorCodes';
@@ -1,3 +1,3 @@
1
- export * from './enum';
2
1
  export * from './interface';
3
2
  export * from './dto';
3
+ export * from './enum';
package/data/api/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './enum';
2
1
  export * from './interface';
3
2
  export * from './dto';
3
+ export * from './enum';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type for entities that have a secondary Id property.
3
+ */
4
+ export type IIdentifiableSecondary<TKey> = {
5
+ /**
6
+ * Gets or sets the secondary Id of the entity.
7
+ */
8
+ idSecondary: TKey;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,2 @@
1
1
  export * from './IIdentifiable';
2
- export * from './IOptionallyIdentifiable';
3
- export * from './IIdentifiableByGuid';
2
+ export * from './IIdentifiableSecondary';
@@ -1,3 +1,2 @@
1
1
  export * from './IIdentifiable';
2
- export * from './IOptionallyIdentifiable';
3
- export * from './IIdentifiableByGuid';
2
+ export * from './IIdentifiableSecondary';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intellegens/cornerstone-client",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { ApiReadControllerClient } from '../ApiReadControllerClient';
2
- import { IIdentifiable, ReadResult } from '../../../data';
2
+ import { IIdentifiable, ApiSuccessResponse, EmptyMetadata } from '../../../data';
3
3
  import { IHttpService } from '../HttpService';
4
4
  /**
5
5
  * Generic API client for consuming any Cornerstone CrudController
@@ -21,14 +21,14 @@ export declare class ApiCrudControllerClient<TKey, TDto extends IIdentifiable<TK
21
21
  * @param dto - Insert request DTO
22
22
  * @returns The created entity DTO
23
23
  */
24
- create(dto: TDto): Promise<ReadResult<TDto>>;
24
+ create(dto: TDto): Promise<ApiSuccessResponse<TDto, EmptyMetadata>>;
25
25
  /**
26
26
  * Updates an existing entity.
27
27
  * @param id - The ID of the entity to update
28
28
  * @param dto - Update request DTO
29
29
  * @returns The updated entity DTO
30
30
  */
31
- update(id: TKey, dto: TDto): Promise<ReadResult<TDto>>;
31
+ update(id: TKey, dto: TDto): Promise<ApiSuccessResponse<TDto, EmptyMetadata>>;
32
32
  /**
33
33
  * Deletes an entity by ID.
34
34
  * @param id - The ID of the entity to delete
@@ -25,17 +25,21 @@ export class ApiCrudControllerClient extends ApiReadControllerClient {
25
25
  async create(dto) {
26
26
  try {
27
27
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/Create`);
28
- const response = await this.httpService.request(url, {
28
+ const res = await this.httpService.request(url, {
29
29
  method: 'POST',
30
30
  headers: { 'Content-Type': 'application/json' },
31
31
  body: JSON.stringify(dto),
32
32
  credentials: 'include',
33
33
  });
34
- if (!response.ok)
35
- throw new Error('Failed to create record');
36
- return response.json();
34
+ if (!res.ok)
35
+ throw undefined;
36
+ const { success, result, metadata, error } = (await res.json());
37
+ if (!success)
38
+ throw new Error(error.message);
39
+ return { result, metadata };
37
40
  }
38
41
  catch (err) {
42
+ // TODO: Extract error from well-formed response
39
43
  throw err instanceof Error ? err : new Error('Unknown error creating record');
40
44
  }
41
45
  }
@@ -48,17 +52,21 @@ export class ApiCrudControllerClient extends ApiReadControllerClient {
48
52
  async update(id, dto) {
49
53
  try {
50
54
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/Update?id=${encodeURIComponent(String(id))}`);
51
- const response = await this.httpService.request(url, {
55
+ const res = await this.httpService.request(url, {
52
56
  method: 'PUT',
53
57
  headers: { 'Content-Type': 'application/json' },
54
58
  body: JSON.stringify(dto),
55
59
  credentials: 'include',
56
60
  });
57
- if (!response.ok)
58
- throw new Error('Failed to update record');
59
- return response.json();
61
+ if (!res.ok)
62
+ throw undefined;
63
+ const { success, result, metadata, error } = (await res.json());
64
+ if (!success)
65
+ throw new Error(error.message);
66
+ return { result, metadata };
60
67
  }
61
68
  catch (err) {
69
+ // TODO: Extract error from well-formed response
62
70
  throw err instanceof Error ? err : new Error('Unknown error updating record');
63
71
  }
64
72
  }
@@ -74,9 +82,10 @@ export class ApiCrudControllerClient extends ApiReadControllerClient {
74
82
  credentials: 'include',
75
83
  });
76
84
  if (!response.ok)
77
- throw new Error('Failed to delete record');
85
+ throw undefined;
78
86
  }
79
87
  catch (err) {
88
+ // TODO: Extract error from well-formed response
80
89
  throw err instanceof Error ? err : new Error('Unknown error deleting record');
81
90
  }
82
91
  }
@@ -1,4 +1,4 @@
1
- import { IIdentifiable, ReadResult, ReadSelectedDefinitionDto, ReadOptions } from '../../../data';
1
+ import { IIdentifiable, ApiSuccessResponse, ReadSelectedDefinitionDto, ReadMetadata, EmptyMetadata } from '../../../data';
2
2
  import { IHttpService } from '../HttpService';
3
3
  /**
4
4
  * Generic API client for consuming any Cornerstone ReadController
@@ -17,35 +17,25 @@ export declare class ApiReadControllerClient<TKey, TDto extends IIdentifiable<TK
17
17
  */
18
18
  constructor(baseControllerPath: string, httpService?: IHttpService);
19
19
  private _httpService?;
20
- /**
21
- * Generates a query string from the provided options.
22
- *
23
- * @param {ReadOptions} options - An object containing query option parameters.
24
- * @param {boolean} options.includeTotalCount - Whether to include the total count of items in the response.
25
- * @return {string} A query string constructed from the provided options. Returns an empty string if no parameters are provided.
26
- */
27
- protected generateQueryParams(options?: ReadOptions): string;
28
20
  /**
29
21
  * Gets globally selected HTTP service
30
22
  */
31
23
  protected get httpService(): IHttpService;
32
24
  /**
33
- * Fetches selected entities based on a search definition.
34
- * @param {any} definition - The search definition object
35
- * @param options - Optional read options
36
- * @returns {Promise<ReadResult<TDto>>} The result of the read operation with metadata
25
+ * Fetches all entities from the read controller.
26
+ * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} List of all entities with metadata
37
27
  */
38
- readSelected(definition: ReadSelectedDefinitionDto, options?: ReadOptions): Promise<ReadResult<TDto>>;
28
+ readAll(): Promise<ApiSuccessResponse<TDto[], ReadMetadata>>;
39
29
  /**
40
- * Fetches a single entity by its ID.
41
- * @param {TKey} id - The ID of the entity
42
- * @returns {Promise<TDto | undefined>} The requested entity
30
+ * Fetches selected entities based on a filter definition.
31
+ * @param {any} definition - The filter definition object
32
+ * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} The result of the read operation with metadata
43
33
  */
44
- readSingle(id: TKey): Promise<ReadResult<TDto>>;
34
+ readSelected(definition: ReadSelectedDefinitionDto): Promise<ApiSuccessResponse<TDto[], ReadMetadata>>;
45
35
  /**
46
- * Fetches all entities from the read controller.
47
- * @param {ReadOptions} options - Optional read options
48
- * @returns {Promise<ReadResult<TDto>>} List of all entities with metadata
36
+ * Fetches a single entity by its ID.
37
+ * @param {TKey} id - The ID of the entity
38
+ * @returns {Promise<ApiSuccessResponse<TDto, EmptyMetadata>>} The requested entity
49
39
  */
50
- readAll(options?: ReadOptions): Promise<ReadResult<TDto>>;
40
+ readSingle(id: TKey): Promise<ApiSuccessResponse<TDto, EmptyMetadata>>;
51
41
  }
@@ -20,21 +20,6 @@ export class ApiReadControllerClient {
20
20
  }
21
21
  // #region HTTP service
22
22
  _httpService = undefined;
23
- /**
24
- * Generates a query string from the provided options.
25
- *
26
- * @param {ReadOptions} options - An object containing query option parameters.
27
- * @param {boolean} options.includeTotalCount - Whether to include the total count of items in the response.
28
- * @return {string} A query string constructed from the provided options. Returns an empty string if no parameters are provided.
29
- */
30
- generateQueryParams(options) {
31
- if (!options)
32
- return '';
33
- const queryParams = [];
34
- if (options.includeTotalCount)
35
- queryParams.push(`includeTotalCount=${options.includeTotalCount}`);
36
- return queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
37
- }
38
23
  /**
39
24
  * Gets globally selected HTTP service
40
25
  */
@@ -44,60 +29,70 @@ export class ApiReadControllerClient {
44
29
  // #endregion
45
30
  // #region API
46
31
  /**
47
- * Fetches selected entities based on a search definition.
48
- * @param {any} definition - The search definition object
49
- * @param options - Optional read options
50
- * @returns {Promise<ReadResult<TDto>>} The result of the read operation with metadata
32
+ * Fetches all entities from the read controller.
33
+ * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} List of all entities with metadata
51
34
  */
52
- async readSelected(definition, options) {
35
+ async readAll() {
53
36
  try {
54
- const url = (await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSelected`)) + this.generateQueryParams(options);
55
- const response = await this.httpService.request(url, {
37
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadAll`);
38
+ const res = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
39
+ if (!res.ok)
40
+ throw undefined;
41
+ const { success, result, metadata, error } = (await res.json());
42
+ if (!success)
43
+ throw new Error(error.message);
44
+ return { result, metadata };
45
+ }
46
+ catch (err) {
47
+ // TODO: Extract error from well-formed response
48
+ throw err instanceof Error ? err : new Error('Unknown error fetching all records');
49
+ }
50
+ }
51
+ /**
52
+ * Fetches selected entities based on a filter definition.
53
+ * @param {any} definition - The filter definition object
54
+ * @returns {Promise<ApiSuccessResponse<TDto[], ReadMetadata>>} The result of the read operation with metadata
55
+ */
56
+ async readSelected(definition) {
57
+ try {
58
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSelected`);
59
+ const res = await this.httpService.request(url, {
56
60
  method: 'POST',
57
61
  headers: { 'Content-Type': 'application/json' },
58
62
  body: JSON.stringify(definition),
59
63
  credentials: 'include',
60
64
  });
61
- if (!response.ok)
62
- throw new Error('Failed to fetch selected records');
63
- return response.json();
65
+ if (!res.ok)
66
+ throw undefined;
67
+ const { success, result, metadata, error } = (await res.json());
68
+ if (!success)
69
+ throw new Error(error.message);
70
+ return { result, metadata };
64
71
  }
65
72
  catch (err) {
73
+ // TODO: Extract error from well-formed response
66
74
  throw err instanceof Error ? err : new Error('Unknown error fetching selected records');
67
75
  }
68
76
  }
69
77
  /**
70
78
  * Fetches a single entity by its ID.
71
79
  * @param {TKey} id - The ID of the entity
72
- * @returns {Promise<TDto | undefined>} The requested entity
80
+ * @returns {Promise<ApiSuccessResponse<TDto, EmptyMetadata>>} The requested entity
73
81
  */
74
82
  async readSingle(id) {
75
83
  try {
76
84
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSingle?id=${encodeURIComponent(String(id))}`);
77
- const response = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
78
- if (!response.ok)
79
- throw new Error('Failed to fetch single record');
80
- return response.json();
85
+ const res = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
86
+ if (!res.ok)
87
+ throw undefined;
88
+ const { success, result, metadata, error } = (await res.json());
89
+ if (!success)
90
+ throw new Error(error.message);
91
+ return { result, metadata };
81
92
  }
82
93
  catch (err) {
94
+ // TODO: Extract error from well-formed response
83
95
  throw err instanceof Error ? err : new Error('Unknown error fetching single record');
84
96
  }
85
97
  }
86
- /**
87
- * Fetches all entities from the read controller.
88
- * @param {ReadOptions} options - Optional read options
89
- * @returns {Promise<ReadResult<TDto>>} List of all entities with metadata
90
- */
91
- async readAll(options) {
92
- try {
93
- const url = (await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadAll`)) + this.generateQueryParams(options);
94
- const response = await this.httpService.request(url, { method: 'GET', credentials: 'include' });
95
- if (!response.ok)
96
- throw new Error('Failed to fetch all records');
97
- return response.json();
98
- }
99
- catch (err) {
100
- throw err instanceof Error ? err : new Error('Unknown error fetching all records');
101
- }
102
- }
103
98
  }
@@ -1,6 +1,6 @@
1
1
  import { ApiCrudControllerClient } from '../ApiCrudControllerClient';
2
2
  import { IHttpService } from '../HttpService';
3
- import { ReadResult, UserDto, ClaimDto } from '../../../data';
3
+ import { UserDto, ClaimDto, ReadMetadata, ApiSuccessResponse } from '../../../data';
4
4
  /**
5
5
  * Client for user management operations
6
6
  *
@@ -21,18 +21,18 @@ export declare class UserManagementControllerClient<TKey, TUser extends UserDto<
21
21
  * @param id - The ID of the user
22
22
  * @returns List of role names assigned to the user
23
23
  */
24
- getUserRoles(id: TKey): Promise<ReadResult<string>>;
24
+ getUserRoles(id: TKey): Promise<ApiSuccessResponse<string[], ReadMetadata>>;
25
25
  /**
26
26
  * Gets the claims assigned to a user
27
27
  * @param id - The ID of the user
28
28
  * @returns List of claims assigned to the user
29
29
  */
30
- getUserClaims(id: TKey): Promise<ReadResult<ClaimDto>>;
30
+ getUserClaims(id: TKey): Promise<ApiSuccessResponse<ClaimDto[], ReadMetadata>>;
31
31
  /**
32
32
  * Gets all available roles in the system
33
33
  * @returns List of all role names
34
34
  */
35
- getAllRoles(): Promise<ReadResult<string>>;
35
+ getAllRoles(): Promise<ApiSuccessResponse<string[], ReadMetadata>>;
36
36
  /**
37
37
  * Changes the password for a user
38
38
  * @param id - The ID of the user
@@ -25,15 +25,19 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
25
25
  async getUserRoles(id) {
26
26
  try {
27
27
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetUserRoles', encodeURIComponent(String(id)));
28
- const response = await this.httpService.request(url, {
28
+ const res = await this.httpService.request(url, {
29
29
  method: 'GET',
30
30
  credentials: 'include',
31
31
  });
32
- if (!response.ok)
33
- throw new Error('Failed to fetch user roles');
34
- return response.json();
32
+ if (!res.ok)
33
+ throw undefined;
34
+ const { success, result, metadata, error } = (await res.json());
35
+ if (!success)
36
+ throw new Error(error.message);
37
+ return { result, metadata };
35
38
  }
36
39
  catch (err) {
40
+ // TODO: Extract error from well-formed response
37
41
  throw err instanceof Error ? err : new Error('Unknown error fetching user roles');
38
42
  }
39
43
  }
@@ -45,15 +49,19 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
45
49
  async getUserClaims(id) {
46
50
  try {
47
51
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetUserClaims', encodeURIComponent(String(id)));
48
- const response = await this.httpService.request(url, {
52
+ const res = await this.httpService.request(url, {
49
53
  method: 'GET',
50
54
  credentials: 'include',
51
55
  });
52
- if (!response.ok)
53
- throw new Error('Failed to fetch user claims');
54
- return response.json();
56
+ if (!res.ok)
57
+ throw undefined;
58
+ const { success, result, metadata, error } = (await res.json());
59
+ if (!success)
60
+ throw new Error(error.message);
61
+ return { result, metadata };
55
62
  }
56
63
  catch (err) {
64
+ // TODO: Extract error from well-formed response
57
65
  throw err instanceof Error ? err : new Error('Unknown error fetching user claims');
58
66
  }
59
67
  }
@@ -64,15 +72,19 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
64
72
  async getAllRoles() {
65
73
  try {
66
74
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, 'GetAllRoles');
67
- const response = await this.httpService.request(url, {
75
+ const res = await this.httpService.request(url, {
68
76
  method: 'GET',
69
77
  credentials: 'include',
70
78
  });
71
- if (!response.ok)
72
- throw new Error('Failed to fetch all roles');
73
- return response.json();
79
+ if (!res.ok)
80
+ throw undefined;
81
+ const { success, result, metadata, error } = (await res.json());
82
+ if (!success)
83
+ throw new Error(error.message);
84
+ return { result, metadata };
74
85
  }
75
86
  catch (err) {
87
+ // TODO: Extract error from well-formed response
76
88
  throw err instanceof Error ? err : new Error('Unknown error fetching all roles');
77
89
  }
78
90
  }
@@ -93,12 +105,11 @@ export class UserManagementControllerClient extends ApiCrudControllerClient {
93
105
  body: JSON.stringify(newPassword),
94
106
  credentials: 'include',
95
107
  });
96
- if (!response.ok) {
97
- const errorText = await response.text();
98
- throw new Error(errorText || 'Failed to change password');
99
- }
108
+ if (!response.ok)
109
+ throw undefined;
100
110
  }
101
111
  catch (err) {
112
+ // TODO: Extract error from well-formed response
102
113
  throw err instanceof Error ? err : new Error('Unknown error changing password');
103
114
  }
104
115
  }
@@ -1,4 +1,4 @@
1
- import { UserDto, UserInfoDto } from '../../../../data';
1
+ import { ApiSuccessResponse, EmptyMetadata, UserDto, UserInfoDto } from '../../../../data';
2
2
  export { UserDto, UserInfoDto };
3
3
  /**
4
4
  * AuthService class is responsible for managing user authentication operations.
@@ -25,7 +25,7 @@ export declare class AuthService<TKey, TUser extends UserDto<TKey> = UserDto<TKe
25
25
  * @return {Promise<TUser>} Currently logged in user's details
26
26
  * @throws {Error} Error if fetch fails
27
27
  */
28
- whoAmI(): Promise<TUser | undefined>;
28
+ whoAmI(): Promise<ApiSuccessResponse<TUser | undefined, EmptyMetadata>>;
29
29
  /**
30
30
  * Authenticates a user using their username and password, and retrieves user's details
31
31
  *
@@ -34,7 +34,7 @@ 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<TUser>;
37
+ signin(username: string, password: string): Promise<ApiSuccessResponse<TUser, EmptyMetadata>>;
38
38
  /**
39
39
  * Deauthenticates current user
40
40
  *
@@ -46,5 +46,5 @@ export declare class AuthService<TKey, TUser extends UserDto<TKey> = UserDto<TKe
46
46
  * If any API response returns an "Unauthenticated" response, call this method
47
47
  * to update local authentication state to unauthenticated
48
48
  */
49
- _handleResponse401(): void;
49
+ _handleNoAuthApiResponse(): void;
50
50
  }
@@ -30,21 +30,24 @@ export class AuthService {
30
30
  async whoAmI() {
31
31
  try {
32
32
  const url = await apiInitializationService.getApiUrl('/auth/whoami');
33
- const response = await fetch(url, { credentials: 'include' });
34
- if (response.ok) {
35
- const info = await response.json();
36
- return (this.user = info.user);
37
- }
38
- else if (response.status === 401) {
39
- return (this.user = undefined);
33
+ const res = await fetch(url, { credentials: 'include' });
34
+ if (!res.ok && res.status !== 401) {
35
+ this.user = undefined;
36
+ throw undefined;
40
37
  }
41
- else {
38
+ if (!res.ok && res.status === 401) {
42
39
  this.user = undefined;
43
- throw new Error('Failed checking authentication status');
40
+ return { result: this.user, metadata: {} };
44
41
  }
42
+ const { success, result, metadata, error } = (await res.json());
43
+ if (!success)
44
+ throw new Error(error.message);
45
+ this.user = result;
46
+ return { result: this.user, metadata };
45
47
  }
46
- catch (error) {
47
- throw error instanceof Error ? error : new Error('Failed checking authentication status');
48
+ catch (err) {
49
+ // TODO: Extract error from well-formed response
50
+ throw err instanceof Error ? err : new Error('Failed checking authentication status');
48
51
  }
49
52
  }
50
53
  /**
@@ -58,27 +61,24 @@ export class AuthService {
58
61
  async signin(username, password) {
59
62
  try {
60
63
  const url = await apiInitializationService.getApiUrl('/auth/signin');
61
- const response = await fetch(url, {
64
+ const res = await fetch(url, {
62
65
  method: 'POST',
63
66
  headers: { 'Content-Type': 'application/json' },
64
67
  body: JSON.stringify({ username, password }),
65
68
  credentials: 'include',
66
69
  });
67
- if (response.ok) {
68
- const user = await this.whoAmI();
69
- if (user !== undefined) {
70
- return (this.user = user);
71
- }
72
- else {
73
- throw new Error('Failed signing in');
74
- }
75
- }
76
- else {
77
- throw new Error('Failed signing in');
78
- }
70
+ if (!res.ok)
71
+ throw undefined;
72
+ // TODO: Handle tokens if not using cookies
73
+ const { result, metadata } = await this.whoAmI();
74
+ if (result === undefined)
75
+ throw undefined;
76
+ this.user = result;
77
+ return { result: this.user, metadata };
79
78
  }
80
- catch (error) {
81
- throw error instanceof Error ? error : new Error('Failed signing in');
79
+ catch (err) {
80
+ // TODO: Extract error from well-formed response
81
+ throw err instanceof Error ? err : new Error('Failed signing in');
82
82
  }
83
83
  }
84
84
  /**
@@ -90,24 +90,22 @@ export class AuthService {
90
90
  async signout() {
91
91
  try {
92
92
  const url = await apiInitializationService.getApiUrl('/auth/signout');
93
- const response = await fetch(url, { credentials: 'include' });
94
- if (response.ok) {
95
- this.user = undefined;
96
- return;
97
- }
98
- else {
99
- throw new Error('Failed signing out');
100
- }
93
+ const res = await fetch(url, { credentials: 'include' });
94
+ if (!res.ok)
95
+ throw undefined;
96
+ this.user = undefined;
97
+ return;
101
98
  }
102
- catch (error) {
103
- throw error instanceof Error ? error : new Error('Failed signing out');
99
+ catch (err) {
100
+ // TODO: Extract error from well-formed response
101
+ throw err instanceof Error ? err : new Error('Failed signing out');
104
102
  }
105
103
  }
106
104
  /**
107
105
  * If any API response returns an "Unauthenticated" response, call this method
108
106
  * to update local authentication state to unauthenticated
109
107
  */
110
- _handleResponse401() {
108
+ _handleNoAuthApiResponse() {
111
109
  this.user = undefined;
112
110
  }
113
111
  }
@@ -1,4 +1,4 @@
1
- import { RoleDto } from '../../../../data';
1
+ import { ApiSuccessResponse, EmptyMetadata, ReadMetadata, RoleDto } from '../../../../data';
2
2
  /**
3
3
  * Client for authorization management operations
4
4
  *
@@ -17,19 +17,19 @@ 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<RoleDto[]>;
21
- /**
22
- * Creates or updates a role
23
- * @param roleDto - The role to create or update
24
- * @returns The created or updated role
25
- */
26
- upsertRole(roleDto: RoleDto): Promise<RoleDto>;
20
+ getAllRoles(includeClaims: boolean): Promise<ApiSuccessResponse<RoleDto[], ReadMetadata>>;
27
21
  /**
28
22
  * Gets a role with its claims
29
23
  * @param roleName - The name of the role
30
24
  * @returns The role with its claims
31
25
  */
32
- getRoleWithClaims(roleName: string): Promise<RoleDto>;
26
+ getRoleWithClaims(roleName: string): Promise<ApiSuccessResponse<RoleDto, ReadMetadata>>;
27
+ /**
28
+ * Creates or updates a role
29
+ * @param roleDto - The role to create or update
30
+ * @returns The created or updated role
31
+ */
32
+ upsertRole(roleDto: RoleDto): Promise<ApiSuccessResponse<RoleDto, EmptyMetadata>>;
33
33
  /**
34
34
  * Deletes a role
35
35
  * @param roleName - The name of the role to delete
@@ -22,17 +22,44 @@ export class AuthorizationManagementControllerClient {
22
22
  async getAllRoles(includeClaims) {
23
23
  try {
24
24
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/GetAllRoles?includeClaims=${includeClaims}`);
25
- const response = await fetch(url, {
25
+ const res = await fetch(url, {
26
26
  credentials: 'include',
27
27
  });
28
- if (!response.ok)
29
- throw new Error('Failed to fetch all roles');
30
- return response.json();
28
+ if (!res.ok)
29
+ throw undefined;
30
+ const { success, result, metadata, error } = (await res.json());
31
+ if (!success)
32
+ throw new Error(error.message);
33
+ return { result, metadata };
31
34
  }
32
35
  catch (err) {
36
+ // TODO: Extract error from well-formed response
33
37
  throw err instanceof Error ? err : new Error('Unknown error fetching all roles');
34
38
  }
35
39
  }
40
+ /**
41
+ * Gets a role with its claims
42
+ * @param roleName - The name of the role
43
+ * @returns The role with its claims
44
+ */
45
+ async getRoleWithClaims(roleName) {
46
+ try {
47
+ const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/GetRoleWithClaims/${encodeURIComponent(roleName)}`);
48
+ const res = await fetch(url, {
49
+ credentials: 'include',
50
+ });
51
+ if (!res.ok)
52
+ throw undefined;
53
+ const { success, result, metadata, error } = (await res.json());
54
+ if (!success)
55
+ throw new Error(error.message);
56
+ return { result, metadata };
57
+ }
58
+ catch (err) {
59
+ // TODO: Extract error from well-formed response
60
+ throw err instanceof Error ? err : new Error('Unknown error fetching role with claims');
61
+ }
62
+ }
36
63
  /**
37
64
  * Creates or updates a role
38
65
  * @param roleDto - The role to create or update
@@ -41,7 +68,7 @@ export class AuthorizationManagementControllerClient {
41
68
  async upsertRole(roleDto) {
42
69
  try {
43
70
  const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/UpsertRole`);
44
- const response = await fetch(url, {
71
+ const res = await fetch(url, {
45
72
  method: 'PUT',
46
73
  headers: {
47
74
  'Content-Type': 'application/json',
@@ -49,35 +76,18 @@ export class AuthorizationManagementControllerClient {
49
76
  body: JSON.stringify(roleDto),
50
77
  credentials: 'include',
51
78
  });
52
- if (!response.ok) {
53
- const errorText = await response.text();
54
- throw new Error(errorText || 'Failed to upsert role');
55
- }
56
- return response.json();
79
+ if (!res.ok)
80
+ throw undefined;
81
+ const { success, result, metadata, error } = (await res.json());
82
+ if (!success)
83
+ throw new Error(error.message);
84
+ return { result, metadata };
57
85
  }
58
86
  catch (err) {
87
+ // TODO: Extract error from well-formed response
59
88
  throw err instanceof Error ? err : new Error('Unknown error upserting role');
60
89
  }
61
90
  }
62
- /**
63
- * Gets a role with its claims
64
- * @param roleName - The name of the role
65
- * @returns The role with its claims
66
- */
67
- async getRoleWithClaims(roleName) {
68
- try {
69
- const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/GetRoleWithClaims/${encodeURIComponent(roleName)}`);
70
- const response = await fetch(url, {
71
- credentials: 'include',
72
- });
73
- if (!response.ok)
74
- throw new Error('Failed to fetch role with claims');
75
- return response.json();
76
- }
77
- catch (err) {
78
- throw err instanceof Error ? err : new Error('Unknown error fetching role with claims');
79
- }
80
- }
81
91
  /**
82
92
  * Deletes a role
83
93
  * @param roleName - The name of the role to delete
@@ -90,12 +100,11 @@ export class AuthorizationManagementControllerClient {
90
100
  method: 'DELETE',
91
101
  credentials: 'include',
92
102
  });
93
- if (!response.ok) {
94
- const errorText = await response.text();
95
- throw new Error(errorText || 'Failed to delete role');
96
- }
103
+ if (!response.ok)
104
+ throw undefined;
97
105
  }
98
106
  catch (err) {
107
+ // TODO: Extract error from well-formed response
99
108
  throw err instanceof Error ? err : new Error('Unknown error deleting role');
100
109
  }
101
110
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * Options for configuring read operations.
3
- *
4
- * @property {boolean} includeTotalCount - Whether to include the total count of items in the response.
5
- */
6
- export type ReadOptions = {
7
- includeTotalCount: boolean;
8
- };
@@ -1,12 +0,0 @@
1
- import { ReadResultMetadata } from '../..';
2
- /**
3
- * Represents a read result containing a collection of results and metadata.
4
- *
5
- * @template T The type of result in the collection.
6
- * @property {T[]} items - The collection of results returned.
7
- * @property {ReadResultMetadata} metadata - Metadata about the paginated result.
8
- */
9
- export type ReadResult<T> = {
10
- results: T[];
11
- metadata: ReadResultMetadata;
12
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Metadata associated with a paginated read result.
3
- *
4
- * @property {number} [totalCount] - The total number of items available.
5
- */
6
- export type ReadResultMetadata = {
7
- totalCount?: number;
8
- };
@@ -1,18 +0,0 @@
1
- import { ReadSelectedSearchPropertyDefinitionDto, ReadSelectedLogicalOperator } from '../..';
2
- /**
3
- * Search definition that supports property searches and nested groups.
4
- */
5
- export type ReadSelectedSearchDefinitionDto = {
6
- /**
7
- * Logical operator (AND/OR) to combine search criteria.
8
- */
9
- logicalOperator: ReadSelectedLogicalOperator;
10
- /**
11
- * Property-based search criteria.
12
- */
13
- propertyCriteria?: ReadSelectedSearchPropertyDefinitionDto[];
14
- /**
15
- * Nested search definitions for complex queries.
16
- */
17
- nestedCriteria?: ReadSelectedSearchDefinitionDto[];
18
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * Type for entities that have a Guid property.
3
- */
4
- export type IIdentifiableByGuid = {
5
- /**
6
- * Gets or sets the Guid of the entity.
7
- */
8
- guid: string;
9
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Type for entities that can, but don't have to have an Id property.
3
- * If present, will be used as a primary key in the database, and if not it signifies an entity that was not yet
4
- * stored.
5
- */
6
- export type IOptionallyIdentifiable<TKey> = {
7
- /**
8
- * Gets or sets the Id of the entity.
9
- */
10
- id?: TKey;
11
- };