Autonoma.Types (Autonoma v0.2.8)

Copy Markdown View Source

Type definitions for the Autonoma SDK.

The SDK is factory-driven: every model is owned by a registered factory whose input is described by input_fields. There is no SQL introspection, no executor protocol, and no dialect machinery.

Summary

Types

auth_context()

@type auth_context() :: %{
  scope_value: String.t(),
  refs: %{required(String.t()) => [map()]}
}

create_op()

@type create_op() :: %{model: String.t(), fields: map(), temp_id: String.t()}

factory_context()

@type factory_context() :: %{
  refs: %{required(String.t()) => [map()]},
  scenario_name: String.t(),
  test_run_id: String.t()
}

factory_definition()

@type factory_definition() :: %{
  :create => (map(), factory_context() -> map()),
  :input_fields => [input_field()],
  optional(:teardown) => (map(), factory_context() -> any()) | nil,
  optional(:ref_fields) => [input_field()] | nil
}

factory_registry()

@type factory_registry() :: %{required(String.t()) => factory_definition()}

field_info()

@type field_info() :: %{
  name: String.t(),
  type: String.t(),
  is_required: boolean(),
  is_id: boolean(),
  has_default: boolean()
}

fk_edge()

@type fk_edge() :: %{
  from: String.t(),
  to: String.t(),
  local_field: String.t(),
  foreign_field: String.t(),
  nullable: boolean()
}

handler_config()

@type handler_config() :: %{
  :scope_field => String.t(),
  :shared_secret => String.t(),
  :signing_secret => String.t(),
  :auth => (map() | nil, map() -> map()),
  optional(:factories) => factory_registry(),
  optional(:allow_production) => boolean(),
  optional(:sdk) => map(),
  optional(:before_down) => (hook_context() -> any()),
  optional(:after_up) => (hook_context(), map() -> map())
}

handler_request()

@type handler_request() :: %{body: String.t(), headers: map()}

handler_response()

@type handler_response() :: %{status: integer(), body: map()}

hook_context()

@type hook_context() :: %{
  scenario_name: String.t(),
  refs: %{required(String.t()) => [map()]}
}

input_field()

@type input_field() :: %{
  name: String.t(),
  type:
    :string | :integer | :number | :boolean | :timestamp | :date | :uuid | :json,
  required: boolean()
}

model_info()

@type model_info() :: %{
  name: String.t(),
  table_name: String.t(),
  fields: [field_info()]
}

resolved_tree()

@type resolved_tree() :: %{
  ops: [create_op()],
  aliases: %{required(String.t()) => String.t()},
  alias_owner_model: %{required(String.t()) => String.t()},
  alias_dependencies: %{required(String.t()) => [String.t()]}
}

schema_info()

@type schema_info() :: %{
  models: [model_info()],
  edges: [fk_edge()],
  relations: [schema_relation()],
  scope_field: String.t()
}

schema_relation()

@type schema_relation() :: %{
  parent_model: String.t(),
  child_model: String.t(),
  parent_field: String.t(),
  child_field: String.t()
}