2019-09-19 20:10:52 +03:00
|
|
|
///
|
2024-01-09 10:46:16 +02:00
|
|
|
/// Copyright © 2016-2024 The Thingsboard Authors
|
2019-09-19 20:10:52 +03:00
|
|
|
///
|
|
|
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
/// you may not use this file except in compliance with the License.
|
|
|
|
|
/// You may obtain a copy of the License at
|
|
|
|
|
///
|
|
|
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
///
|
|
|
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
/// See the License for the specific language governing permissions and
|
|
|
|
|
/// limitations under the License.
|
|
|
|
|
///
|
|
|
|
|
|
2020-04-27 09:27:14 +03:00
|
|
|
import { EntityType } from '@shared/models/entity-type.models';
|
2019-10-10 13:00:29 +03:00
|
|
|
import { EntityId } from '@shared/models/id/entity-id';
|
2021-03-02 15:13:21 +02:00
|
|
|
import { EntitySearchDirection, RelationEntityTypeFilter } from '@shared/models/relation.models';
|
2020-06-19 18:13:57 +03:00
|
|
|
import { EntityFilter } from '@shared/models/query/query.models';
|
2019-09-19 20:10:52 +03:00
|
|
|
|
|
|
|
|
export enum AliasFilterType {
|
|
|
|
|
singleEntity = 'singleEntity',
|
|
|
|
|
entityList = 'entityList',
|
|
|
|
|
entityName = 'entityName',
|
2021-03-02 15:13:21 +02:00
|
|
|
entityType = 'entityType',
|
2019-09-19 20:10:52 +03:00
|
|
|
stateEntity = 'stateEntity',
|
|
|
|
|
assetType = 'assetType',
|
|
|
|
|
deviceType = 'deviceType',
|
2020-06-21 20:38:43 +03:00
|
|
|
edgeType = 'edgeType',
|
2019-09-19 20:10:52 +03:00
|
|
|
entityViewType = 'entityViewType',
|
2020-10-20 18:55:52 +03:00
|
|
|
apiUsageState = 'apiUsageState',
|
2019-09-19 20:10:52 +03:00
|
|
|
relationsQuery = 'relationsQuery',
|
|
|
|
|
assetSearchQuery = 'assetSearchQuery',
|
|
|
|
|
deviceSearchQuery = 'deviceSearchQuery',
|
2020-06-21 20:38:43 +03:00
|
|
|
edgeSearchQuery = 'edgeSearchQuery',
|
2019-09-19 20:10:52 +03:00
|
|
|
entityViewSearchQuery = 'entityViewSearchQuery'
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 15:44:31 +03:00
|
|
|
export const edgeAliasFilterTypes = new Array<string>(
|
|
|
|
|
AliasFilterType.edgeType,
|
|
|
|
|
AliasFilterType.edgeSearchQuery
|
|
|
|
|
);
|
|
|
|
|
|
2019-09-19 20:10:52 +03:00
|
|
|
export const aliasFilterTypeTranslationMap = new Map<AliasFilterType, string>(
|
|
|
|
|
[
|
|
|
|
|
[ AliasFilterType.singleEntity, 'alias.filter-type-single-entity' ],
|
|
|
|
|
[ AliasFilterType.entityList, 'alias.filter-type-entity-list' ],
|
|
|
|
|
[ AliasFilterType.entityName, 'alias.filter-type-entity-name' ],
|
2021-03-02 15:13:21 +02:00
|
|
|
[ AliasFilterType.entityType, 'alias.filter-type-entity-type' ],
|
2019-09-19 20:10:52 +03:00
|
|
|
[ AliasFilterType.stateEntity, 'alias.filter-type-state-entity' ],
|
|
|
|
|
[ AliasFilterType.assetType, 'alias.filter-type-asset-type' ],
|
|
|
|
|
[ AliasFilterType.deviceType, 'alias.filter-type-device-type' ],
|
2020-06-21 20:38:43 +03:00
|
|
|
[ AliasFilterType.edgeType, 'alias.filter-type-edge-type' ],
|
2019-09-19 20:10:52 +03:00
|
|
|
[ AliasFilterType.entityViewType, 'alias.filter-type-entity-view-type' ],
|
2020-10-20 18:55:52 +03:00
|
|
|
[ AliasFilterType.apiUsageState, 'alias.filter-type-apiUsageState' ],
|
2019-09-19 20:10:52 +03:00
|
|
|
[ AliasFilterType.relationsQuery, 'alias.filter-type-relations-query' ],
|
|
|
|
|
[ AliasFilterType.assetSearchQuery, 'alias.filter-type-asset-search-query' ],
|
|
|
|
|
[ AliasFilterType.deviceSearchQuery, 'alias.filter-type-device-search-query' ],
|
2020-06-21 20:38:43 +03:00
|
|
|
[ AliasFilterType.edgeSearchQuery, 'alias.filter-type-edge-search-query' ],
|
2019-09-19 20:10:52 +03:00
|
|
|
[ AliasFilterType.entityViewSearchQuery, 'alias.filter-type-entity-view-search-query' ]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface SingleEntityFilter {
|
|
|
|
|
singleEntity?: EntityId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EntityListFilter {
|
|
|
|
|
entityType?: EntityType;
|
2019-09-19 20:10:52 +03:00
|
|
|
entityList?: string[];
|
2019-10-10 13:00:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EntityNameFilter {
|
|
|
|
|
entityType?: EntityType;
|
2019-09-19 20:10:52 +03:00
|
|
|
entityNameFilter?: string;
|
2019-10-10 13:00:29 +03:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 15:13:21 +02:00
|
|
|
export interface EntityTypeFilter {
|
|
|
|
|
entityType?: EntityType;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface StateEntityFilter {
|
|
|
|
|
stateEntityParamName?: string;
|
|
|
|
|
defaultStateEntity?: EntityId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AssetTypeFilter {
|
2023-03-03 13:44:12 +02:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
*/
|
|
|
|
|
assetType?: string;
|
2023-02-01 17:21:04 +02:00
|
|
|
assetTypes?: string[];
|
2019-10-10 13:00:29 +03:00
|
|
|
assetNameFilter?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface DeviceTypeFilter {
|
2023-03-03 13:44:12 +02:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
*/
|
|
|
|
|
deviceType?: string;
|
2023-02-01 17:21:04 +02:00
|
|
|
deviceTypes?: string[];
|
2019-10-10 13:00:29 +03:00
|
|
|
deviceNameFilter?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 20:38:43 +03:00
|
|
|
export interface EdgeTypeFilter {
|
2023-03-03 13:44:12 +02:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
*/
|
|
|
|
|
edgeType?: string;
|
2023-02-01 17:21:04 +02:00
|
|
|
edgeTypes?: string[];
|
2020-06-21 20:38:43 +03:00
|
|
|
edgeNameFilter?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface EntityViewFilter {
|
2023-03-03 13:44:12 +02:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
*/
|
|
|
|
|
entityViewType?: string;
|
2023-02-01 17:21:04 +02:00
|
|
|
entityViewTypes?: string[];
|
2019-10-10 13:00:29 +03:00
|
|
|
entityViewNameFilter?: string;
|
|
|
|
|
}
|
2019-09-19 20:10:52 +03:00
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface RelationsQueryFilter {
|
|
|
|
|
rootStateEntity?: boolean;
|
|
|
|
|
stateEntityParamName?: string;
|
|
|
|
|
defaultStateEntity?: EntityId;
|
|
|
|
|
rootEntity?: EntityId;
|
|
|
|
|
direction?: EntitySearchDirection;
|
2021-03-02 15:13:21 +02:00
|
|
|
filters?: Array<RelationEntityTypeFilter>;
|
2019-10-10 13:00:29 +03:00
|
|
|
maxLevel?: number;
|
2020-02-21 19:04:49 +02:00
|
|
|
fetchLastLevelOnly?: boolean;
|
2019-10-10 13:00:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EntitySearchQueryFilter {
|
|
|
|
|
rootStateEntity?: boolean;
|
|
|
|
|
stateEntityParamName?: string;
|
|
|
|
|
defaultStateEntity?: EntityId;
|
|
|
|
|
rootEntity?: EntityId;
|
|
|
|
|
relationType?: string;
|
|
|
|
|
direction?: EntitySearchDirection;
|
2020-02-21 19:04:49 +02:00
|
|
|
maxLevel?: number;
|
|
|
|
|
fetchLastLevelOnly?: boolean;
|
2019-10-10 13:00:29 +03:00
|
|
|
}
|
|
|
|
|
|
2023-02-02 16:55:27 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
2020-10-20 18:55:52 +03:00
|
|
|
export interface ApiUsageStateFilter {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface AssetSearchQueryFilter extends EntitySearchQueryFilter {
|
|
|
|
|
assetTypes?: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface DeviceSearchQueryFilter extends EntitySearchQueryFilter {
|
|
|
|
|
deviceTypes?: string[];
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-21 20:38:43 +03:00
|
|
|
export interface EdgeSearchQueryFilter extends EntitySearchQueryFilter {
|
|
|
|
|
edgeTypes?: string[];
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 13:00:29 +03:00
|
|
|
export interface EntityViewSearchQueryFilter extends EntitySearchQueryFilter {
|
|
|
|
|
entityViewTypes?: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type EntityFilters =
|
|
|
|
|
SingleEntityFilter &
|
|
|
|
|
EntityListFilter &
|
|
|
|
|
EntityNameFilter &
|
2021-03-02 15:13:21 +02:00
|
|
|
EntityTypeFilter &
|
2019-10-10 13:00:29 +03:00
|
|
|
StateEntityFilter &
|
|
|
|
|
AssetTypeFilter &
|
|
|
|
|
DeviceTypeFilter &
|
2020-06-21 20:38:43 +03:00
|
|
|
EdgeTypeFilter &
|
2019-10-10 13:00:29 +03:00
|
|
|
EntityViewFilter &
|
|
|
|
|
RelationsQueryFilter &
|
|
|
|
|
AssetSearchQueryFilter &
|
|
|
|
|
DeviceSearchQueryFilter &
|
2020-10-20 18:55:52 +03:00
|
|
|
EntityViewSearchQueryFilter &
|
2020-12-07 10:46:15 +02:00
|
|
|
EntitySearchQueryFilter &
|
|
|
|
|
EdgeSearchQueryFilter;
|
2019-10-10 13:00:29 +03:00
|
|
|
|
|
|
|
|
export interface EntityAliasFilter extends EntityFilters {
|
|
|
|
|
type?: AliasFilterType;
|
2019-10-11 19:22:03 +03:00
|
|
|
resolveMultiple?: boolean;
|
2019-09-19 20:10:52 +03:00
|
|
|
}
|
|
|
|
|
|
2019-10-31 10:06:57 +02:00
|
|
|
export interface EntityAliasInfo {
|
2019-09-19 20:10:52 +03:00
|
|
|
alias: string;
|
|
|
|
|
filter: EntityAliasFilter;
|
2019-11-08 14:17:15 +02:00
|
|
|
[key: string]: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AliasesInfo {
|
|
|
|
|
datasourceAliases: {[datasourceIndex: number]: EntityAliasInfo};
|
|
|
|
|
targetDeviceAliases: {[targetDeviceAliasIndex: number]: EntityAliasInfo};
|
2019-10-31 10:06:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EntityAlias extends EntityAliasInfo {
|
|
|
|
|
id: string;
|
2019-09-19 20:10:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EntityAliases {
|
|
|
|
|
[id: string]: EntityAlias;
|
|
|
|
|
}
|
2019-10-10 13:00:29 +03:00
|
|
|
|
|
|
|
|
export interface EntityAliasFilterResult {
|
|
|
|
|
stateEntity: boolean;
|
2020-06-19 18:13:57 +03:00
|
|
|
entityFilter: EntityFilter;
|
2019-10-10 13:00:29 +03:00
|
|
|
entityParamName?: string;
|
|
|
|
|
}
|