2019-08-14 19:55:24 +03:00
|
|
|
///
|
|
|
|
|
/// Copyright © 2016-2019 The Thingsboard Authors
|
|
|
|
|
///
|
|
|
|
|
/// 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.
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
import {BaseData} from '@shared/models/base-data';
|
|
|
|
|
import {AssetId} from '@shared/models/id/asset-id';
|
|
|
|
|
import {TenantId} from '@shared/models/id/tenant-id';
|
|
|
|
|
import {CustomerId} from '@shared/models/id/customer-id';
|
|
|
|
|
import {RuleChainId} from '@shared/models/id/rule-chain-id';
|
|
|
|
|
import {RuleNodeId} from '@shared/models/id/rule-node-id';
|
2019-11-22 17:58:13 +02:00
|
|
|
import { ComponentDescriptor, ComponentType } from '@shared/models/component-descriptor.models';
|
|
|
|
|
import { EntityType, EntityTypeResource } from '@shared/models/entity-type.models';
|
2019-08-14 19:55:24 +03:00
|
|
|
|
2019-08-22 18:44:48 +03:00
|
|
|
export enum MsgDataType {
|
|
|
|
|
JSON = 'JSON',
|
|
|
|
|
TEXT = 'TEXT',
|
|
|
|
|
BINARY = 'BINARY'
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-14 19:55:24 +03:00
|
|
|
export interface RuleNodeConfiguration {
|
2019-11-22 17:58:13 +02:00
|
|
|
[key: string]: any;
|
2019-08-14 19:55:24 +03:00
|
|
|
// TODO:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface RuleNode extends BaseData<RuleNodeId> {
|
|
|
|
|
ruleChainId: RuleChainId;
|
|
|
|
|
type: string;
|
|
|
|
|
name: string;
|
|
|
|
|
debugMode: boolean;
|
|
|
|
|
configuration: RuleNodeConfiguration;
|
|
|
|
|
additionalInfo?: any;
|
|
|
|
|
}
|
2019-11-22 17:58:13 +02:00
|
|
|
|
|
|
|
|
export interface RuleNodeConfigurationDescriptor {
|
|
|
|
|
nodeDefinition: {
|
|
|
|
|
description: string;
|
|
|
|
|
details: string;
|
|
|
|
|
inEnabled: boolean;
|
|
|
|
|
outEnabled: boolean;
|
|
|
|
|
relationTypes: string[];
|
|
|
|
|
customRelations: boolean;
|
|
|
|
|
defaultConfiguration: any;
|
|
|
|
|
icon?: string;
|
|
|
|
|
iconUrl?: string;
|
|
|
|
|
uiResources?: string[];
|
|
|
|
|
uiResourceLoadError?: string;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum RuleNodeType {
|
|
|
|
|
FILTER = 'FILTER',
|
|
|
|
|
ENRICHMENT = 'ENRICHMENT',
|
|
|
|
|
TRANSFORMATION = 'TRANSFORMATION',
|
|
|
|
|
ACTION = 'ACTION',
|
|
|
|
|
EXTERNAL = 'EXTERNAL',
|
|
|
|
|
RULE_CHAIN = 'RULE_CHAIN',
|
|
|
|
|
UNKNOWN = 'UNKNOWN',
|
|
|
|
|
INPUT = 'INPUT'
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-12 19:55:17 +02:00
|
|
|
export const ruleNodeTypesLibrary = [
|
|
|
|
|
RuleNodeType.FILTER,
|
|
|
|
|
RuleNodeType.ENRICHMENT,
|
|
|
|
|
RuleNodeType.TRANSFORMATION,
|
|
|
|
|
RuleNodeType.ACTION,
|
|
|
|
|
RuleNodeType.EXTERNAL,
|
|
|
|
|
RuleNodeType.RULE_CHAIN,
|
|
|
|
|
];
|
|
|
|
|
|
2019-11-22 17:58:13 +02:00
|
|
|
export interface RuleNodeTypeDescriptor {
|
|
|
|
|
value: RuleNodeType;
|
|
|
|
|
name: string;
|
|
|
|
|
details: string;
|
|
|
|
|
nodeClass: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
special?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ruleNodeTypeDescriptors = new Map<RuleNodeType, RuleNodeTypeDescriptor>(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.FILTER,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.FILTER,
|
|
|
|
|
name: 'rulenode.type-filter',
|
|
|
|
|
details: 'rulenode.type-filter-details',
|
|
|
|
|
nodeClass: 'tb-filter-type',
|
|
|
|
|
icon: 'filter_list'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.ENRICHMENT,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.ENRICHMENT,
|
|
|
|
|
name: 'rulenode.type-enrichment',
|
|
|
|
|
details: 'rulenode.type-enrichment-details',
|
|
|
|
|
nodeClass: 'tb-enrichment-type',
|
|
|
|
|
icon: 'playlist_add'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.TRANSFORMATION,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.TRANSFORMATION,
|
|
|
|
|
name: 'rulenode.type-transformation',
|
|
|
|
|
details: 'rulenode.type-transformation-details',
|
|
|
|
|
nodeClass: 'tb-transformation-type',
|
|
|
|
|
icon: 'transform'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.ACTION,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.ACTION,
|
|
|
|
|
name: 'rulenode.type-action',
|
|
|
|
|
details: 'rulenode.type-action-details',
|
|
|
|
|
nodeClass: 'tb-action-type',
|
|
|
|
|
icon: 'flash_on'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.EXTERNAL,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.EXTERNAL,
|
|
|
|
|
name: 'rulenode.type-external',
|
|
|
|
|
details: 'rulenode.type-external-details',
|
|
|
|
|
nodeClass: 'tb-external-type',
|
|
|
|
|
icon: 'cloud_upload'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.RULE_CHAIN,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.RULE_CHAIN,
|
|
|
|
|
name: 'rulenode.type-rule-chain',
|
|
|
|
|
details: 'rulenode.type-rule-chain-details',
|
|
|
|
|
nodeClass: 'tb-rule-chain-type',
|
|
|
|
|
icon: 'settings_ethernet'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.INPUT,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.INPUT,
|
|
|
|
|
name: 'rulenode.type-input',
|
|
|
|
|
details: 'rulenode.type-input-details',
|
|
|
|
|
nodeClass: 'tb-input-type',
|
|
|
|
|
icon: 'input',
|
|
|
|
|
special: true
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
RuleNodeType.UNKNOWN,
|
|
|
|
|
{
|
|
|
|
|
value: RuleNodeType.UNKNOWN,
|
|
|
|
|
name: 'rulenode.type-unknown',
|
|
|
|
|
details: 'rulenode.type-unknown-details',
|
|
|
|
|
nodeClass: 'tb-unknown-type',
|
|
|
|
|
icon: 'help_outline'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export interface RuleNodeComponentDescriptor extends ComponentDescriptor {
|
|
|
|
|
type: RuleNodeType;
|
|
|
|
|
configurationDescriptor?: RuleNodeConfigurationDescriptor;
|
|
|
|
|
}
|