-module(telega@flow@types). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/telega/flow/types.gleam"). -export_type([flow_state/0, flow_stack_frame/0, parallel_state/0, flow_instance/0, wait_result/0, flow_instance_row/0, flow_storage/1, step_config/3, conditional_transition/1, parallel_config/1, subflow_config/3, flow_action/1, flow/3, flow_trigger/0, inline_step/0, composed_step/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( " Shared type definitions for the flow system.\n" "\n" " This module contains all types used across flow submodules.\n" ). -type flow_state() :: {flow_state, binary(), gleam@dict:dict(binary(), binary()), list(binary()), list(flow_stack_frame()), gleam@option:option(parallel_state())}. -type flow_stack_frame() :: {flow_stack_frame, binary(), binary(), gleam@dict:dict(binary(), binary())}. -type parallel_state() :: {parallel_state, list(binary()), list(binary()), gleam@dict:dict(binary(), gleam@dict:dict(binary(), binary())), binary()}. -type flow_instance() :: {flow_instance, binary(), binary(), integer(), integer(), flow_state(), gleam@dict:dict(binary(), binary()), gleam@option:option(binary()), gleam@option:option(integer()), integer(), integer()}. -type wait_result() :: {text_input, binary()} | {bool_callback, boolean()} | {data_callback, binary()} | {photo_input, list(binary())} | {video_input, binary()} | {voice_input, binary()} | {audio_input, binary()} | {location_input, float(), float()} | {command_input, binary(), binary()} | pending. -type flow_instance_row() :: {flow_instance_row, binary(), binary(), integer(), integer(), binary(), gleam@dict:dict(binary(), binary()), gleam@dict:dict(binary(), binary()), gleam@option:option(binary()), gleam@option:option(integer()), integer(), integer()}. -type flow_storage(AITX) :: {flow_storage, fun((flow_instance()) -> {ok, nil} | {error, AITX}), fun((binary()) -> {ok, gleam@option:option(flow_instance())} | {error, AITX}), fun((binary()) -> {ok, nil} | {error, AITX}), fun((integer(), integer()) -> {ok, list(flow_instance())} | {error, AITX})}. -type step_config(AITY, AITZ, AIUA) :: {step_config, fun((telega@bot:context(AITZ, AIUA), flow_instance()) -> {ok, {telega@bot:context(AITZ, AIUA), flow_action(AITY), flow_instance()}} | {error, AIUA}), list(fun((telega@bot:context(AITZ, AIUA), flow_instance(), fun(() -> {ok, {telega@bot:context(AITZ, AIUA), flow_action(AITY), flow_instance()}} | {error, AIUA})) -> {ok, {telega@bot:context(AITZ, AIUA), flow_action(AITY), flow_instance()}} | {error, AIUA})), gleam@option:option(fun((telega@bot:context(AITZ, AIUA), flow_instance()) -> {ok, {telega@bot:context(AITZ, AIUA), flow_instance()}} | {error, AIUA})), gleam@option:option(fun((telega@bot:context(AITZ, AIUA), flow_instance()) -> {ok, {telega@bot:context(AITZ, AIUA), flow_instance()}} | {error, AIUA}))}. -type conditional_transition(AIUB) :: {conditional_transition, binary(), list({fun((flow_instance()) -> boolean()), AIUB}), AIUB}. -type parallel_config(AIUC) :: {parallel_config, binary(), list(AIUC), AIUC}. -type subflow_config(AIUD, AIUE, AIUF) :: {subflow_config, binary(), flow(gleam@dynamic:dynamic_(), AIUE, AIUF), AIUD, fun((flow_instance()) -> gleam@dict:dict(binary(), binary())), fun((gleam@dict:dict(binary(), binary()), flow_instance()) -> flow_instance())}. -type flow_action(AIUG) :: {next, AIUG} | {next_string, binary()} | back | {complete, gleam@dict:dict(binary(), binary())} | cancel | wait | wait_callback | {wait_with_timeout, integer()} | {wait_callback_with_timeout, integer()} | {go_to, AIUG} | {exit, gleam@option:option(gleam@dict:dict(binary(), binary()))} | {return_from_subflow, gleam@dict:dict(binary(), binary())} | {start_parallel, list(AIUG), AIUG} | {complete_parallel_step, AIUG, gleam@dict:dict(binary(), binary())} | {enter_subflow, binary(), gleam@dict:dict(binary(), binary())}. -type flow(AIUH, AIUI, AIUJ) :: {flow, binary(), gleam@dict:dict(binary(), step_config(AIUH, AIUI, AIUJ)), AIUH, fun((AIUH) -> binary()), fun((binary()) -> {ok, AIUH} | {error, nil}), flow_storage(AIUJ), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance()) -> {ok, telega@bot:context(AIUI, AIUJ)} | {error, AIUJ})), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance(), gleam@option:option(AIUJ)) -> {ok, telega@bot:context(AIUI, AIUJ)} | {error, AIUJ})), list(fun((telega@bot:context(AIUI, AIUJ), flow_instance(), fun(() -> {ok, {telega@bot:context(AIUI, AIUJ), flow_action(AIUH), flow_instance()}} | {error, AIUJ})) -> {ok, {telega@bot:context(AIUI, AIUJ), flow_action(AIUH), flow_instance()}} | {error, AIUJ})), list(conditional_transition(AIUH)), list(parallel_config(AIUH)), list(subflow_config(AIUH, AIUI, AIUJ)), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance()) -> {ok, {telega@bot:context(AIUI, AIUJ), flow_instance()}} | {error, AIUJ})), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance()) -> {ok, {telega@bot:context(AIUI, AIUJ), flow_instance()}} | {error, AIUJ})), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance()) -> {ok, telega@bot:context(AIUI, AIUJ)} | {error, AIUJ})), gleam@option:option(integer()), gleam@option:option(fun((telega@bot:context(AIUI, AIUJ), flow_instance()) -> {ok, telega@bot:context(AIUI, AIUJ)} | {error, AIUJ}))}. -type flow_trigger() :: {on_command, binary()} | {on_text, telega@router:pattern()} | {on_callback, telega@router:pattern()} | {on_filtered, telega@router:filter()} | on_photo | on_video | on_audio | on_voice | on_any_text. -type inline_step() :: {inline_step, binary()}. -type composed_step() :: {composed_flow_step, integer()} | composed_select_flow | composed_start_parallel | {composed_parallel_flow, integer()} | composed_merge_results.