index.ts 1.57 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.CALCULATE_DELTA);

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

export const CalculateDeltaConfig: NodeItemConfigType = {
  ...keys,
  clazz: 'org.thingsboard.rule.engine.metadata.CalculateDeltaNode',
  categoryType: RuleNodeTypeEnum.ENRICHMENT,
  name: t('designer_config.enrichments.index.calculateDelta.name'),
  configurationDescriptor: {
    nodeDefinition: {
      details: t('designer_config.enrichments.index.calculateDelta.details'),
      description: t('designer_config.enrichments.index.calculateDelta.description'),
      inEnabled: true,
      outEnabled: true,
      relationTypes: ['Success', 'Failure', 'Other'],
      customRelations: false,
      ruleChainNode: false,
      defaultConfiguration: {
        inputValueKey: 'pulseCounter',
        outputValueKey: 'delta',
        useCache: true,
        addPeriodBetweenMsgs: false,
        periodValueKey: 'periodInMs',
        round: null,
        tellFailureIfDeltaIsNegative: true,
      },
      uiResources: ['static/rulenode/rulenode-core-config.js'],
      configDirective: 'tbEnrichmentNodeCalculateDeltaConfig',
      icon: '',
      iconUrl: '',
      docUrl: '',
    },
  },
};