index.ts 1.78 KB
import { TransformationCategoryComponentEnum } from '../../../enum/category';
import { useCreateNodeKey } from '../../../hook/useCreateNodeKey';
import type { NodeItemConfigType } from '../../../types/node';
import { RuleNodeTypeEnum } from '../../index.type';

const keys = useCreateNodeKey(TransformationCategoryComponentEnum.CHANGE_ORIGINATOR);

export interface ChangeOriginatorDataType {
  someConfiguration?: Recordable;
}

export const ChangeOriginatorConfig: NodeItemConfigType = {
  ...keys,
  clazz: 'org.thingsboard.rule.engine.transform.TbChangeOriginatorNode',
  categoryType: RuleNodeTypeEnum.TRANSFORMATION,
  name: 'change originator',
  configurationDescriptor: {
    nodeDefinition: {
      details:
        'Related Entity found using configured relation direction and Relation Type. If multiple Related Entities are found, only first Entity is used as new Originator, other entities are discarded.<br/>Alarm Originator found only in case original Originator is <code>Alarm</code> entity.',
      description: 'Change Message Originator To Tenant/Customer/Related Entity/Alarm Originator',
      inEnabled: true,
      outEnabled: true,
      relationTypes: ['Success', 'Failure'],
      customRelations: false,
      ruleChainNode: false,
      defaultConfiguration: {
        originatorSource: 'CUSTOMER',
        relationsQuery: {
          direction: 'FROM',
          maxLevel: 1,
          filters: [
            {
              relationType: 'Contains',
              entityTypes: [],
            },
          ],
          fetchLastLevelOnly: false,
        },
      },
      uiResources: ['static/rulenode/rulenode-core-config.js'],
      configDirective: 'tbTransformationNodeChangeOriginatorConfig',
      icon: 'ic:outline-find-replace',
      iconUrl: '',
      docUrl: '',
    },
  },
};