index.ts
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.SCRIPT);
export interface ScriptDataType {
someConfiguration?: Recordable;
}
export const ScriptConfig: NodeItemConfigType = {
...keys,
clazz: 'org.thingsboard.rule.engine.transform.TbTransformMsgNode',
categoryType: RuleNodeTypeEnum.TRANSFORMATION,
name: 'script',
configurationDescriptor: {
nodeDefinition: {
details:
'JavaScript function receive 3 input parameters <br/> <code>metadata</code> - is a Message metadata.<br/><code>msg</code> - is a Message payload.<br/><code>msgType</code> - is a Message type.<br/>Should return the following structure:<br/><code>{ msg: <i style="color: #666;">new payload</i>,<br/>   metadata: <i style="color: #666;">new metadata</i>,<br/>   msgType: <i style="color: #666;">new msgType</i> }</code><br/>All fields in resulting object are optional and will be taken from original message if not specified.',
description: 'Change Message payload, Metadata or Message type using JavaScript',
inEnabled: true,
outEnabled: true,
relationTypes: ['Success', 'Failure'],
customRelations: false,
ruleChainNode: false,
defaultConfiguration: {
jsScript: 'return {msg: msg, metadata: metadata, msgType: msgType};',
},
uiResources: ['static/rulenode/rulenode-core-config.js'],
configDirective: 'tbTransformationNodeScriptConfig',
icon: '',
iconUrl: '',
docUrl: '',
},
},
};