index.ts 1.48 KB
import { TransformationCategoryComponentEnum } 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(TransformationCategoryComponentEnum.SCRIPT);

const { t } = useI18n(); // 加载国际化

export interface ScriptDataType {
  someConfiguration?: Recordable;
}

export const ScriptConfig: NodeItemConfigType = {
  ...keys,
  clazz: 'org.thingsboard.rule.engine.transform.TbTransformMsgNode',
  categoryType: RuleNodeTypeEnum.TRANSFORMATION,
  name: t('designer_config.transformations.index.script.name'),
  configurationDescriptor: {
    nodeDefinition: {
      details: t('designer_config.transformations.index.script.details'),
      description: t('designer_config.transformations.index.script.description'),
      inEnabled: true,
      outEnabled: true,
      relationTypes: ['Success', 'Failure'],
      customRelations: false,
      ruleChainNode: false,
      defaultConfiguration: {
        scriptLang: 'TBEL',
        jsScript: 'return {msg: msg, metadata: metadata, msgType: msgType};',
        tbelScript: 'return {msg: msg, metadata: metadata, msgType: msgType};',
      },
      uiResources: ['static/rulenode/rulenode-core-config.js'],
      configDirective: 'tbTransformationNodeScriptConfig',
      icon: '',
      iconUrl: '',
      docUrl: '',
    },
  },
};