@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,374 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCode,
|
|
3
|
+
PropertyPathDto,
|
|
4
|
+
ReadSelectedComparisonOperator,
|
|
5
|
+
ReadSelectedDefinitionDto,
|
|
6
|
+
ReadSelectedLogicalOperator,
|
|
7
|
+
ReadSelectedOrderingDirection,
|
|
8
|
+
ReadSelectedPropertyType,
|
|
9
|
+
ReadSelectedSearchDefinitionDto,
|
|
10
|
+
ReadSelectedSearchPropertyDefinitionDto,
|
|
11
|
+
} from '@data';
|
|
12
|
+
import { ApiReadControllerClient, IReadSelectedClient } from '@services';
|
|
13
|
+
import { IHasObservableProperty, SingularEventTarget, toPascalCase } from '@utils';
|
|
14
|
+
|
|
15
|
+
export type SearchAdapterBaseOptions<TDto> = {
|
|
16
|
+
primaryKey: string | ((item: TDto) => string);
|
|
17
|
+
multiselect: boolean;
|
|
18
|
+
defaultSearch?: ReadSelectedSearchDefinitionDto<TDto>;
|
|
19
|
+
defaultText?: string;
|
|
20
|
+
searchTriggerMinLength?: number;
|
|
21
|
+
searchDebounceDelay?: number;
|
|
22
|
+
ordering?: { path: PropertyPathDto; direction: ReadSelectedOrderingDirection }[];
|
|
23
|
+
limit?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type SearchAdapterOptions<TDto> = SearchAdapterBaseOptions<TDto> & (TDto extends { type: string } ? { typesToSearch?: string[] } : {});
|
|
27
|
+
|
|
28
|
+
export interface ISearchAdapter<TDto>
|
|
29
|
+
extends
|
|
30
|
+
IHasObservableProperty<'isLoading', boolean>,
|
|
31
|
+
IHasObservableProperty<'error', string | undefined>,
|
|
32
|
+
IHasObservableProperty<'searchData', readonly TDto[]>,
|
|
33
|
+
IHasObservableProperty<'totalItemCount', number>,
|
|
34
|
+
IHasObservableProperty<'types', string[] | undefined>,
|
|
35
|
+
IHasObservableProperty<'search', ReadSelectedSearchDefinitionDto<TDto> | undefined>,
|
|
36
|
+
IHasObservableProperty<'text', string | undefined>,
|
|
37
|
+
IHasObservableProperty<'selection', readonly TDto[]> {
|
|
38
|
+
readonly options: Required<SearchAdapterBaseOptions<TDto>>;
|
|
39
|
+
readonly searchTriggerMinLength: number;
|
|
40
|
+
|
|
41
|
+
setTypes(types: string[] | undefined): void;
|
|
42
|
+
setSearch(search: ReadSelectedSearchDefinitionDto<TDto> | undefined): void;
|
|
43
|
+
setText(text: string | undefined): void;
|
|
44
|
+
|
|
45
|
+
refresh(): void;
|
|
46
|
+
|
|
47
|
+
selectionAdd(item: TDto): void;
|
|
48
|
+
selectionRemove(item: TDto): void;
|
|
49
|
+
selectionToggle(item: TDto): void;
|
|
50
|
+
selectionClear(): void;
|
|
51
|
+
|
|
52
|
+
destroy(): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DEFAULT_OPTIONS = {
|
|
56
|
+
defaultSearch: undefined,
|
|
57
|
+
defaultText: undefined,
|
|
58
|
+
searchTriggerMinLength: 1,
|
|
59
|
+
searchDebounceDelay: 100,
|
|
60
|
+
ordering: [],
|
|
61
|
+
limit: undefined,
|
|
62
|
+
} as const;
|
|
63
|
+
|
|
64
|
+
export class SearchAdapter<TDto> implements ISearchAdapter<TDto> {
|
|
65
|
+
public readonly options: Required<SearchAdapterBaseOptions<TDto>>;
|
|
66
|
+
|
|
67
|
+
public readonly isLoadingChanged = new SingularEventTarget<boolean>();
|
|
68
|
+
public readonly errorChanged = new SingularEventTarget<string | undefined>();
|
|
69
|
+
public readonly searchDataChanged = new SingularEventTarget<readonly TDto[]>();
|
|
70
|
+
public readonly totalItemCountChanged = new SingularEventTarget<number>();
|
|
71
|
+
public readonly typesChanged = new SingularEventTarget<string[] | undefined>();
|
|
72
|
+
public readonly searchChanged = new SingularEventTarget<ReadSelectedSearchDefinitionDto<TDto> | undefined>();
|
|
73
|
+
public readonly textChanged = new SingularEventTarget<string | undefined>();
|
|
74
|
+
public readonly selectionChanged = new SingularEventTarget<readonly TDto[]>();
|
|
75
|
+
|
|
76
|
+
private _readClient: IReadSelectedClient<any, any>;
|
|
77
|
+
private _isLoading = false;
|
|
78
|
+
private _error: string | undefined = undefined;
|
|
79
|
+
private _searchData: TDto[] = [];
|
|
80
|
+
private _totalItemCount = 0;
|
|
81
|
+
private _types: string[] | undefined;
|
|
82
|
+
private _search: ReadSelectedSearchDefinitionDto<TDto> | undefined;
|
|
83
|
+
private _text: string | undefined;
|
|
84
|
+
private _selection: TDto[] = [];
|
|
85
|
+
|
|
86
|
+
private _lastSearchedText: string | undefined = undefined;
|
|
87
|
+
private _currentAbortController?: AbortController;
|
|
88
|
+
private _fetchTimeout?: ReturnType<typeof setTimeout>;
|
|
89
|
+
|
|
90
|
+
constructor(options: SearchAdapterOptions<TDto>, client: IReadSelectedClient<any, any> | string) {
|
|
91
|
+
this._readClient = typeof client === 'string' ? new ApiReadControllerClient<any, any, any>(client) : client;
|
|
92
|
+
|
|
93
|
+
this.options = {
|
|
94
|
+
...DEFAULT_OPTIONS,
|
|
95
|
+
...options,
|
|
96
|
+
} as Required<SearchAdapterBaseOptions<TDto>>;
|
|
97
|
+
|
|
98
|
+
this._types = (options as { typesToSearch?: string[] }).typesToSearch;
|
|
99
|
+
this._search = this.options.defaultSearch;
|
|
100
|
+
this._text = this.options.defaultText;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// --- Getters ---
|
|
104
|
+
|
|
105
|
+
public get isLoading(): boolean {
|
|
106
|
+
return this._isLoading;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public get error(): string | undefined {
|
|
110
|
+
return this._error;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public get searchData(): readonly TDto[] {
|
|
114
|
+
return this._searchData;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public get totalItemCount(): number {
|
|
118
|
+
return this._totalItemCount;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public get types(): string[] | undefined {
|
|
122
|
+
return this._types;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public get search(): ReadSelectedSearchDefinitionDto<TDto> | undefined {
|
|
126
|
+
return this._search;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public get text(): string | undefined {
|
|
130
|
+
return this._text;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public get selection(): readonly TDto[] {
|
|
134
|
+
return this._selection;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public get searchTriggerMinLength(): number {
|
|
138
|
+
return this.options.searchTriggerMinLength;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// --- Mutations ---
|
|
142
|
+
|
|
143
|
+
public setTypes(types: string[] | undefined): void {
|
|
144
|
+
this._types = types;
|
|
145
|
+
this._lastSearchedText = undefined;
|
|
146
|
+
this.typesChanged.dispatchEvent(this._types);
|
|
147
|
+
this._triggerFetch();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public setSearch(search: ReadSelectedSearchDefinitionDto<TDto> | undefined): void {
|
|
151
|
+
this._search = search;
|
|
152
|
+
this._lastSearchedText = undefined;
|
|
153
|
+
this.searchChanged.dispatchEvent(this._search);
|
|
154
|
+
this._triggerFetch();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public setText(text: string | undefined): void {
|
|
158
|
+
if (this._text === text) return;
|
|
159
|
+
this._text = text;
|
|
160
|
+
this.textChanged.dispatchEvent(this._text);
|
|
161
|
+
this._triggerFetch();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public refresh(): void {
|
|
165
|
+
this._lastSearchedText = undefined;
|
|
166
|
+
this._triggerFetch();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// --- Selection ---
|
|
170
|
+
|
|
171
|
+
private _getItemKey(item: TDto): string {
|
|
172
|
+
const pk = this.options.primaryKey;
|
|
173
|
+
if (typeof pk === 'function') return pk(item);
|
|
174
|
+
return String((item as Record<string, unknown>)[pk]);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public selectionAdd(item: TDto): void {
|
|
178
|
+
const key = this._getItemKey(item);
|
|
179
|
+
if (this._selection.find(x => this._getItemKey(x) === key)) return;
|
|
180
|
+
if (this.options.multiselect) {
|
|
181
|
+
this._selection = [...this._selection, item];
|
|
182
|
+
} else {
|
|
183
|
+
this._selection = [item];
|
|
184
|
+
}
|
|
185
|
+
this._searchData = this._searchData.filter(d => this._getItemKey(d) !== key);
|
|
186
|
+
this.selectionChanged.dispatchEvent(this._selection);
|
|
187
|
+
this.searchDataChanged.dispatchEvent(this._searchData);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public selectionRemove(item: TDto): void {
|
|
191
|
+
const key = this._getItemKey(item);
|
|
192
|
+
this._selection = this._selection.filter(s => this._getItemKey(s) !== key);
|
|
193
|
+
this._searchData = [...this._searchData, item];
|
|
194
|
+
this.selectionChanged.dispatchEvent(this._selection);
|
|
195
|
+
this.searchDataChanged.dispatchEvent(this._searchData);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public selectionToggle(item: TDto): void {
|
|
199
|
+
const key = this._getItemKey(item);
|
|
200
|
+
if (this._selection.find(x => this._getItemKey(x) === key)) {
|
|
201
|
+
this.selectionRemove(item);
|
|
202
|
+
} else {
|
|
203
|
+
this.selectionAdd(item);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public selectionClear(): void {
|
|
208
|
+
this._selection = [];
|
|
209
|
+
this.selectionChanged.dispatchEvent(this._selection);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// --- Lifecycle ---
|
|
213
|
+
|
|
214
|
+
public destroy(): void {
|
|
215
|
+
this._cancelPendingRequests();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// --- Private ---
|
|
219
|
+
|
|
220
|
+
private _triggerFetch(): void {
|
|
221
|
+
const textLength = this._text?.length ?? 0;
|
|
222
|
+
if (textLength < this.options.searchTriggerMinLength) {
|
|
223
|
+
this._searchData = [];
|
|
224
|
+
this._lastSearchedText = undefined;
|
|
225
|
+
this._emitSearchState();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (this._text === this._lastSearchedText) return;
|
|
229
|
+
this._lastSearchedText = this._text;
|
|
230
|
+
|
|
231
|
+
this._searchData = [];
|
|
232
|
+
this._scheduleFetch();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private _scheduleFetch(): void {
|
|
236
|
+
this._isLoading = true;
|
|
237
|
+
this.isLoadingChanged.dispatchEvent(true);
|
|
238
|
+
if (this._fetchTimeout !== undefined) {
|
|
239
|
+
clearTimeout(this._fetchTimeout);
|
|
240
|
+
}
|
|
241
|
+
this._fetchTimeout = setTimeout(() => this._executeFetch(), this.options.searchDebounceDelay);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
private async _executeFetch(): Promise<void> {
|
|
245
|
+
let abortController: AbortController | undefined;
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
if (this._currentAbortController) {
|
|
249
|
+
try {
|
|
250
|
+
this._currentAbortController.abort();
|
|
251
|
+
} catch {
|
|
252
|
+
// Ignore abort errors
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
abortController = new AbortController();
|
|
256
|
+
this._currentAbortController = abortController;
|
|
257
|
+
|
|
258
|
+
const definition = this._buildDefinition();
|
|
259
|
+
const response = await this._readClient.readSelected(definition, abortController.signal);
|
|
260
|
+
|
|
261
|
+
if (!response.ok) {
|
|
262
|
+
if (response.error.code === ErrorCode.Aborted) return;
|
|
263
|
+
this._error = response.error.details ?? response.error.message ?? 'Unknown error';
|
|
264
|
+
} else {
|
|
265
|
+
this._error = undefined;
|
|
266
|
+
this._totalItemCount = response.metadata?.totalCount ?? response.result.length;
|
|
267
|
+
|
|
268
|
+
const selectedKeys = new Set(this._selection.map(item => this._getItemKey(item)));
|
|
269
|
+
this._searchData = response.result.filter((item: TDto) => !selectedKeys.has(this._getItemKey(item)));
|
|
270
|
+
}
|
|
271
|
+
} catch (error: unknown) {
|
|
272
|
+
console.error('Error fetching data:', error);
|
|
273
|
+
this._error = error instanceof Error ? error.message : 'Unknown error';
|
|
274
|
+
} finally {
|
|
275
|
+
if (abortController && this._currentAbortController === abortController) {
|
|
276
|
+
this._isLoading = false;
|
|
277
|
+
this._currentAbortController = undefined;
|
|
278
|
+
this.isLoadingChanged.dispatchEvent(false);
|
|
279
|
+
this.errorChanged.dispatchEvent(this._error);
|
|
280
|
+
this._emitSearchState();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private _emitSearchState(): void {
|
|
286
|
+
this.searchDataChanged.dispatchEvent(this._searchData);
|
|
287
|
+
this.totalItemCountChanged.dispatchEvent(this._totalItemCount);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private _buildDefinition(): ReadSelectedDefinitionDto<TDto> {
|
|
291
|
+
const definition: ReadSelectedDefinitionDto<TDto> = {};
|
|
292
|
+
|
|
293
|
+
// Pagination
|
|
294
|
+
if (this.options.limit !== undefined) {
|
|
295
|
+
definition.paginationDefinition = { skip: 0, limit: this.options.limit };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Ordering
|
|
299
|
+
if (this.options.ordering.length > 0) {
|
|
300
|
+
definition.orderingDefinition = {
|
|
301
|
+
order: this.options.ordering.map(o => ({
|
|
302
|
+
propertyPath: o.path.map(x => toPascalCase(x)) as PropertyPathDto,
|
|
303
|
+
direction: o.direction,
|
|
304
|
+
})),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Search definition (from options or setSearch)
|
|
309
|
+
if (this._search) {
|
|
310
|
+
definition.searchDefinition = { ...this._search };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Text search criterion
|
|
314
|
+
if (this._text) {
|
|
315
|
+
const textCriterion: ReadSelectedSearchPropertyDefinitionDto<TDto, keyof TDto> = {
|
|
316
|
+
propertyName: 'Name' as keyof TDto,
|
|
317
|
+
comparisonOperator: ReadSelectedComparisonOperator.IContains,
|
|
318
|
+
valueType: ReadSelectedPropertyType.String,
|
|
319
|
+
value: this._text,
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
if (!definition.searchDefinition) {
|
|
323
|
+
definition.searchDefinition = {
|
|
324
|
+
logicalOperator: ReadSelectedLogicalOperator.And,
|
|
325
|
+
propertyCriteria: [textCriterion],
|
|
326
|
+
} as ReadSelectedSearchDefinitionDto<TDto>;
|
|
327
|
+
} else {
|
|
328
|
+
definition.searchDefinition.propertyCriteria = [...(definition.searchDefinition.propertyCriteria || []), textCriterion];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Type criteria
|
|
333
|
+
if (this._types && this._types.length > 0) {
|
|
334
|
+
if (!definition.searchDefinition) {
|
|
335
|
+
definition.searchDefinition = {
|
|
336
|
+
logicalOperator: ReadSelectedLogicalOperator.And,
|
|
337
|
+
propertyCriteria: [],
|
|
338
|
+
} as ReadSelectedSearchDefinitionDto<TDto>;
|
|
339
|
+
}
|
|
340
|
+
if (!definition.searchDefinition.searches) {
|
|
341
|
+
definition.searchDefinition.searches = [];
|
|
342
|
+
}
|
|
343
|
+
definition.searchDefinition.searches.push({
|
|
344
|
+
logicalOperator: ReadSelectedLogicalOperator.Or,
|
|
345
|
+
propertyCriteria: this._types.map(
|
|
346
|
+
type =>
|
|
347
|
+
({
|
|
348
|
+
propertyName: 'Type',
|
|
349
|
+
comparisonOperator: ReadSelectedComparisonOperator.IEqual,
|
|
350
|
+
valueType: ReadSelectedPropertyType.String,
|
|
351
|
+
value: type,
|
|
352
|
+
}) as ReadSelectedSearchPropertyDefinitionDto<TDto, keyof TDto>,
|
|
353
|
+
),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return definition;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private _cancelPendingRequests(): void {
|
|
361
|
+
if (this._fetchTimeout !== undefined) {
|
|
362
|
+
clearTimeout(this._fetchTimeout);
|
|
363
|
+
this._fetchTimeout = undefined;
|
|
364
|
+
}
|
|
365
|
+
if (this._currentAbortController) {
|
|
366
|
+
try {
|
|
367
|
+
this._currentAbortController.abort();
|
|
368
|
+
} catch {
|
|
369
|
+
// Ignore abort errors
|
|
370
|
+
}
|
|
371
|
+
this._currentAbortController = undefined;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './crud-metadata-dto';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
1
|
+
export * from './read-metadata-dto';
|
|
2
|
+
export * from './read-selected-search-property-definition-dto';
|
|
3
|
+
export * from './read-selected-nested-criteria-dto';
|
|
4
|
+
export * from './read-selected-nested-collection-criteria-dto';
|
|
5
|
+
export * from './read-selected-ordering-definition-dto';
|
|
6
|
+
export * from './read-selected-ordering-property-definition-dto';
|
|
7
|
+
export * from './read-selected-pagination-definition-dto';
|
|
8
|
+
export * from './read-selected-definition-dto';
|
|
9
|
+
export * from './read-selected-search-definition-dto';
|
|
10
|
+
export * from './read-selected-search-definition-builder';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReadSelectedCollectionOperator, ReadSelectedComparisonOperator, ReadSelectedLogicalOperator, ReadSelectedPropertyType } from '@data';
|
|
2
|
-
import { ReadSelectedSearchDefinitionDto } from './
|
|
3
|
-
import { ReadSelectedSearchPropertyDefinitionDto } from './
|
|
4
|
-
import { ReadSelectedNestedCriteriaDto } from './
|
|
5
|
-
import { ReadSelectedNestedCollectionCriteriaDto } from './
|
|
2
|
+
import { ReadSelectedSearchDefinitionDto } from './read-selected-search-definition-dto';
|
|
3
|
+
import { ReadSelectedSearchPropertyDefinitionDto } from './read-selected-search-property-definition-dto';
|
|
4
|
+
import { ReadSelectedNestedCriteriaDto } from './read-selected-nested-criteria-dto';
|
|
5
|
+
import { ReadSelectedNestedCollectionCriteriaDto } from './read-selected-nested-collection-criteria-dto';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Builder class for constructing ReadSelectedSearchDefinitionDto with a fluent API.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './api-response-dto';
|
|
2
|
+
export * from './api-success-response-dto';
|
|
3
|
+
export * from './api-error-dto';
|
|
4
|
+
export * from './metadata-dto';
|
|
5
|
+
export * from './api-error-response-dto';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './read-selected-collection-operator';
|
|
2
|
+
export * from './read-selected-comparison-operator';
|
|
3
|
+
export * from './read-selected-logical-operator';
|
|
4
|
+
export * from './read-selected-ordering-direction';
|
|
5
|
+
export * from './read-selected-property-type';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './error-code';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './iidentifiable';
|
|
2
|
+
export * from './iidentifiable-secondary';
|
|
3
|
+
export * from './iconcurrency-safe';
|
|
4
|
+
export * from './icommon-identifiable';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './claim-dto';
|
|
2
|
+
export * from './user-dto';
|
|
3
|
+
export * from './user-info-dto';
|
|
4
|
+
export * from './role-dto';
|
|
5
|
+
export * from './role-with-claims-dto';
|
|
6
|
+
export * from './register-request-dto';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ClaimDto } from '@data';
|
|
2
|
-
import { IIdentifiable } from '@data';
|
|
1
|
+
import { ClaimDto, IIdentifiable, RoleWithClaimsDto } from '@data';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Represents a user with an identifier and email address.
|
|
@@ -8,11 +7,11 @@ import { IIdentifiable } from '@data';
|
|
|
8
7
|
*
|
|
9
8
|
* @param {TKey} id The unique identifier for the user.
|
|
10
9
|
* @param {string} email The email address associated with the user.
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {ClaimDto[]}
|
|
10
|
+
* @param {RoleWithClaimsDto[]} roles The roles (with their claims) associated with the user.
|
|
11
|
+
* @param {ClaimDto[]} userClaims The claims associated with the user.
|
|
13
12
|
*/
|
|
14
13
|
export type UserDto<TKey> = IIdentifiable<TKey> & {
|
|
15
14
|
email: string;
|
|
16
|
-
roles:
|
|
17
|
-
|
|
15
|
+
roles: RoleWithClaimsDto[];
|
|
16
|
+
userClaims: ClaimDto[];
|
|
18
17
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
2
|
import { ApiCrudControllerClient } from '.';
|
|
3
|
-
import { FetchHttpService } from '
|
|
3
|
+
import { FetchHttpService } from '@services';
|
|
4
4
|
|
|
5
5
|
type VehicleSlimDto = { id: number; brand: string; model: string };
|
|
6
6
|
|
|
@@ -1,11 +1,48 @@
|
|
|
1
|
-
import { apiInitializationService } from '
|
|
2
|
-
import { ApiErrorResponseDto, ApiResponseDto, ApiSuccessResponseDto, EmptyMetadataDto } from '
|
|
3
|
-
import { IIdentifiable } from '../../../data/api/interface';
|
|
4
|
-
import { IHttpService } from '../HttpService';
|
|
5
|
-
import { ApiReadControllerClient } from '../ApiReadControllerClient';
|
|
6
|
-
import { ErrorCode } from '@data';
|
|
1
|
+
import { apiInitializationService, ApiReadControllerClient, IApiReadControllerClient, IHttpService } from '@/services';
|
|
2
|
+
import { ApiErrorResponseDto, ApiResponseDto, ApiSuccessResponseDto, EmptyMetadataDto, ErrorCode, IIdentifiable } from '@data';
|
|
7
3
|
import { fail, ok } from '@utils/result';
|
|
8
4
|
|
|
5
|
+
function isAbortError(err: unknown): boolean {
|
|
6
|
+
return err instanceof DOMException && err.name === 'AbortError';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Client for creating a new entity in a CRUD controller.
|
|
11
|
+
*/
|
|
12
|
+
export interface ICreateClient<TKey, TResultDto extends IIdentifiable<TKey>, TInsertRequestDto> {
|
|
13
|
+
create(dto: TInsertRequestDto, signal?: AbortSignal): Promise<ApiResponseDto<TResultDto, EmptyMetadataDto>>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Client for updating an existing entity in a CRUD controller.
|
|
18
|
+
*/
|
|
19
|
+
export interface IUpdateClient<TKey, TResultDto extends IIdentifiable<TKey>, TUpdateRequestDto> {
|
|
20
|
+
update(id: TKey, dto: TUpdateRequestDto, signal?: AbortSignal): Promise<ApiResponseDto<TResultDto, EmptyMetadataDto>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Client for deleting an entity in a CRUD controller.
|
|
25
|
+
*/
|
|
26
|
+
export interface IDeleteClient<TKey> {
|
|
27
|
+
delete(id: TKey, signal?: AbortSignal): Promise<ApiResponseDto<undefined, EmptyMetadataDto>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Client for managing CRUD operations on a controller.
|
|
32
|
+
*/
|
|
33
|
+
export interface IApiCrudControllerClient<
|
|
34
|
+
TKey,
|
|
35
|
+
TResultDto extends IIdentifiable<TKey>,
|
|
36
|
+
TSingleResultDto extends IIdentifiable<TKey>,
|
|
37
|
+
TInsertRequestDto,
|
|
38
|
+
TUpdateRequestDto,
|
|
39
|
+
>
|
|
40
|
+
extends
|
|
41
|
+
IApiReadControllerClient<TKey, TResultDto, TSingleResultDto>,
|
|
42
|
+
ICreateClient<TKey, TSingleResultDto, TInsertRequestDto>,
|
|
43
|
+
IUpdateClient<TKey, TSingleResultDto, TUpdateRequestDto>,
|
|
44
|
+
IDeleteClient<TKey> {}
|
|
45
|
+
|
|
9
46
|
/**
|
|
10
47
|
* Generic API client for consuming any Cornerstone CrudController
|
|
11
48
|
*
|
|
@@ -21,7 +58,10 @@ export class ApiCrudControllerClient<
|
|
|
21
58
|
TSingleResultDto extends IIdentifiable<TKey>,
|
|
22
59
|
TInsertRequestDto,
|
|
23
60
|
TUpdateRequestDto,
|
|
24
|
-
>
|
|
61
|
+
>
|
|
62
|
+
extends ApiReadControllerClient<TKey, TResultDto, TSingleResultDto>
|
|
63
|
+
implements IApiCrudControllerClient<TKey, TResultDto, TSingleResultDto, TInsertRequestDto, TUpdateRequestDto>
|
|
64
|
+
{
|
|
25
65
|
/**
|
|
26
66
|
* Constructor
|
|
27
67
|
* @param baseControllerPath Base path to API controller
|
|
@@ -53,6 +93,11 @@ export class ApiCrudControllerClient<
|
|
|
53
93
|
|
|
54
94
|
return ok<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
|
|
55
95
|
} catch (err) {
|
|
96
|
+
if (isAbortError(err)) {
|
|
97
|
+
return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
|
|
98
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} as EmptyMetadataDto },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
56
101
|
console.error(err);
|
|
57
102
|
|
|
58
103
|
return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
|
|
@@ -89,6 +134,11 @@ export class ApiCrudControllerClient<
|
|
|
89
134
|
|
|
90
135
|
return ok<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
|
|
91
136
|
} catch (err) {
|
|
137
|
+
if (isAbortError(err)) {
|
|
138
|
+
return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
|
|
139
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} as EmptyMetadataDto },
|
|
140
|
+
});
|
|
141
|
+
}
|
|
92
142
|
console.error(err);
|
|
93
143
|
|
|
94
144
|
return fail<ApiSuccessResponseDto<TSingleResultDto, EmptyMetadataDto>, ApiErrorResponseDto>({
|
|
@@ -121,6 +171,11 @@ export class ApiCrudControllerClient<
|
|
|
121
171
|
|
|
122
172
|
return ok<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>(await res.json());
|
|
123
173
|
} catch (err) {
|
|
174
|
+
if (isAbortError(err)) {
|
|
175
|
+
return fail<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>({
|
|
176
|
+
error: { code: ErrorCode.Aborted, message: 'Request was aborted', metadata: {} as EmptyMetadataDto },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
124
179
|
console.error(err);
|
|
125
180
|
|
|
126
181
|
return fail<ApiSuccessResponseDto<undefined, EmptyMetadataDto>, ApiErrorResponseDto>({
|