| ... | ... | @@ -2,69 +2,12 @@ import { join } from 'path'; | 
| 2 | 2 | import { pathExists, ensureFile, writeFile } from 'fs-extra'; | 
| 3 | 3 | import { NodeItemConfigType } from '/@/views/rule/designer/types/node'; | 
| 4 | 4 | import { camelCase, upperFirst, snakeCase } from 'lodash-es'; | 
| 5 |  | -import { execSync } from 'child_process'; | 
| 6 |  | - | 
|  | 5 | +import { components } from './components'; | 
| 7 | 6 | type GroupNodeType = { [key: string]: NodeItemConfigType[] }; | 
| 8 | 7 |  | 
| 9 | 8 | const RULE_CHAIN_FILE_PATH = join(process.cwd(), '/src/views/rule/designer'); | 
| 10 | 9 |  | 
| 11 |  | -const list: NodeItemConfigType[] = [ | 
| 12 |  | -  { | 
| 13 |  | -    type: 'FLOW', | 
| 14 |  | -    scope: 'TENANT', | 
| 15 |  | -    name: 'acknowledge', | 
| 16 |  | -    clazz: 'org.thingsboard.rule.engine.flow.TbAckNode', | 
| 17 |  | -    configurationDescriptor: { | 
| 18 |  | -      nodeDefinition: { | 
| 19 |  | -        details: | 
| 20 |  | -          "After acknowledgement, the message is pushed to related rule nodes. Useful if you don't care what happens to this message next.", | 
| 21 |  | -        description: 'Acknowledges the incoming message', | 
| 22 |  | -        inEnabled: true, | 
| 23 |  | -        outEnabled: true, | 
| 24 |  | -        relationTypes: ['Success', 'Failure'], | 
| 25 |  | -        customRelations: false, | 
| 26 |  | -        ruleChainNode: false, | 
| 27 |  | -        defaultConfiguration: { | 
| 28 |  | -          version: 0, | 
| 29 |  | -        }, | 
| 30 |  | -        uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 31 |  | -        configDirective: 'tbNodeEmptyConfig', | 
| 32 |  | -        icon: '', | 
| 33 |  | -        iconUrl: '', | 
| 34 |  | -        docUrl: '', | 
| 35 |  | -      }, | 
| 36 |  | -    }, | 
| 37 |  | -    actions: null, | 
| 38 |  | -  }, | 
| 39 |  | -  { | 
| 40 |  | -    createdTime: 1668743016418, | 
| 41 |  | -    type: 'FILTER', | 
| 42 |  | -    scope: 'TENANT', | 
| 43 |  | -    name: 'check alarm status', | 
| 44 |  | -    clazz: 'org.thingsboard.rule.engine.filter.TbCheckAlarmStatusNode', | 
| 45 |  | -    configurationDescriptor: { | 
| 46 |  | -      nodeDefinition: { | 
| 47 |  | -        details: | 
| 48 |  | -          'If the alarm status matches the specified one - msg is success if does not match - msg is failure.', | 
| 49 |  | -        description: 'Checks alarm status.', | 
| 50 |  | -        inEnabled: true, | 
| 51 |  | -        outEnabled: true, | 
| 52 |  | -        relationTypes: ['True', 'False', 'Failure'], | 
| 53 |  | -        customRelations: false, | 
| 54 |  | -        ruleChainNode: false, | 
| 55 |  | -        defaultConfiguration: { | 
| 56 |  | -          alarmStatusList: ['ACTIVE_ACK', 'ACTIVE_UNACK'], | 
| 57 |  | -        }, | 
| 58 |  | -        uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 59 |  | -        configDirective: 'tbFilterNodeCheckAlarmStatusConfig', | 
| 60 |  | -        icon: '', | 
| 61 |  | -        iconUrl: '', | 
| 62 |  | -        docUrl: '', | 
| 63 |  | -      }, | 
| 64 |  | -    }, | 
| 65 |  | -    actions: null, | 
| 66 |  | -  }, | 
| 67 |  | -]; | 
|  | 10 | +const list: NodeItemConfigType[] = components; | 
| 68 | 11 |  | 
| 69 | 12 | const getCategoryConfigName = (name: string) => { | 
| 70 | 13 | return `${upperFirst(camelCase(name))}CategoryConfig`; | 
| ... | ... | @@ -158,8 +101,7 @@ ${importContent.join('')} | 
| 158 | 101 |  | 
| 159 | 102 | export const ${getCategoryConfigName(type)}: CategoryConfigType = { | 
| 160 | 103 | category: RuleNodeTypeEnum.${type.toUpperCase()}, | 
| 161 |  | -  backgroundColor: '#ede550', | 
| 162 |  | -  title: '筛选器', | 
|  | 104 | +  title: ${type}', | 
| 163 | 105 | icon: 'tabler:circuit-ground', | 
| 164 | 106 | description: '使用配置条件筛选传入消息', | 
| 165 | 107 | }; | 
| ... | ... | @@ -167,7 +109,7 @@ export const ${getCategoryConfigName(type)}: CategoryConfigType = { | 
| 167 | 109 | export const ${upperFirst(type.toLowerCase())}Components: NodeItemConfigType[] = [${components}]; | 
| 168 | 110 | `; | 
| 169 | 111 |  | 
| 170 |  | -  createFile(`./${upperFirst(type.toLowerCase())}/index.ts`, content); | 
|  | 112 | +  createFile(`./${upperFirst(type.toLowerCase())}/index.ts`, content, true); | 
| 171 | 113 |  | 
| 172 | 114 | return content; | 
| 173 | 115 | }; | 
| ... | ... | @@ -186,7 +128,7 @@ const generateNodeIndexFile = async (type: string, data: NodeItemConfigType) => | 
| 186 | 128 | const keys = useCreateNodeKey(${categoryEnumName}.${getEnumKeyName(data.name)}); | 
| 187 | 129 |  | 
| 188 | 130 | export interface ${upperFirst(camelCase(data.name))}DataType { | 
| 189 |  | - | 
|  | 131 | +    someConfiguration?: Recordable | 
| 190 | 132 | } | 
| 191 | 133 |  | 
| 192 | 134 | export const ${nodeConfigName}: NodeItemConfigType = { | 
| ... | ... | @@ -194,7 +136,6 @@ const generateNodeIndexFile = async (type: string, data: NodeItemConfigType) => | 
| 194 | 136 | clazz: '${data.clazz}', | 
| 195 | 137 | categoryType: RuleNodeTypeEnum.${type.toUpperCase()}, | 
| 196 | 138 | name: '${data.name}', | 
| 197 |  | -    backgroundColor: '#ede550', | 
| 198 | 139 | configurationDescriptor: ${JSON.stringify(data.configurationDescriptor, null, 2)} | 
| 199 | 140 | }; | 
| 200 | 141 | `; | 
| ... | ... | @@ -259,6 +200,11 @@ const generateNodeVueConfigFile = async (type: string, data: NodeItemConfigType) | 
| 259 | 200 | import { FormSchema } from '/@/components/Form'; | 
| 260 | 201 |  | 
| 261 | 202 | export const formSchemas: FormSchema[] = [ | 
|  | 203 | +    { | 
|  | 204 | +      field: NodeBindDataFieldEnum.NAME, | 
|  | 205 | +      component: 'Input', | 
|  | 206 | +      label: NodeBindDataFieldNameEnum.NAME, | 
|  | 207 | +    } | 
| 262 | 208 | ]; | 
| 263 | 209 | `; | 
| 264 | 210 |  | 
| ... | ... | @@ -305,7 +251,6 @@ const bootstrap = async () => { | 
| 305 | 251 | const groupData = groupByType(); | 
| 306 | 252 | await generateRuleNodeEnumFile(groupData); | 
| 307 | 253 | await generateCategoryEnumFile(groupData); | 
| 308 |  | - | 
| 309 | 254 | for (const type of Object.keys(groupData)) { | 
| 310 | 255 | const item = groupData[type]; | 
| 311 | 256 | await generateCategoryIndexFile(type, item); | 
| ... | ... | @@ -316,7 +261,6 @@ const bootstrap = async () => { | 
| 316 | 261 | await generateNodeVueTemplateFile(type, temp); | 
| 317 | 262 | } | 
| 318 | 263 | } | 
| 319 |  | -  execSync(`npx eslint --fix ${RULE_CHAIN_FILE_PATH}/*.{vue,ts}`); | 
| 320 | 264 | }; | 
| 321 | 265 |  | 
| 322 | 266 | bootstrap(); | 
... | ... |  |