Current section
Files
Jump to
Current section
Files
src/aion@manifest.erl
-module(aion@manifest).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/aion/manifest.gleam").
-export([to_json/1]).
-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(
" Canonical JSON wire form of a package's activity declarations.\n"
"\n"
" The typed Gleam declaration is the single source of truth (ADR-014). To\n"
" generate the activity plumbing, `aion generate` runs a small generated\n"
" export module that calls a package's `manifest()` function and prints\n"
" `to_json` of the result; the out-of-process Rust generator parses that JSON\n"
" to drive codegen. This module is the wire boundary between the typed source\n"
" and the generator — not a second authoring surface: the JSON is derived\n"
" from the declarations and never hand-written.\n"
).
-file("src/aion/manifest.gleam", 30).
-spec declaration_to_json(aion@activity:declaration()) -> gleam@json:json().
declaration_to_json(Declaration) ->
gleam@json:object(
[{<<"name"/utf8>>,
gleam@json:string(aion@activity:declaration_name(Declaration))},
{<<"tier"/utf8>>,
gleam@json:string(
aion@activity:tier_to_string(
aion@activity:declaration_tier(Declaration)
)
)},
{<<"input"/utf8>>,
gleam@json:string(
aion@activity:declaration_input_type(Declaration)
)},
{<<"output"/utf8>>,
gleam@json:string(
aion@activity:declaration_output_type(Declaration)
)}]
).
-file("src/aion/manifest.gleam", 23).
?DOC(
" Serialize a package's activity declarations to the canonical JSON array the\n"
" `aion generate` extractor consumes.\n"
"\n"
" Each declaration becomes one object carrying its `name`, `tier`, `input`\n"
" type, and `output` type, in declaration order. Order is load-bearing: it is\n"
" the order in which the generator emits wrappers, registration entries, and\n"
" the `workflow.toml` activities list, so a byte-identical round-trip depends\n"
" on it.\n"
).
-spec to_json(list(aion@activity:declaration())) -> binary().
to_json(Declarations) ->
_pipe = Declarations,
_pipe@1 = gleam@list:map(_pipe, fun declaration_to_json/1),
_pipe@2 = gleam@json:preprocessed_array(_pipe@1),
gleam@json:to_string(_pipe@2).