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

const keys = useCreateNodeKey(ActionCategoryComponentEnum.SAVE_TO_CUSTOM_TABLE);

export interface SaveToCustomTableDataType {
  someConfiguration?: Recordable;
}

export const SaveToCustomTableConfig: NodeItemConfigType = {
  ...keys,
  clazz: 'org.thingsboard.rule.engine.action.TbSaveToCustomCassandraTableNode',
  categoryType: RuleNodeTypeEnum.ACTION,
  name: 'save to custom table',
  configurationDescriptor: {
    nodeDefinition: {
      details:
        'Administrator should set the custom table name without prefix: <b>cs_tb_</b>. <br>Administrator can configure the mapping between the Message field names and Table columns name.<br><b>Note:</b>If the mapping key is <b>$entity_id</b>, that is identified by the Message Originator, then to the appropriate column name(mapping value) will be write the message originator id.<br><br>If specified message field does not exist or is not a JSON Primitive, the outbound message will be routed via <b>failure</b> chain, otherwise, the message will be routed via <b>success</b> chain.',
      description:
        'Node stores data from incoming Message payload to the Cassandra database into the predefined custom table that should have <b>cs_tb_</b> prefix, to avoid the data insertion to the common TB tables.<br><b>Note:</b> rule node can be used only for Cassandra DB.',
      inEnabled: true,
      outEnabled: true,
      relationTypes: ['Success', 'Failure'],
      customRelations: false,
      ruleChainNode: false,
      defaultConfiguration: {
        tableName: '',
        fieldsMapping: {
          '': '',
        },
      },
      uiResources: ['static/rulenode/rulenode-core-config.js'],
      configDirective: 'tbActionNodeCustomTableConfig',
      icon: 'material-symbols:file-upload',
      iconUrl: '',
      docUrl: '',
    },
  },
};