diff --git a/apps/emqx_rule_engine/src/emqx_rule_engine_schema.erl b/apps/emqx_rule_engine/src/emqx_rule_engine_schema.erl index de04ee736..288eea233 100644 --- a/apps/emqx_rule_engine/src/emqx_rule_engine_schema.erl +++ b/apps/emqx_rule_engine/src/emqx_rule_engine_schema.erl @@ -22,7 +22,9 @@ -export([ namespace/0 , roots/0 - , fields/1]). + , fields/1 + , desc/1 + ]). -export([ validate_sql/1 ]). @@ -82,30 +84,7 @@ counter of the function output or the bridge channel will increase. fields("builtin_output_republish") -> [ {function, sc(republish, #{desc => "Republish the message as a new MQTT message"})} - , {args, sc(ref("republish_args"), - #{ desc => """ -The arguments of the built-in 'republish' output.
-We can use variables in the args.
- -The variables are selected by the rule. For example, if the rule SQL is defined as following: - - SELECT clientid, qos, payload FROM \"t/1\" - -Then there are 3 variables available: clientid, qos and -payload. And if we've set the args to: - - { - topic = \"t/${clientid}\" - qos = \"${qos}\" - payload = \"msg: ${payload}\" - } - -When the rule is triggered by an MQTT message with payload = \"hello\", qos = 1, -clientid = \"Steve\", the rule will republish a new MQTT message to topic \"t/Steve\", -payload = \"msg: hello\", and qos = 1. -""" - , default => #{} - })} + , {args, sc(ref("republish_args"), #{default => #{}})} ]; fields("builtin_output_console") -> @@ -178,6 +157,38 @@ of the rule, then the string \"undefined\" is used. })} ]. +desc("rule_engine") -> + "Configuration for the EMQX Rule Engine."; +desc("rules") -> + "Configuration for a rule."; +desc("builtin_output_republish") -> + "Configuration for a built-in output."; +desc("builtin_output_console") -> + "Configuration for a built-in output."; +desc("user_provided_function") -> + "Configuration for a built-in output."; +desc("republish_args") -> + "The arguments of the built-in 'republish' output.
" + "We can use variables in the args.
\n" + "The variables are selected by the rule. For example, if the rule SQL is defined as following:\n" + "\n" + " SELECT clientid, qos, payload FROM \"t/1\"\n" + "\n" + "Then there are 3 variables available: clientid, qos and\n" + "payload. And if we've set the args to:\n" + "\n" + " {\n" + " topic = \"t/${clientid}\"\n" + " qos = \"${qos}\"\n" + " payload = \"msg: ${payload}\"\n" + " }\n" + "\n" + "When the rule is triggered by an MQTT message with payload = \"hello\", qos = 1,\n" + "clientid = \"Steve\", the rule will republish a new MQTT message to topic \"t/Steve\",\n" + "payload = \"msg: hello\", and qos = 1."; +desc(_) -> + undefined. + rule_name() -> {"name", sc(binary(), #{ desc => "The name of the rule"