-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/4, conditional_transition/1, parallel_config/1, subflow_config/4, flow_action/1, flow/4, 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(AUCH) :: {flow_storage, fun((flow_instance()) -> {ok, nil} | {error, AUCH}), fun((binary()) -> {ok, gleam@option:option(flow_instance())} | {error, AUCH}), fun((binary()) -> {ok, nil} | {error, AUCH}), fun((integer(), integer()) -> {ok, list(flow_instance())} | {error, AUCH})}. -type step_config(AUCI, AUCJ, AUCK, AUCL) :: {step_config, fun((telega@bot:context(AUCJ, AUCK, AUCL), flow_instance()) -> {ok, {telega@bot:context(AUCJ, AUCK, AUCL), flow_action(AUCI), flow_instance()}} | {error, AUCK}), list(fun((telega@bot:context(AUCJ, AUCK, AUCL), flow_instance(), fun(() -> {ok, {telega@bot:context(AUCJ, AUCK, AUCL), flow_action(AUCI), flow_instance()}} | {error, AUCK})) -> {ok, {telega@bot:context(AUCJ, AUCK, AUCL), flow_action(AUCI), flow_instance()}} | {error, AUCK})), gleam@option:option(fun((telega@bot:context(AUCJ, AUCK, AUCL), flow_instance()) -> {ok, {telega@bot:context(AUCJ, AUCK, AUCL), flow_instance()}} | {error, AUCK})), gleam@option:option(fun((telega@bot:context(AUCJ, AUCK, AUCL), flow_instance()) -> {ok, {telega@bot:context(AUCJ, AUCK, AUCL), flow_instance()}} | {error, AUCK}))}. -type conditional_transition(AUCM) :: {conditional_transition, binary(), list({fun((flow_instance()) -> boolean()), AUCM}), AUCM}. -type parallel_config(AUCN) :: {parallel_config, binary(), list(AUCN), AUCN}. -type subflow_config(AUCO, AUCP, AUCQ, AUCR) :: {subflow_config, binary(), flow(gleam@dynamic:dynamic_(), AUCP, AUCQ, AUCR), AUCO, fun((flow_instance()) -> gleam@dict:dict(binary(), binary())), fun((gleam@dict:dict(binary(), binary()), flow_instance()) -> flow_instance())}. -type flow_action(AUCS) :: {next, AUCS} | {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, AUCS} | {jump, AUCS} | {exit, gleam@option:option(gleam@dict:dict(binary(), binary()))} | {return_from_subflow, gleam@dict:dict(binary(), binary())} | {start_parallel, list(AUCS), AUCS} | {complete_parallel_step, AUCS, gleam@dict:dict(binary(), binary())} | {enter_subflow, binary(), gleam@dict:dict(binary(), binary())}. -type flow(AUCT, AUCU, AUCV, AUCW) :: {flow, binary(), gleam@dict:dict(binary(), step_config(AUCT, AUCU, AUCV, AUCW)), AUCT, fun((AUCT) -> binary()), fun((binary()) -> {ok, AUCT} | {error, nil}), flow_storage(AUCV), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance()) -> {ok, telega@bot:context(AUCU, AUCV, AUCW)} | {error, AUCV})), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance(), gleam@option:option(AUCV)) -> {ok, telega@bot:context(AUCU, AUCV, AUCW)} | {error, AUCV})), list(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance(), fun(() -> {ok, {telega@bot:context(AUCU, AUCV, AUCW), flow_action(AUCT), flow_instance()}} | {error, AUCV})) -> {ok, {telega@bot:context(AUCU, AUCV, AUCW), flow_action(AUCT), flow_instance()}} | {error, AUCV})), list(conditional_transition(AUCT)), list(parallel_config(AUCT)), list(subflow_config(AUCT, AUCU, AUCV, AUCW)), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance()) -> {ok, {telega@bot:context(AUCU, AUCV, AUCW), flow_instance()}} | {error, AUCV})), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance()) -> {ok, {telega@bot:context(AUCU, AUCV, AUCW), flow_instance()}} | {error, AUCV})), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance()) -> {ok, telega@bot:context(AUCU, AUCV, AUCW)} | {error, AUCV})), gleam@option:option(integer()), gleam@option:option(fun((telega@bot:context(AUCU, AUCV, AUCW), flow_instance()) -> {ok, telega@bot:context(AUCU, AUCV, AUCW)} | {error, AUCV}))}. -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.