calcinator v1.0.0 Calcinator

Converts actions from a controller or RPC server using JSONAPI formatted params to calls on a Calcinator.Resources module.

Summary

Types

Nested params format used by Ecto.Changeset.t

The name of the parameter that was used for the query and was not found

The raw request params that need to be validated as a JSONAPI document and converted to an Alembic.Document.t

A rendered JSONAPI document as a map

t()
  • authorization_module - The module that implements the Calcinator.Authorization behaviour
  • subject - the subject that is trying to do the action and needs to be authorized by authorization_module
  • target - the target of subject’s action

Types

association()
association() :: atom | list | map
insertable_params()
insertable_params() :: %{optional(String.t) => term}

Nested params format used by Ecto.Changeset.t.

parameter()
parameter() :: String.t

The name of the parameter that was used for the query and was not found.

params()
params() :: %{optional(String.t) => term}

The raw request params that need to be validated as a JSONAPI document and converted to an Alembic.Document.t

rendered()
rendered() :: map

A rendered JSONAPI document as a map

t()
t() :: %Calcinator{associations_by_include: term, authorization_module: module, ecto_schema_module: module, params: term, resources_module: term, subject: Calcinator.Authorization.subject, view_module: module}
  • authorization_module - The module that implements the Calcinator.Authorization behaviour
  • subject - the subject that is trying to do the action and needs to be authorized by authorization_module
  • target - the target of subject’s action

Functions

allow_sandbox_access(calcinator, params)
authorized(calcinator, arg2)
authorized(t, struct) :: struct
can(calcinator, action, target)
can(t, Calcinator.Authorization.action, Authorizaton.target) ::
  :ok |
  {:error, :unauthorized}
changeset(calcinator, updatable, updatable_params)
create(calcinator, params)
create(t, params) ::
  {:error, :unauthorized} |
  {:error, Alembic.Document.t} |
  {:error, Ecto.Changeset.t} |
  {:ok, rendered}
delete(calcinator, params)
delete(t, params) ::
  {:error, {:not_found, parameter}} |
  {:error, :unauthorized} |
  {:error, Ecto.Changeset.t} |
  :ok
get(resources_module, params, id_key, query_options)
get(module, params, id_key :: String.t, Resources.query_options) ::
  {:error, {:not_found, parameter} | :timeout | term} |
  {:ok, Ecto.Schema.t}
index(calcinator, params, map)
index(t, params, %{base_uri: URI.t}) ::
  {:error, :timeout} |
  {:error, :unauthorized} |
  {:error, Alembic.Document.t} |
  {:ok, rendered}
show(calcinator, map)
show(t, params) ::
  {:error, {:not_found, parameter}} |
  {:error, :unauthorized} |
  {:error, Alembic.Document.t} |
  {:ok, rendered}
show_relationship(calcinator, params, map)
show_relationship(t, params, map) ::
  {:error, {:not_found, parameter}} |
  {:error, :unauthorized} |
  {:ok, rendered}
update(calcinator, params)
update(t, params) ::
  {:error, :bad_gateway} |
  {:error, {:not_found, parameter}} |
  {:error, :unauthorized} |
  {:error, Alembic.Document.t} |
  {:error, Ecto.Changeset.t} |
  {:ok, rendered}
update_changeset(calcinator, changeset, params)
update_changeset(t, Ecto.Changeset.t, params) ::
  {:ok, Ecto.Schema.t} |
  {:error, Alembic.Document.t} |
  {:error, Ecto.Changeset.t} |
  {:error, :bad_gateway} |
  {:error, :not_found}