-module(aion@internal@ffi).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/aion/internal/ffi.gleam").
-export([dispatch_activity/3, await_activity_result/1, now/0, random/0, random_int/2, sleep/1, start_timer/2, cancel_timer/1, with_timeout/2, continue_as_new/1, receive_signal/2, send_signal/3, register_query/2, reply_query/2, reply_query_error/2, dispatch_query/2, query_recorded_observations/0, spawn_child/3, await_child/1, collect_all/2, collect_race/2, collect_map/2, testing_reset/0, testing_advance/1, testing_register_activity_mock/2, testing_register_child_mock/2, testing_clear_observations/0, testing_observations/0, register_query_handler/2, service_query/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(
" Raw bindings to the engine-provided `aion_flow_ffi` runtime module.\n"
"\n"
" This module is the only place in `aion_flow` that declares\n"
" `@external(erlang, \"aion_flow_ffi\", ...)` functions. The Erlang module\n"
" name is the engine's NIF registry namespace, registered by\n"
" `EngineBuilder::register_nifs` (AE-004) and resolved by beamr when a\n"
" compiled workflow is loaded inside an Aion engine runtime. The query\n"
" pump bindings at the bottom target `aion_flow_query_pump`, the plain\n"
" Erlang module shipped inside this package.\n"
"\n"
" `gleam build` type-checks these signatures with no engine present. The\n"
" author-facing modules wrap this type-erased string boundary with typed\n"
" codecs and domain values; this module intentionally exposes only raw names,\n"
" encoded payload/config strings, handles, and `Result(String, String)` error\n"
" seams.\n"
).
-file("src/aion/internal/ffi.gleam", 18).
-spec dispatch_activity(binary(), binary(), binary()) -> {ok, binary()} |
{error, binary()}.
dispatch_activity(Name, Input, Config) ->
aion_flow_ffi:dispatch_activity(Name, Input, Config).
-file("src/aion/internal/ffi.gleam", 25).
-spec await_activity_result(binary()) -> {ok, binary()} | {error, binary()}.
await_activity_result(Correlation_id) ->
aion_flow_ffi:await_activity_result(Correlation_id).
-file("src/aion/internal/ffi.gleam", 28).
-spec now() -> {ok, binary()} | {error, binary()}.
now() ->
aion_flow_ffi:now().
-file("src/aion/internal/ffi.gleam", 31).
-spec random() -> {ok, binary()} | {error, binary()}.
random() ->
aion_flow_ffi:random().
-file("src/aion/internal/ffi.gleam", 34).
-spec random_int(binary(), binary()) -> {ok, binary()} | {error, binary()}.
random_int(Min, Max) ->
aion_flow_ffi:random_int(Min, Max).
-file("src/aion/internal/ffi.gleam", 37).
-spec sleep(binary()) -> {ok, binary()} | {error, binary()}.
sleep(Duration) ->
aion_flow_ffi:sleep(Duration).
-file("src/aion/internal/ffi.gleam", 40).
-spec start_timer(binary(), binary()) -> {ok, binary()} | {error, binary()}.
start_timer(Timer_id, Duration) ->
aion_flow_ffi:start_timer(Timer_id, Duration).
-file("src/aion/internal/ffi.gleam", 43).
-spec cancel_timer(binary()) -> {ok, binary()} | {error, binary()}.
cancel_timer(Timer_id) ->
aion_flow_ffi:cancel_timer(Timer_id).
-file("src/aion/internal/ffi.gleam", 46).
-spec with_timeout(binary(), fun(() -> {ok, DVI} | {error, DVJ})) -> {ok,
{ok, DVI} | {error, DVJ}} |
{error, binary()}.
with_timeout(Duration, Operation) ->
aion_flow_ffi:with_timeout(Duration, Operation).
-file("src/aion/internal/ffi.gleam", 52).
-spec continue_as_new(binary()) -> {ok, nil} | {error, binary()}.
continue_as_new(Input) ->
aion_flow_ffi:continue_as_new(Input).
-file("src/aion/internal/ffi.gleam", 55).
-spec receive_signal(binary(), binary()) -> {ok, binary()} | {error, binary()}.
receive_signal(Name, Config) ->
aion_flow_ffi:receive_signal(Name, Config).
-file("src/aion/internal/ffi.gleam", 58).
-spec send_signal(binary(), binary(), binary()) -> {ok, binary()} |
{error, binary()}.
send_signal(Workflow_id, Name, Payload) ->
aion_flow_ffi:send_signal(Workflow_id, Name, Payload).
-file("src/aion/internal/ffi.gleam", 65).
-spec register_query(binary(), binary()) -> {ok, binary()} | {error, binary()}.
register_query(Name, Config) ->
aion_flow_ffi:register_query(Name, Config).
-file("src/aion/internal/ffi.gleam", 68).
-spec reply_query(binary(), binary()) -> {ok, binary()} | {error, binary()}.
reply_query(Query_id, Payload) ->
aion_flow_ffi:reply_query(Query_id, Payload).
-file("src/aion/internal/ffi.gleam", 71).
-spec reply_query_error(binary(), binary()) -> {ok, binary()} |
{error, binary()}.
reply_query_error(Query_id, Message) ->
aion_flow_ffi:reply_query_error(Query_id, Message).
-file("src/aion/internal/ffi.gleam", 77).
-spec dispatch_query(binary(), binary()) -> {ok, binary()} | {error, binary()}.
dispatch_query(Name, Config) ->
aion_flow_ffi:dispatch_query(Name, Config).
-file("src/aion/internal/ffi.gleam", 80).
-spec query_recorded_observations() -> {ok, binary()} | {error, binary()}.
query_recorded_observations() ->
aion_flow_ffi:query_recorded_observations().
-file("src/aion/internal/ffi.gleam", 83).
-spec spawn_child(binary(), binary(), binary()) -> {ok, binary()} |
{error, binary()}.
spawn_child(Workflow_name, Input, Config) ->
aion_flow_ffi:spawn_child(Workflow_name, Input, Config).
-file("src/aion/internal/ffi.gleam", 90).
-spec await_child(binary()) -> {ok, binary()} | {error, binary()}.
await_child(Child_id) ->
aion_flow_ffi:await_child(Child_id).
-file("src/aion/internal/ffi.gleam", 93).
-spec collect_all(binary(), list(binary())) -> {ok, binary()} |
{error, binary()}.
collect_all(Collection_id, Items) ->
aion_flow_ffi:collect_all(Collection_id, Items).
-file("src/aion/internal/ffi.gleam", 99).
-spec collect_race(binary(), list(binary())) -> {ok, binary()} |
{error, binary()}.
collect_race(Collection_id, Items) ->
aion_flow_ffi:collect_race(Collection_id, Items).
-file("src/aion/internal/ffi.gleam", 105).
-spec collect_map(binary(), list(binary())) -> {ok, binary()} |
{error, binary()}.
collect_map(Collection_id, Items) ->
aion_flow_ffi:collect_map(Collection_id, Items).
-file("src/aion/internal/ffi.gleam", 111).
-spec testing_reset() -> {ok, binary()} | {error, binary()}.
testing_reset() ->
aion_flow_ffi:testing_reset().
-file("src/aion/internal/ffi.gleam", 114).
-spec testing_advance(binary()) -> {ok, binary()} | {error, binary()}.
testing_advance(Duration) ->
aion_flow_ffi:testing_advance(Duration).
-file("src/aion/internal/ffi.gleam", 117).
-spec testing_register_activity_mock(
binary(),
fun((binary()) -> {ok, binary()} | {error, binary()})
) -> {ok, binary()} | {error, binary()}.
testing_register_activity_mock(Name, Handler) ->
aion_flow_ffi:testing_register_activity_mock(Name, Handler).
-file("src/aion/internal/ffi.gleam", 123).
-spec testing_register_child_mock(
binary(),
fun((binary()) -> {ok, binary()} | {error, binary()})
) -> {ok, binary()} | {error, binary()}.
testing_register_child_mock(Name, Handler) ->
aion_flow_ffi:testing_register_child_mock(Name, Handler).
-file("src/aion/internal/ffi.gleam", 129).
-spec testing_clear_observations() -> {ok, binary()} | {error, binary()}.
testing_clear_observations() ->
aion_flow_ffi:testing_clear_observations().
-file("src/aion/internal/ffi.gleam", 132).
-spec testing_observations() -> {ok, binary()} | {error, binary()}.
testing_observations() ->
aion_flow_ffi:testing_observations().
-file("src/aion/internal/ffi.gleam", 138).
?DOC(
" Store a query handler fun in the workflow process dictionary under the\n"
" engine-contract key `{aion_query_handler, Name}`. The Erlang helper owns\n"
" the raw process-dictionary types; Gleam code never touches them.\n"
).
-spec register_query_handler(
binary(),
fun((binary()) -> {ok, binary()} | {error, binary()})
) -> nil.
register_query_handler(Name, Handler) ->
aion_flow_query_pump:register(Name, Handler).
-file("src/aion/internal/ffi.gleam", 148).
?DOC(
" Service one query sentinel payload (the JSON binary after the\n"
" `aion_query:` prefix): run the registered handler under try/catch and\n"
" reply, converting a raise or a missing handler into a typed\n"
" `reply_query_error`. Never crashes the workflow process.\n"
).
-spec service_query(binary()) -> nil.
service_query(Sentinel_payload) ->
aion_flow_query_pump:service(Sentinel_payload).