chore(ftschema): mention `translate` is for tests purpose only

This commit is contained in:
Andrew Mayorov 2023-06-08 14:47:10 +03:00
parent e3c16be3c4
commit ce8cc05cc8
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 15 additions and 6 deletions

View File

@ -25,9 +25,12 @@
-export([schema/1]).
-export([translate/1]).
%% Utilities
-export([backend/1]).
%% Test-only helpers
-export([translate/1]).
-type json_value() ::
null
| boolean()
@ -327,11 +330,7 @@ converter(unicode_string) ->
ref(Ref) ->
ref(?MODULE, Ref).
translate(Conf) ->
[Root] = roots(),
RootRaw = atom_to_binary(Root),
ConfChecked = hocon_tconf:check_plain(?MODULE, #{RootRaw => Conf}, #{}, [Root]),
emqx_utils_maps:unsafe_atom_key_map(maps:get(RootRaw, ConfChecked)).
%% Utilities
-spec backend(emqx_config:config()) ->
{_Type :: atom(), emqx_config:config()}.
@ -342,3 +341,13 @@ backend(Config) ->
no_return().
emit_enabled(Type, BConf = #{enable := Enabled}) ->
Enabled andalso throw({Type, BConf}).
%% Test-only helpers
-spec translate(emqx_config:raw_config()) ->
emqx_config:config().
translate(Conf) ->
[Root] = roots(),
RootRaw = atom_to_binary(Root),
ConfChecked = hocon_tconf:check_plain(?MODULE, #{RootRaw => Conf}, #{}, [Root]),
emqx_utils_maps:unsafe_atom_key_map(maps:get(RootRaw, ConfChecked)).