A declarative and extensible framework for building Elixir applications.
Find a file
Zach Daniel f6f5d194bf feat: freeform expressions
feat: validatiosn in actions

feat: query arguments

feat: add `Ash.Query.for_read/3`

feat: return changeset with API errors

feat: add case insensitive string `CiString`/`:ci_string`

feat: support `context/1` and `arg/1` in filter templates

feat: support targeting notifications with the `for` option

feat: add `ago/2` query function

feat: add basic arithmetic operators (+, *, -, /)

feat: `sensitive?` option for attributes

feat: `sensitive?` option for arguments

feat: `private` arguments, which can’t be set using `for_<action>`

feat: add `prevent_change` which will erase changes just before the changeset is committed

feat: add `match?` validation that supports a custom error message

feat: add `interval` type to support `ago/2` function

feat: add `url_encoded_binary` type

feat: add `function` type

improvement: `changing?` is now a validation

improvement: add `Transformer.get_persisted/3`

improvement: add `api` field to `Notification`

improvement: standardize errors, add `to_error_class`

improvement: use `Comp` everywhere

Improvement: use action on changeset if set by `for_<action_type>`

improvement: `action_failed?` field on change sets

improvement: remove ability for data layers to add operators (for now at least)

Improvement: Changeset.apply_attributes/2 now returns an error tuple

Improvement: add a bunch of new/informative errors

improvement: runtime filter now uses left join logic (a naive implementation of it)

improvement: support more filter templates in resources

Improvement: basic/naive type system for operators/functions

Fix: properly expand module aliases for options w/o compile time dependency

chore(engine): track changeset changes for the request with `manage_changeset?: true`
2021-01-21 15:22:50 -05:00
.github fix: update get-tag 2020-11-18 02:28:04 -05:00
config fix: remove test warning from git_ops 2020-06-01 22:09:26 -04:00
documentation feat: freeform expressions 2021-01-21 15:22:50 -05:00
lib feat: freeform expressions 2021-01-21 15:22:50 -05:00
logos chore: add cropped for header 2020-06-03 16:17:15 -04:00
test feat: freeform expressions 2021-01-21 15:22:50 -05:00
.check.exs chore: stop doing check-unused 2020-10-20 18:58:43 -04:00
.credo.exs feat: multitenancy! and tons of various fixes (#139) 2020-10-28 01:14:17 -04:00
.formatter.exs feat: freeform expressions 2021-01-21 15:22:50 -05:00
.gitignore fix: stop gitignoring the mnesia data layer 2020-06-30 09:58:04 -04:00
.tool-versions chore: fix CI + update docs 2020-10-09 10:13:44 -04:00
backers.md chore: update backers 2020-12-06 18:52:07 -05:00
CHANGELOG.md chore: release version v1.28.1 2021-01-12 15:41:47 -05:00
coveralls.json feat: Add pagination (#131) 2020-10-11 23:55:47 -04:00
FUNDING.yml fix: parse functions properly 2020-10-09 20:59:43 -04:00
LICENSE chore: Update License 2020-09-21 14:00:57 -04:00
mix.exs feat: freeform expressions 2021-01-21 15:22:50 -05:00
mix.lock feat: freeform expressions 2021-01-21 15:22:50 -05:00
README.md chore: release version v1.28.1 2021-01-12 15:41:47 -05:00

Logo Elixir CI License: MIT Coverage Status Hex version badge

Documentation

All documentation is contained in the generated hex documentation located here. Head there for installation and usage information. What follows is only a brief introduction to Ash.

ALPHA NOTICE

Ash is in alpha. The package version is 1.0.0+, and most of the time that means stable, but in this case it does not. The 2.0 release will be the stable release.

Upgrading to 1.27.0+

Typically a project wouldn't have breaking changes on 1.0.0+ that only change the minor version. See the ALPHA NOTICE above.

If you were using Ash prior to 1.27.0, a breaking change was made that will affect you if you are

  • using the postgres data layer
  • are using the create_timestamp or update_timestamp helpers

The default type for those attributes was changed to :utc_datetime_usec. If you don't want to change your data, you can update the type used by your timestamps like so:

created_timestamp :created_at, type: :utc_datetime
updated_timestamp :updated_at, type: :utc_datetime

If you want to change the data to leverage this new (more specific) type, you can create a migration like so:

mix ecto.gen.migration update_timestamp_types
# In the generated migration

def change do
  # do this for each table
  alter table(:table_name) do
    # do this for each timestamp you want to change on that table
    modify :attribute_name, :utc_datetime_usec, from: :utc_datetime
  end

  ...
end

Dependency

def deps do
  [
    {:ash, "~> 1.28.1"}
  ]
end

Links

Guides

Extensions

APIs

Authorizers

Datalayers

Introduction

Traditional MVC Frameworks (Rails, Django, .Net, Phoenix, etc) leave it up to the user to build the glue between requests for data (HTTP requests in various forms as well as server-side domain logic) and their respective ORMs. In that space, there is an incredible amount of boilerplate code that must get written from scratch for each application (authentication, authorization, sorting, filtering, sideloading relationships, serialization, etc).

Ash is an opinionated yet configurable framework designed to reduce boilerplate in an Elixir application. Ash does this by providing a layer of abstraction over your system's data layer(s) with Resources. It is designed to be used in conjunction with a phoenix application, or on its own.

To riff on a famous JRR Tolkien quote, a Resourceis "One Interface to rule them all, One Interface to find them" and will become an indispensable place to define contracts for interacting with data throughout your application.

To start using Ash, first declare your Resources using the Ash Resource DSL. You could technically stop there, and just leverage the Ash Elixir API to avoid writing boilerplate. More likely, you would use extensions like Ash.JsonApi or Ash.GraphQL with Phoenix to add external interfaces to those resources without having to write any extra code at all.

Ash is an open-source project and draws inspiration from similar ideas in other frameworks and concepts. The goal of Ash is to lower the barrier to adopting and using Elixir and Phoenix, and in doing so help these amazing communities attract new developers, projects, and companies.

Example Resource

defmodule Post do
  use Ash.Resource

  actions do
    read :default

    create :default
  end

  attributes do
    attribute :name, :string
  end

  relationships do
    belongs_to :author, Author
  end
end

See the getting started guide for more information.

For those looking to add ash extensions:

  • see Ash.Dsl.Extension for adding configuration.
  • If you are looking to write a new data source, also see the Ash.DataLayer documentation.
  • If you are looking to write a new authorizer, see Ash.Authorizer
  • If you are looking to write a "front end", something powered by Ash resources, a guide on building those kinds of tools is in the works.

Creating a new release of Ash

  • check out the repository locally
  • run mix git_ops.release (see git_ops documentation for more information)
  • check the changelog/new release number
  • push (with tags) and CI will automatically deploy the hex package