@intellegens/cornerstone-client 0.0.9999-alpha-41 → 0.0.9999-alpha-43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/collection-view-adapter.d.ts +123 -0
- package/dist/adapters/collection-view-adapter.integration.test.d.ts +1 -0
- package/dist/adapters/collection-view-adapter.integration.test.js +141 -0
- package/dist/adapters/collection-view-adapter.js +352 -0
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/index.js +2 -2
- package/dist/adapters/search-adapter.d.ts +83 -0
- package/dist/adapters/search-adapter.js +284 -0
- package/dist/data/api/dto/crud/crud-metadata-dto.js +1 -0
- package/dist/data/api/dto/crud/index.d.ts +1 -1
- package/dist/data/api/dto/crud/index.js +1 -1
- package/dist/data/api/dto/index.d.ts +1 -1
- package/dist/data/api/dto/index.js +1 -1
- package/dist/data/api/dto/property-path-dto.d.ts +4 -0
- package/dist/data/api/dto/property-path-dto.js +1 -0
- package/dist/data/api/dto/read/index.d.ts +10 -10
- package/dist/data/api/dto/read/index.js +10 -10
- package/dist/data/api/dto/read/read-metadata-dto.d.ts +8 -0
- package/dist/data/api/dto/read/read-metadata-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-definition-dto.d.ts +18 -0
- package/dist/data/api/dto/read/read-selected-definition-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-nested-collection-criteria-dto.d.ts +22 -0
- package/dist/data/api/dto/read/read-selected-nested-collection-criteria-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-nested-criteria-dto.d.ts +18 -0
- package/dist/data/api/dto/read/read-selected-nested-criteria-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-ordering-definition-dto.d.ts +7 -0
- package/dist/data/api/dto/read/read-selected-ordering-definition-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-ordering-property-definition-dto.d.ts +14 -0
- package/dist/data/api/dto/read/read-selected-ordering-property-definition-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-pagination-definition-dto.d.ts +13 -0
- package/dist/data/api/dto/read/read-selected-pagination-definition-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-search-definition-builder.d.ts +167 -0
- package/dist/data/api/dto/read/read-selected-search-definition-builder.js +267 -0
- package/dist/data/api/dto/read/read-selected-search-definition-dto.d.ts +33 -0
- package/dist/data/api/dto/read/read-selected-search-definition-dto.js +1 -0
- package/dist/data/api/dto/read/read-selected-search-property-definition-dto.d.ts +114 -0
- package/dist/data/api/dto/read/read-selected-search-property-definition-dto.js +1 -0
- package/dist/data/api/dto/read-options-dto.d.ts +8 -0
- package/dist/data/api/dto/read-options-dto.js +1 -0
- package/dist/data/api/dto/read-result-dto.d.ts +12 -0
- package/dist/data/api/dto/read-result-dto.js +1 -0
- package/dist/data/api/dto/read-result-metadata-dto.d.ts +8 -0
- package/dist/data/api/dto/read-result-metadata-dto.js +1 -0
- package/dist/data/api/dto/response/api-error-dto.d.ts +17 -0
- package/dist/data/api/dto/response/api-error-dto.js +1 -0
- package/dist/data/api/dto/response/api-error-response-dto.d.ts +11 -0
- package/dist/data/api/dto/response/api-error-response-dto.js +1 -0
- package/dist/data/api/dto/response/api-response-dto.d.ts +3 -0
- package/dist/data/api/dto/response/api-response-dto.js +1 -0
- package/dist/data/api/dto/response/api-success-response-dto.d.ts +13 -0
- package/dist/data/api/dto/response/api-success-response-dto.js +1 -0
- package/dist/data/api/dto/response/index.d.ts +5 -5
- package/dist/data/api/dto/response/index.js +5 -5
- package/dist/data/api/dto/response/metadata-dto.d.ts +25 -0
- package/dist/data/api/dto/response/metadata-dto.js +1 -0
- package/dist/data/api/enum/read/index.d.ts +5 -5
- package/dist/data/api/enum/read/index.js +5 -5
- package/dist/data/api/enum/read/read-selected-collection-operator.d.ts +16 -0
- package/dist/data/api/enum/read/read-selected-collection-operator.js +17 -0
- package/dist/data/api/enum/read/read-selected-comparison-operator.d.ts +69 -0
- package/dist/data/api/enum/read/read-selected-comparison-operator.js +76 -0
- package/dist/data/api/enum/read/read-selected-logical-operator.d.ts +15 -0
- package/dist/data/api/enum/read/read-selected-logical-operator.js +16 -0
- package/dist/data/api/enum/read/read-selected-ordering-direction.d.ts +13 -0
- package/dist/data/api/enum/read/read-selected-ordering-direction.js +14 -0
- package/dist/data/api/enum/read/read-selected-property-type.d.ts +66 -0
- package/dist/data/api/enum/read/read-selected-property-type.js +75 -0
- package/dist/data/api/enum/response/error-code.d.ts +14 -0
- package/dist/data/api/enum/response/error-code.js +15 -0
- package/dist/data/api/enum/response/index.d.ts +1 -1
- package/dist/data/api/enum/response/index.js +1 -1
- package/dist/data/api/interface/icommon-identifiable.d.ts +7 -0
- package/dist/data/api/interface/icommon-identifiable.js +1 -0
- package/dist/data/api/interface/iconcurrency-safe.d.ts +9 -0
- package/dist/data/api/interface/iconcurrency-safe.js +1 -0
- package/dist/data/api/interface/iidentifiable-secondary.d.ts +9 -0
- package/dist/data/api/interface/iidentifiable-secondary.js +1 -0
- package/dist/data/api/interface/iidentifiable.d.ts +11 -0
- package/dist/data/api/interface/iidentifiable.js +1 -0
- package/dist/data/api/interface/index.d.ts +4 -3
- package/dist/data/api/interface/index.js +4 -3
- package/dist/data/auth/dto/claim-dto.d.ts +4 -0
- package/dist/data/auth/dto/claim-dto.js +1 -0
- package/dist/data/auth/dto/index.d.ts +6 -5
- package/dist/data/auth/dto/index.js +6 -5
- package/dist/data/auth/dto/register-request-dto.d.ts +4 -0
- package/dist/data/auth/dto/register-request-dto.js +1 -0
- package/dist/data/auth/dto/role-dto.d.ts +5 -0
- package/dist/data/auth/dto/role-dto.js +1 -0
- package/dist/data/auth/dto/role-with-claims-dto.d.ts +5 -0
- package/dist/data/auth/dto/role-with-claims-dto.js +1 -0
- package/dist/data/auth/dto/sign-in-request-dto.d.ts +4 -0
- package/dist/data/auth/dto/sign-in-request-dto.js +1 -0
- package/dist/data/auth/dto/tokens-dto.d.ts +4 -0
- package/dist/data/auth/dto/tokens-dto.js +1 -0
- package/dist/data/auth/dto/user-dto.d.ts +16 -0
- package/dist/data/auth/dto/user-dto.js +1 -0
- package/dist/data/auth/dto/user-info-dto.d.ts +14 -0
- package/dist/data/auth/dto/user-info-dto.js +1 -0
- package/dist/services/api/api-crud-controller-client.d.ts +62 -0
- package/dist/services/api/api-crud-controller-client.integration.test.d.ts +1 -0
- package/dist/services/api/api-crud-controller-client.integration.test.js +34 -0
- package/dist/services/api/api-crud-controller-client.js +133 -0
- package/dist/services/api/api-initialization-service.d.ts +106 -0
- package/dist/services/api/api-initialization-service.js +207 -0
- package/dist/services/api/api-read-controller-client.d.ts +62 -0
- package/dist/services/api/api-read-controller-client.integration.test.d.ts +1 -0
- package/dist/services/api/api-read-controller-client.integration.test.js +59 -0
- package/dist/services/api/api-read-controller-client.js +129 -0
- package/dist/services/api/http-service/fetch-http-service.d.ts +7 -0
- package/dist/services/api/http-service/fetch-http-service.integration.test.d.ts +1 -0
- package/dist/services/api/http-service/fetch-http-service.integration.test.js +52 -0
- package/dist/services/api/http-service/fetch-http-service.js +29 -0
- package/dist/services/api/http-service/http-request-config.d.ts +10 -0
- package/dist/services/api/http-service/http-request-config.js +1 -0
- package/dist/services/api/http-service/http-response.d.ts +11 -0
- package/dist/services/api/http-service/http-response.js +3 -0
- package/dist/services/api/http-service/http-service.d.ts +5 -0
- package/dist/services/api/http-service/http-service.js +5 -0
- package/dist/services/api/http-service/ihttp-service.d.ts +13 -0
- package/dist/services/api/http-service/ihttp-service.js +3 -0
- package/dist/services/api/http-service/index.d.ts +5 -0
- package/dist/services/api/http-service/index.js +5 -0
- package/dist/services/api/index.d.ts +5 -5
- package/dist/services/api/index.js +5 -5
- package/dist/services/api/user-management-controller-client.d.ts +80 -0
- package/dist/services/api/user-management-controller-client.integration.test.d.ts +1 -0
- package/dist/services/api/user-management-controller-client.integration.test.js +60 -0
- package/dist/services/api/user-management-controller-client.js +291 -0
- package/dist/services/auth/client/auth-service.d.ts +75 -0
- package/dist/services/auth/client/auth-service.js +200 -0
- package/dist/services/auth/client/authorization-management-controller-client.d.ts +48 -0
- package/dist/services/auth/client/authorization-management-controller-client.integration.test.d.ts +1 -0
- package/dist/services/auth/client/authorization-management-controller-client.integration.test.js +89 -0
- package/dist/services/auth/client/authorization-management-controller-client.js +148 -0
- package/dist/services/auth/client/index.d.ts +2 -2
- package/dist/services/auth/client/index.js +2 -2
- package/dist/utils/authorization.d.ts +17 -0
- package/dist/utils/authorization.js +45 -0
- package/dist/utils/events.d.ts +19 -0
- package/dist/utils/events.js +12 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/result.d.ts +21 -0
- package/dist/utils/result.js +16 -0
- package/dist/utils/search.d.ts +34 -0
- package/dist/utils/search.js +106 -0
- package/package.json +6 -6
- package/src/adapters/collection-view-adapter.integration.test.ts +172 -0
- package/src/adapters/collection-view-adapter.ts +458 -0
- package/src/adapters/index.ts +2 -2
- package/src/adapters/search-adapter.ts +374 -0
- package/src/data/api/dto/crud/crud-metadata-dto.ts +4 -0
- package/src/data/api/dto/crud/index.ts +1 -1
- package/src/data/api/dto/index.ts +1 -1
- package/src/data/api/dto/read/index.ts +10 -10
- package/src/data/api/dto/read/{ReadSelectedSearchDefinitionBuilder.ts → read-selected-search-definition-builder.ts} +4 -4
- package/src/data/api/dto/{ReadResultDto.ts → read-result-dto.ts} +1 -1
- package/src/data/api/dto/response/{ApiErrorDto.ts → api-error-dto.ts} +1 -1
- package/src/data/api/dto/response/index.ts +5 -5
- package/src/data/api/enum/read/index.ts +5 -5
- package/src/data/api/enum/response/{ErrorCode.ts → error-code.ts} +1 -0
- package/src/data/api/enum/response/index.ts +1 -1
- package/src/data/api/interface/{ICommonIdentifiable.ts → icommon-identifiable.ts} +1 -1
- package/src/data/api/interface/{IConcurrencySafe.ts → iconcurrency-safe.ts} +1 -1
- package/src/data/api/interface/{IIdentifiable.ts → iidentifiable.ts} +1 -1
- package/src/data/api/interface/index.ts +4 -3
- package/src/data/auth/dto/index.ts +6 -5
- package/src/data/auth/dto/role-with-claims-dto.ts +6 -0
- package/src/data/auth/dto/{UserDto.ts → user-dto.ts} +5 -6
- package/src/services/api/{ApiCrudControllerClient/index.integration.test.ts → api-crud-controller-client.integration.test.ts} +1 -1
- package/src/services/api/{ApiCrudControllerClient/index.ts → api-crud-controller-client.ts} +62 -7
- package/src/services/api/{ApiInitializationService/index.ts → api-initialization-service.ts} +2 -4
- package/src/services/api/{ApiReadControllerClient/index.integration.test.ts → api-read-controller-client.integration.test.ts} +1 -1
- package/src/services/api/{ApiReadControllerClient/index.ts → api-read-controller-client.ts} +55 -6
- package/src/services/api/{HttpService/FetchHttpService.integration.test.ts → http-service/fetch-http-service.integration.test.ts} +1 -1
- package/src/services/api/http-service/http-service.ts +6 -0
- package/src/services/api/http-service/index.ts +5 -0
- package/src/services/api/index.ts +5 -5
- package/src/services/api/{UserManagementControllerClient/index.integration.test.ts → user-management-controller-client.integration.test.ts} +1 -1
- package/src/services/api/user-management-controller-client.ts +322 -0
- package/src/services/auth/client/index.ts +2 -2
- package/src/utils/events.ts +29 -0
- package/src/utils/index.ts +2 -0
- package/demo/index.ts +0 -29
- package/demo/public_html/favicon.ico +0 -0
- package/demo/public_html/index.html +0 -105
- package/demo/public_html/websettings.json +0 -3
- package/src/adapters/CollectionViewAdapter/index.integration.test.ts +0 -197
- package/src/adapters/CollectionViewAdapter/index.ts +0 -477
- package/src/adapters/SearchAdapter/index.ts +0 -302
- package/src/services/api/HttpService/index.ts +0 -12
- package/src/services/api/UserManagementControllerClient/index.ts +0 -134
- /package/{src/data/api/dto/crud/CrudMetadataDto.ts → dist/data/api/dto/crud/crud-metadata-dto.d.ts} +0 -0
- /package/src/data/api/dto/{PropertyPathDto.ts → property-path-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadMetadataDto.ts → read-metadata-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedDefinitionDto.ts → read-selected-definition-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedNestedCollectionCriteriaDto.ts → read-selected-nested-collection-criteria-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedNestedCriteriaDto.ts → read-selected-nested-criteria-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedOrderingDefinitionDto.ts → read-selected-ordering-definition-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedOrderingPropertyDefinitionDto.ts → read-selected-ordering-property-definition-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedPaginationDefinitionDto.ts → read-selected-pagination-definition-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedSearchDefinitionDto.ts → read-selected-search-definition-dto.ts} +0 -0
- /package/src/data/api/dto/read/{ReadSelectedSearchPropertyDefinitionDto.ts → read-selected-search-property-definition-dto.ts} +0 -0
- /package/src/data/api/dto/{ReadOptionsDto.ts → read-options-dto.ts} +0 -0
- /package/src/data/api/dto/{ReadResultMetadataDto.ts → read-result-metadata-dto.ts} +0 -0
- /package/src/data/api/dto/response/{ApiErrorResponseDto.ts → api-error-response-dto.ts} +0 -0
- /package/src/data/api/dto/response/{ApiResponseDto.ts → api-response-dto.ts} +0 -0
- /package/src/data/api/dto/response/{ApiSuccessResponseDto.ts → api-success-response-dto.ts} +0 -0
- /package/src/data/api/dto/response/{MetadataDto.ts → metadata-dto.ts} +0 -0
- /package/src/data/api/enum/read/{ReadSelectedCollectionOperator.ts → read-selected-collection-operator.ts} +0 -0
- /package/src/data/api/enum/read/{ReadSelectedComparisonOperator.ts → read-selected-comparison-operator.ts} +0 -0
- /package/src/data/api/enum/read/{ReadSelectedLogicalOperator.ts → read-selected-logical-operator.ts} +0 -0
- /package/src/data/api/enum/read/{ReadSelectedOrderingDirection.ts → read-selected-ordering-direction.ts} +0 -0
- /package/src/data/api/enum/read/{ReadSelectedPropertyType.ts → read-selected-property-type.ts} +0 -0
- /package/src/data/api/interface/{IIdentifiableSecondary.ts → iidentifiable-secondary.ts} +0 -0
- /package/src/data/auth/dto/{ClaimDto.ts → claim-dto.ts} +0 -0
- /package/src/data/auth/dto/{RegisterRequestDto.ts → register-request-dto.ts} +0 -0
- /package/src/data/auth/dto/{RoleDto.ts → role-dto.ts} +0 -0
- /package/src/data/auth/dto/{SignInRequestDto.ts → sign-in-request-dto.ts} +0 -0
- /package/src/data/auth/dto/{TokensDto.ts → tokens-dto.ts} +0 -0
- /package/src/data/auth/dto/{UserInfoDto.ts → user-info-dto.ts} +0 -0
- /package/src/services/api/{HttpService → http-service}/README.md +0 -0
- /package/src/services/api/{HttpService/FetchHttpService.ts → http-service/fetch-http-service.ts} +0 -0
- /package/src/services/api/{HttpService/HttpRequestConfig.ts → http-service/http-request-config.ts} +0 -0
- /package/src/services/api/{HttpService/HttpResponse.ts → http-service/http-response.ts} +0 -0
- /package/src/services/api/{HttpService/IHttpService.ts → http-service/ihttp-service.ts} +0 -0
- /package/src/services/auth/client/{AuthService/index.ts → auth-service.ts} +0 -0
- /package/src/services/auth/client/{AuthorizationManagementControllerClient/index.integration.test.ts → authorization-management-controller-client.integration.test.ts} +0 -0
- /package/src/services/auth/client/{AuthorizationManagementControllerClient/index.ts → authorization-management-controller-client.ts} +0 -0
- /package/src/utils/{authorization/index.ts → authorization.ts} +0 -0
- /package/src/utils/{result/index.ts → result.ts} +0 -0
- /package/src/utils/{search/index.ts → search.ts} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IHttpService } from '../../services';
|
|
2
|
+
import { ApiResponseDto, EmptyMetadataDto, IIdentifiable, ReadMetadataDto, ReadSelectedDefinitionDto } from '../../data';
|
|
3
|
+
/**
|
|
4
|
+
* Client for reading all entities from a read controller.
|
|
5
|
+
*/
|
|
6
|
+
export interface IReadAllClient<TKey, TResultDto extends IIdentifiable<TKey>> {
|
|
7
|
+
readAll(signal?: AbortSignal): Promise<ApiResponseDto<TResultDto[], ReadMetadataDto>>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Client for reading selected entities from a read controller.
|
|
11
|
+
*/
|
|
12
|
+
export interface IReadSelectedClient<TKey, TResultDto extends IIdentifiable<TKey>> {
|
|
13
|
+
readSelected(definition: ReadSelectedDefinitionDto<TResultDto>, signal?: AbortSignal): Promise<ApiResponseDto<TResultDto[], ReadMetadataDto>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Client for reading a single entity from a read controller.
|
|
17
|
+
*/
|
|
18
|
+
export interface IReadSingleClient<TKey, TResultDto extends IIdentifiable<TKey>> {
|
|
19
|
+
readSingle(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<TResultDto, EmptyMetadataDto>>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Client for reading entities from a read controller.
|
|
23
|
+
*/
|
|
24
|
+
export interface IApiReadControllerClient<TKey, TResultDto extends IIdentifiable<TKey>, TSingleResultDto extends IIdentifiable<TKey>> extends IReadAllClient<TKey, TResultDto>, IReadSelectedClient<TKey, TResultDto>, IReadSingleClient<TKey, TSingleResultDto> {
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Base client for read-only API controllers
|
|
28
|
+
*/
|
|
29
|
+
export declare class ApiReadControllerClient<TKey, TResultDto extends IIdentifiable<TKey>, TSingleResultDto extends IIdentifiable<TKey>> implements IApiReadControllerClient<TKey, TResultDto, TSingleResultDto> {
|
|
30
|
+
protected readonly baseControllerPath: string;
|
|
31
|
+
/**
|
|
32
|
+
* Constructor
|
|
33
|
+
* @param baseControllerPath Base path to API controller
|
|
34
|
+
* @param httpService HTTP service implementation to use for requests
|
|
35
|
+
*/
|
|
36
|
+
constructor(baseControllerPath: string, httpService?: IHttpService);
|
|
37
|
+
private readonly _httpService?;
|
|
38
|
+
/**
|
|
39
|
+
* Gets globally selected HTTP service
|
|
40
|
+
*/
|
|
41
|
+
protected get httpService(): IHttpService;
|
|
42
|
+
/**
|
|
43
|
+
* Fetches all entities from the read controller.
|
|
44
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
45
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
|
|
46
|
+
*/
|
|
47
|
+
readAll(signal?: AbortSignal): Promise<ApiResponseDto<TResultDto[], ReadMetadataDto>>;
|
|
48
|
+
/**
|
|
49
|
+
* Fetches selected entities based on a filter definition.
|
|
50
|
+
* @param {any} definition - The filter definition object
|
|
51
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
52
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} The result of the read operation with metadata
|
|
53
|
+
*/
|
|
54
|
+
readSelected(definition: ReadSelectedDefinitionDto<TResultDto>, signal?: AbortSignal): Promise<ApiResponseDto<TResultDto[], ReadMetadataDto>>;
|
|
55
|
+
/**
|
|
56
|
+
* Fetches a single entity by its ID.
|
|
57
|
+
* @param {TKey} id - The ID of the entity
|
|
58
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
59
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
|
|
60
|
+
*/
|
|
61
|
+
readSingle(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<TSingleResultDto, EmptyMetadataDto>>;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { ApiReadControllerClient } from '.';
|
|
3
|
+
import { FetchHttpService } from '..';
|
|
4
|
+
import { ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType } from '../../data';
|
|
5
|
+
describe('ApiReadControllerClient', () => {
|
|
6
|
+
let client;
|
|
7
|
+
let fetchService;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
fetchService = new FetchHttpService();
|
|
10
|
+
client = new ApiReadControllerClient('/VehiclesSlim', fetchService);
|
|
11
|
+
});
|
|
12
|
+
it('should use injected HTTP service for readAll', async () => {
|
|
13
|
+
const result = (await client.readAll());
|
|
14
|
+
expect(result.ok).toBe(true);
|
|
15
|
+
expect(result.result).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
it('should use injected HTTP service for readSingle', async () => {
|
|
18
|
+
const testId = 1;
|
|
19
|
+
const result = (await client.readSingle(testId));
|
|
20
|
+
expect(result.ok).toBe(true);
|
|
21
|
+
expect(result.result).toBeDefined();
|
|
22
|
+
expect(typeof result.result).toBe('object');
|
|
23
|
+
expect(result.result.id).toBe(testId);
|
|
24
|
+
});
|
|
25
|
+
it('should use injected HTTP service for readSelected', async () => {
|
|
26
|
+
const definition = {
|
|
27
|
+
searchDefinition: {
|
|
28
|
+
searches: [
|
|
29
|
+
{
|
|
30
|
+
propertyCriteria: [
|
|
31
|
+
{
|
|
32
|
+
propertyName: 'Brand',
|
|
33
|
+
comparisonOperator: ReadSelectedComparisonOperator.Equal,
|
|
34
|
+
valueType: ReadSelectedPropertyType.String,
|
|
35
|
+
value: 'Audi',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
propertyName: 'Brand',
|
|
39
|
+
comparisonOperator: ReadSelectedComparisonOperator.Equal,
|
|
40
|
+
valueType: ReadSelectedPropertyType.String,
|
|
41
|
+
value: 'BMW',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
logicalOperator: ReadSelectedLogicalOperator.Or,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
logicalOperator: ReadSelectedLogicalOperator.And,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const result = (await client.readSelected(definition));
|
|
51
|
+
expect(result.ok).toBe(true);
|
|
52
|
+
expect(result.result).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
it('should handle HTTP errors properly', async () => {
|
|
55
|
+
const invalidClient = new ApiReadControllerClient('/InvalidPath', fetchService);
|
|
56
|
+
const result = await invalidClient.readAll();
|
|
57
|
+
expect(result.ok).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { apiInitializationService } from '../../services';
|
|
2
|
+
import { ErrorCode, } from '../../data';
|
|
3
|
+
import { fail, ok } from '../../utils/result';
|
|
4
|
+
function isAbortError(err) {
|
|
5
|
+
return err instanceof DOMException && err.name === 'AbortError';
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Base client for read-only API controllers
|
|
9
|
+
*/
|
|
10
|
+
export class ApiReadControllerClient {
|
|
11
|
+
baseControllerPath;
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param baseControllerPath Base path to API controller
|
|
15
|
+
* @param httpService HTTP service implementation to use for requests
|
|
16
|
+
*/
|
|
17
|
+
constructor(baseControllerPath, httpService) {
|
|
18
|
+
this.baseControllerPath = baseControllerPath;
|
|
19
|
+
this._httpService = httpService;
|
|
20
|
+
}
|
|
21
|
+
// #region HTTP service
|
|
22
|
+
_httpService = undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Gets globally selected HTTP service
|
|
25
|
+
*/
|
|
26
|
+
get httpService() {
|
|
27
|
+
return this._httpService || apiInitializationService._getHttpService();
|
|
28
|
+
}
|
|
29
|
+
// #endregion
|
|
30
|
+
// #region API
|
|
31
|
+
/**
|
|
32
|
+
* Fetches all entities from the read controller.
|
|
33
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
34
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} List of all entities with metadata
|
|
35
|
+
*/
|
|
36
|
+
async readAll(signal) {
|
|
37
|
+
try {
|
|
38
|
+
const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadAll`);
|
|
39
|
+
const res = await this.httpService.request(url, { method: 'GET', credentials: 'include', signal });
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
return fail(await res.json());
|
|
42
|
+
}
|
|
43
|
+
return ok(await res.json());
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (isAbortError(err)) {
|
|
47
|
+
return fail({
|
|
48
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
console.error(err);
|
|
52
|
+
return fail({
|
|
53
|
+
error: {
|
|
54
|
+
code: ErrorCode.UnknownError,
|
|
55
|
+
message: 'Unknown error fetching all records',
|
|
56
|
+
metadata: {},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fetches selected entities based on a filter definition.
|
|
63
|
+
* @param {any} definition - The filter definition object
|
|
64
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
65
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto>[], ReadMetadataDto>>} The result of the read operation with metadata
|
|
66
|
+
*/
|
|
67
|
+
async readSelected(definition, signal) {
|
|
68
|
+
try {
|
|
69
|
+
const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSelected`);
|
|
70
|
+
const res = await this.httpService.request(url, {
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: { 'Content-Type': 'application/json' },
|
|
73
|
+
body: JSON.stringify(definition),
|
|
74
|
+
credentials: 'include',
|
|
75
|
+
signal,
|
|
76
|
+
});
|
|
77
|
+
if (!res.ok) {
|
|
78
|
+
return fail(await res.json());
|
|
79
|
+
}
|
|
80
|
+
return ok(await res.json());
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (isAbortError(err)) {
|
|
84
|
+
return fail({
|
|
85
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
console.error(err);
|
|
89
|
+
return fail({
|
|
90
|
+
error: {
|
|
91
|
+
code: ErrorCode.UnknownError,
|
|
92
|
+
message: 'Unknown error fetching selected records',
|
|
93
|
+
metadata: {},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches a single entity by its ID.
|
|
100
|
+
* @param {TKey} id - The ID of the entity
|
|
101
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
102
|
+
* @returns {Promise<ApiSuccessResponseDto<TDto, EmptyMetadataDto>>} The requested entity
|
|
103
|
+
*/
|
|
104
|
+
async readSingle(id, signal) {
|
|
105
|
+
try {
|
|
106
|
+
const url = await apiInitializationService.getApiUrl(this.baseControllerPath, `/ReadSingle?id=${encodeURIComponent(String(id))}`);
|
|
107
|
+
const res = await this.httpService.request(url, { method: 'GET', credentials: 'include', signal });
|
|
108
|
+
if (!res.ok) {
|
|
109
|
+
return fail(await res.json());
|
|
110
|
+
}
|
|
111
|
+
return ok(await res.json());
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (isAbortError(err)) {
|
|
115
|
+
return fail({
|
|
116
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
console.error(err);
|
|
120
|
+
return fail({
|
|
121
|
+
error: {
|
|
122
|
+
code: ErrorCode.UnknownError,
|
|
123
|
+
message: `Unknown error fetching record with id ${id}`,
|
|
124
|
+
metadata: {},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HttpRequestConfig, HttpResponse, IHttpService } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Default HTTP service implementation using the Fetch API
|
|
4
|
+
*/
|
|
5
|
+
export declare class FetchHttpService implements IHttpService {
|
|
6
|
+
request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { FetchHttpService } from '../..';
|
|
3
|
+
const baseUrl = 'http://localhost:5000/api';
|
|
4
|
+
const credentials = {
|
|
5
|
+
username: 'admin@test.com',
|
|
6
|
+
password: 'Password1234!',
|
|
7
|
+
};
|
|
8
|
+
describe('FetchHttpService', () => {
|
|
9
|
+
let fetchService;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
fetchService = new FetchHttpService();
|
|
12
|
+
});
|
|
13
|
+
it('should make a GET request successfully', async () => {
|
|
14
|
+
const result = await fetchService.request(`${baseUrl}/AnythingManuallyMappedRead/ReadAll`);
|
|
15
|
+
expect(result.ok).toBe(true);
|
|
16
|
+
expect(result.status).toBe(200);
|
|
17
|
+
expect(result.statusText).toBe('OK');
|
|
18
|
+
const jsonData = await result.json();
|
|
19
|
+
expect(jsonData.result).toBeDefined();
|
|
20
|
+
expect(jsonData.error).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
it('should make a POST request with body', async () => {
|
|
23
|
+
const result = await fetchService.request(`${baseUrl}/auth/signin`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: { 'Content-Type': 'application/json' },
|
|
26
|
+
body: JSON.stringify(credentials),
|
|
27
|
+
});
|
|
28
|
+
expect(result.ok).toBe(true);
|
|
29
|
+
expect(result.status).toBe(204);
|
|
30
|
+
});
|
|
31
|
+
it('should handle non-ok responses', async () => {
|
|
32
|
+
const result = await fetchService.request(`${baseUrl}/auth/signin`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: { 'Content-Type': 'application/json' },
|
|
35
|
+
body: JSON.stringify({ username: credentials.username, password: `${credentials.password}wrong` }),
|
|
36
|
+
});
|
|
37
|
+
expect(result.ok).toBe(false);
|
|
38
|
+
expect(result.status).toBe(400);
|
|
39
|
+
expect(result.statusText).toBe('Bad Request');
|
|
40
|
+
const jsonData = await result.json();
|
|
41
|
+
expect(jsonData.result).toBeNull();
|
|
42
|
+
expect(jsonData.error).toBeDefined();
|
|
43
|
+
expect(jsonData.error.code).toBe(400);
|
|
44
|
+
expect(jsonData.error.message).toBe('Invalid email or password');
|
|
45
|
+
});
|
|
46
|
+
it('should handle fetch errors from backend', async () => {
|
|
47
|
+
const result = await fetchService.request('http://localhost:5000/api/error');
|
|
48
|
+
expect(result.ok).toBe(false);
|
|
49
|
+
expect(result.status).toBe(404);
|
|
50
|
+
expect(result.statusText).toBe('Not Found');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Ignore eslint any error in this file
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
/**
|
|
4
|
+
* Default HTTP service implementation using the Fetch API
|
|
5
|
+
*/
|
|
6
|
+
export class FetchHttpService {
|
|
7
|
+
async request(url, config) {
|
|
8
|
+
const response = await fetch(url, {
|
|
9
|
+
method: config?.method || 'GET',
|
|
10
|
+
headers: config?.headers,
|
|
11
|
+
body: config?.body,
|
|
12
|
+
credentials: config?.credentials || 'include',
|
|
13
|
+
signal: config?.signal,
|
|
14
|
+
});
|
|
15
|
+
// Convert Headers to a plain object
|
|
16
|
+
const headers = {};
|
|
17
|
+
response.headers.forEach((value, key) => {
|
|
18
|
+
headers[key] = value;
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
ok: response.ok,
|
|
22
|
+
status: response.status,
|
|
23
|
+
statusText: response.statusText,
|
|
24
|
+
headers,
|
|
25
|
+
json: () => response.json(),
|
|
26
|
+
text: () => response.text(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP request configuration interface
|
|
3
|
+
*/
|
|
4
|
+
export interface HttpRequestConfig {
|
|
5
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
body?: string;
|
|
8
|
+
credentials?: RequestCredentials;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpRequestConfig, HttpResponse } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract HTTP service interface that can be implemented by different HTTP clients
|
|
4
|
+
*/
|
|
5
|
+
export interface IHttpService {
|
|
6
|
+
/**
|
|
7
|
+
* Performs an HTTP request
|
|
8
|
+
* @param url - The URL to make the request to
|
|
9
|
+
* @param config - Request configuration
|
|
10
|
+
* @returns Promise that resolves to the HTTP response
|
|
11
|
+
*/
|
|
12
|
+
request<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './http-service';
|
|
2
|
+
export * from './api-initialization-service';
|
|
3
|
+
export * from './api-read-controller-client';
|
|
4
|
+
export * from './api-crud-controller-client';
|
|
5
|
+
export * from './user-management-controller-client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './http-service';
|
|
2
|
+
export * from './api-initialization-service';
|
|
3
|
+
export * from './api-read-controller-client';
|
|
4
|
+
export * from './api-crud-controller-client';
|
|
5
|
+
export * from './user-management-controller-client';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ApiCrudControllerClient, IHttpService } from '../../services';
|
|
2
|
+
import { ApiResponseDto, ClaimDto, EmptyMetadataDto, ReadMetadataDto, UserDto } from '../../data';
|
|
3
|
+
/**
|
|
4
|
+
* Client for user management operations
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class UserManagementControllerClient
|
|
8
|
+
* @template TKey - Type of the entity key (e.g., number, string, GUID, etc.)
|
|
9
|
+
* @template TUser - Data Transfer Object representing the user entity
|
|
10
|
+
*/
|
|
11
|
+
export declare class UserManagementControllerClient<TKey, TResultDto extends UserDto<TKey>, TSingleResultDto extends UserDto<TKey>, TInsertRequestDto extends UserDto<TKey>, TUpdateRequestDto extends UserDto<TKey>> extends ApiCrudControllerClient<TKey, TResultDto, TSingleResultDto, TInsertRequestDto, TUpdateRequestDto> {
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param baseControllerPath Base path to API controller
|
|
15
|
+
* @param httpService HTTP service implementation to use for requests
|
|
16
|
+
*/
|
|
17
|
+
constructor(baseControllerPath: string, httpService?: IHttpService);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the roles assigned to a user
|
|
20
|
+
* @param id - The ID of the user
|
|
21
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
22
|
+
* @returns List of role names assigned to the user
|
|
23
|
+
*/
|
|
24
|
+
getUserRoles(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<string[], ReadMetadataDto>>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the claims assigned to a user
|
|
27
|
+
* @param id - The ID of the user
|
|
28
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
29
|
+
* @returns List of claims assigned to the user
|
|
30
|
+
*/
|
|
31
|
+
getUserClaims(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<ClaimDto[], ReadMetadataDto>>;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the roles for a user, replacing all existing roles
|
|
34
|
+
* @param id - The ID of the user
|
|
35
|
+
* @param roles - The list of role names to set
|
|
36
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
37
|
+
* @returns Promise that resolves when the roles are set successfully
|
|
38
|
+
*/
|
|
39
|
+
setUserRoles(id: TKey, roles: string[], signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
40
|
+
/**
|
|
41
|
+
* Adds roles to a user
|
|
42
|
+
* @param id - The ID of the user
|
|
43
|
+
* @param roles - The list of role names to add
|
|
44
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
45
|
+
* @returns Promise that resolves when the roles are added successfully
|
|
46
|
+
*/
|
|
47
|
+
addRolesToUser(id: TKey, roles: string[], signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
48
|
+
/**
|
|
49
|
+
* Removes roles from a user
|
|
50
|
+
* @param id - The ID of the user
|
|
51
|
+
* @param roles - The list of role names to remove
|
|
52
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
53
|
+
* @returns Promise that resolves when the roles are removed successfully
|
|
54
|
+
*/
|
|
55
|
+
removeRolesFromUser(id: TKey, roles: string[], signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
56
|
+
/**
|
|
57
|
+
* Adds claims to a user
|
|
58
|
+
* @param id - The ID of the user
|
|
59
|
+
* @param claims - The list of claims to add
|
|
60
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
61
|
+
* @returns Promise that resolves when the claims are added successfully
|
|
62
|
+
*/
|
|
63
|
+
addUserClaims(id: TKey, claims: ClaimDto[], signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
64
|
+
/**
|
|
65
|
+
* Removes claims from a user
|
|
66
|
+
* @param id - The ID of the user
|
|
67
|
+
* @param claims - The list of claims to remove
|
|
68
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
69
|
+
* @returns Promise that resolves when the claims are removed successfully
|
|
70
|
+
*/
|
|
71
|
+
removeUserClaims(id: TKey, claims: ClaimDto[], signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
72
|
+
/**
|
|
73
|
+
* Changes the password for a user
|
|
74
|
+
* @param id - The ID of the user
|
|
75
|
+
* @param newPassword - The new password to set
|
|
76
|
+
* @param {AbortSignal} [signal] - Optional cancellation signal
|
|
77
|
+
* @returns Promise that resolves when the password is changed successfully
|
|
78
|
+
*/
|
|
79
|
+
changePassword(id: TKey, newPassword: string, signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { UserManagementControllerClient } from '.';
|
|
3
|
+
import fetchOrig from 'node-fetch';
|
|
4
|
+
import fetchCookie from 'fetch-cookie';
|
|
5
|
+
import { CookieJar } from 'tough-cookie';
|
|
6
|
+
// Create a fetch instance that handles auth cookies
|
|
7
|
+
const jar = new CookieJar();
|
|
8
|
+
const cookieFetch = fetchCookie(fetchOrig, jar);
|
|
9
|
+
// Custom IHttpService implementation for tests
|
|
10
|
+
class CookieFetchHttpService {
|
|
11
|
+
async request(url, config) {
|
|
12
|
+
const response = await cookieFetch(url, {
|
|
13
|
+
method: config?.method || 'GET',
|
|
14
|
+
headers: config?.headers,
|
|
15
|
+
body: config?.body,
|
|
16
|
+
signal: config?.signal,
|
|
17
|
+
});
|
|
18
|
+
const headers = {};
|
|
19
|
+
response.headers.forEach((value, key) => {
|
|
20
|
+
headers[key] = value;
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
ok: response.ok,
|
|
24
|
+
status: response.status,
|
|
25
|
+
statusText: response.statusText,
|
|
26
|
+
headers,
|
|
27
|
+
json: () => response.json(),
|
|
28
|
+
text: () => response.text(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const credentials = {
|
|
33
|
+
username: 'admin@test.com',
|
|
34
|
+
password: 'Password1234!',
|
|
35
|
+
};
|
|
36
|
+
const baseUrl = 'http://localhost:5000/api';
|
|
37
|
+
describe('UserManagementControllerClient', () => {
|
|
38
|
+
let client;
|
|
39
|
+
let fetchService = new CookieFetchHttpService();
|
|
40
|
+
beforeAll(async () => {
|
|
41
|
+
await fetchService.request(`${baseUrl}/auth/signin`, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: { 'Content-Type': 'application/json' },
|
|
44
|
+
body: JSON.stringify(credentials),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
client = new UserManagementControllerClient('/users', fetchService);
|
|
49
|
+
});
|
|
50
|
+
it('should use injected HTTP service for getUserRoles', async () => {
|
|
51
|
+
const result = (await client.getUserRoles(1));
|
|
52
|
+
expect(result.ok).toBe(true);
|
|
53
|
+
expect(result.result).toBeDefined();
|
|
54
|
+
});
|
|
55
|
+
it('should use injected HTTP service for getUserClaims', async () => {
|
|
56
|
+
const result = (await client.getUserClaims(1));
|
|
57
|
+
expect(result.ok).toBe(true);
|
|
58
|
+
expect(result.result).toBeDefined();
|
|
59
|
+
});
|
|
60
|
+
});
|