-module(atproto_codegen@plugins@decode_json). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/atproto_codegen/plugins/decode_json.gleam"). -export([plugin/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(false). -file("src/atproto_codegen/plugins/decode_json.gleam", 53). ?DOC(false). -spec render_unit( atproto_codegen@emit@zero:zero_plan(), atproto_codegen@config:config(), binary(), atproto_codegen@lower:codec_unit() ) -> binary(). render_unit(Plan, Config, Nsid, Unit) -> case Unit of {def_unit, Def} -> Name = atproto_codegen@naming:def_type_name( erlang:element(5, Config), Def ), Props = atproto_codegen@lower:emittable_properties(Def), atproto_codegen@emit@def:emit_decoder( Config, Nsid, Def, Name, Props ); {union_unit, Def@1, Field, Refs, Openness} -> Name@1 = atproto_codegen@emit@exprs:union_type_name( Config, Def@1, Field ), erlang:element( 4, atproto_codegen@emit@union:emit_union( Plan, Config, Nsid, Name@1, Refs, Openness ) ) end. -file("src/atproto_codegen/plugins/decode_json.gleam", 25). ?DOC(false). -spec emit(atproto_codegen@plugin:plugin_context()) -> {ok, list(atproto_codegen@plugin:output_file())} | {error, atproto_codegen@plugin:codegen_error()}. emit(Context) -> case atproto_codegen@emit@zero:compute(erlang:element(4, Context)) of {error, Err} -> {error, {plugin_failure, <<"decode-json"/utf8>>, atproto_codegen@emit@zero:error_to_string(Err)}}; {ok, Plan} -> _pipe = erlang:element(4, Context), _pipe@1 = gleam@list:filter_map( _pipe, fun(Lex) -> case atproto_codegen@lower:codec_units( erlang:element(4, Lex) ) of [] -> {error, nil}; Units -> {ok, {output_file, <<(atproto_codegen@naming:module_subpath( erlang:element( 5, erlang:element(2, Context) ), erlang:element(2, Lex) ))/binary, ".gleam"/utf8>>, gleam@list:map( Units, fun(_capture) -> render_unit( Plan, erlang:element(2, Context), erlang:element(2, Lex), _capture ) end )}} end end ), {ok, _pipe@1} end. -file("src/atproto_codegen/plugins/decode_json.gleam", 21). ?DOC(false). -spec plugin() -> atproto_codegen@plugin:plugin(). plugin() -> {plugin, <<"decode-json"/utf8>>, [], fun emit/1}.