index.ts 1.78 KB
import { EnrichmentCategoryComponentEnum } from '../../../enum/category';
import { useCreateNodeKey } from '../../../hook/useCreateNodeKey';
import type { NodeItemConfigType } from '../../../types/node';
import { RuleNodeTypeEnum } from '../../index.type';
import { useI18n } from '/@/hooks/web/useI18n';

const keys = useCreateNodeKey(EnrichmentCategoryComponentEnum.RELATED_DEVICE_ATTRIBUTES);

const { t } = useI18n(); // 加载国际化
export interface RelatedDeviceAttributesDataType {
  someConfiguration?: Recordable;
}

export const RelatedDeviceAttributesConfig: NodeItemConfigType = {
  ...keys,
  clazz: 'org.thingsboard.rule.engine.metadata.TbGetDeviceAttrNode',
  categoryType: RuleNodeTypeEnum.ENRICHMENT,
  name: t('designer_config.enrichments.index.relatedDeviceAttributes.name'),
  configurationDescriptor: {
    nodeDefinition: {
      details: t('designer_config.enrichments.index.relatedDeviceAttributes.details'),
      description: t('designer_config.enrichments.index.relatedDeviceAttributes.description'),
      inEnabled: true,
      outEnabled: true,
      relationTypes: ['Success', 'Failure'],
      customRelations: false,
      ruleChainNode: false,
      defaultConfiguration: {
        clientAttributeNames: [],
        sharedAttributeNames: [],
        serverAttributeNames: [],
        latestTsKeyNames: [],
        tellFailureIfAbsent: true,
        getLatestValueWithTs: false,
        deviceRelationsQuery: {
          direction: 'FROM',
          maxLevel: 1,
          relationType: 'Contains',
          deviceTypes: ['default'],
          fetchLastLevelOnly: false,
        },
      },
      uiResources: ['static/rulenode/rulenode-core-config.js'],
      configDirective: 'tbEnrichmentNodeDeviceAttributesConfig',
      icon: '',
      iconUrl: '',
      docUrl: '',
    },
  },
};