Commit graph

152 commits

Author SHA1 Message Date
Zach Daniel
e29897e1aa improvement: add system for action_select, which can limit selects from mutations 2024-09-10 15:08:08 -04:00
Zach Daniel
e33dc23a07 improvement: support select_by_default? flag on attributes 2024-09-10 13:24:56 -04:00
Zach Daniel
5fc5d32508 improvement: cache action known inputs individually
improvement: cache action required inputs all together
2024-08-19 21:49:34 -04:00
Zach Daniel
ce5c080492 improvement: don't start processes for single items in list
chore: add some benchmarks/flame files
2024-08-15 09:14:43 -04:00
Jonatan Männchen
93775109c7
improvement: Implement condition for upsert (#1386)
Resolves #1385
2024-08-13 19:19:13 -04:00
Zach Daniel
dc73c3a3d5 feat: add policy groups
Policy groups allow you to group policies by shared conditions.
This can help simplify the mental overhead of large sets of policies.

For example:

```elixir
policies do
  policy_group actor_attribute_equals(:role, :owner) do
    policy action_type(:read) do
      authorize_if expr(owner_id == ^actor(:id))
    end

    policy action_type([:create, :update, :destroy]) do
      forbid_if
      authorize_if expr(owner_id == ^actor(:id))
    end
  end
end
```
2024-08-09 16:48:54 -04:00
Zach Daniel
32c8da1f8d improvement: add :* as a valid value in skip_unknown_inputs
improvement: add `skip_unknown_inputs` to individual actions
improvement: add `skip_unknown_inputs` constraint to embedded resources
2024-07-23 12:51:11 -04:00
Zach Daniel
bad62c1e8a improvement: add authorize_with fallback option to bulk actions
improvement: store non-expr atomic changes in attributes for simplicity
fix: make `relating_to_actor` built-in-check aware of atomics

closes #1327
2024-07-22 10:03:14 -04:00
Tore Pettersen
37755a870b
feat: Allow field policies to hide private fields (#1289)
* Allow field policies to hide private fields

* Create option for how to handle private fields

* Improve docs
2024-07-15 08:16:52 -04:00
Alessio Montagnani
7f2e7d3ec1
improvement: bring uuid version 7 into the core (#1253) 2024-06-23 18:16:20 -04:00
Zach Daniel
dc94f3a743 improvement: support nils_distinct? on identities
improvement: support `where` option on `identities`
improvement: allow calculations in identity keys

closes #1001
closes #1182
2024-05-24 00:24:42 -04:00
Zach Daniel
feb187bdf6 improvement: add atomic_upgrade? flag to update/destroy actions
improvement: do not do atomic upgrade by default unless `require_atomic?` is `true`
improvement: allow configuring the read action used by atomic upgrades
2024-05-23 11:05:17 -04:00
Frank Dugan III
35961a793d
feat: leverage resource domain for eager/pre checking (#1040)
closes #1022
2024-04-22 17:15:27 -04:00
Riccardo Binetti
6d209e8836
feat: configurable multitenancy on read actions (#1030)
Allow making specific read actions able to optionally or totally bypass
multitenancy
2024-04-16 12:09:13 +01:00
Zach Daniel
bc69f904e2 improvement: support require_reference?: false on code interfaces
improvement: support `:filter` option on bulk create/destroy
2024-04-13 17:21:43 -04:00
Zach Daniel
5967ed3a48 improvement!: 3.0 (#955)
* improvement!: use `%Ash.NotSelected{}` for unselected values

* improvement!: default `require_atomic?` to `true`

* improvement!: raise errors on unknown generic action arguments

* improvement!: default bulk strategy to `:atomic`

* improvement!: warnings on `require_atomic?` `true` actions
improvement!: revise `Ash.NotSelected` to `Ash.NotLoaded`
improvement!: errors on unknown action inputs across the board

* doc: clarify wording in notifiers.md

closes #889

* improvement!: default `api.authorization.authorize` to `:by_default`

* improvement!: require the api when constructing changesets

this commit also fixes some work from prior commits around
the default value for the `authorize` option

* improvement!: code_interface.define_for -> code_interface.api

`code_interface.define_for` is now `code_interface.api`. Additionally, it is set automatically if the `api` option is specified on `use Ash.Resource`.

* improvement!: remove registries

* improvement!: pubsub notifier default to `previous_values?: false`
improvement!: requires_original_data? callback defaults to false

* improvement!: rename Ash.Calculation -> Ash.Resource.Calculation
improvement!: improve `Ash.Query.Calculation.new` signature
improvement!: anonymous function calculations now take lists and return lists
improvement!: make callback contexts into structs
improvement!: pass context to builtin lifecycle hook changes
improvement!: calculation arguments are now in the `arguments` key of the context

* chore: fix build

* improvement!: remove `aggregates` and `calculations` from `Filter.parse` and `Filter.parse_input`

* improvement: update spark to 2.0

* improvement!: make picosat_elixir optional with `simple_sat`

* improvement!: rename api to domain

* docs: add more info to upgrading guide

* docs: tweak docs formatting

* improvement!: remove `Ash.Changeset.new!`

* docs: update docs for `Ash.Changeset.new/1`

* improvement!: deprecate `private?: false` in favor of `public?: true`

* doc: add upgrade guide for private -> public

* improvement: update reactor to 3.0

* improvement!: default `default_accept` is now `[]`

* improvement!: `Ash.CiString.new/1` returns `nil` on `nil` input

* improvement!(Ash.Reactor): Improve integration with Ash 3.0 changes.

* improvement!: clean up and reorganize `Ash` functions

this is in preparation of deprecating the functions that are defined
on the api

improvement!: remove context-based functionality

* chore: update docs references from `Ash.Domain` to `Ash`

* chore: fix bad merge

* chore: fix context access in atomic changes

* improvement!: Deprecate calling functions on (domain) api in favor of `Ash`

* improvement!: add `attribute_public?` and update `attribute_writable?` behavior

* improvement!: update atomic behaviors, default to invalid

* chore: update downcase docs

* improvement!: changeset.filters -> changeset.filter

* improvement!: remove deprecated functions

* improvement!: remove and simplify `Ash.Filter.TemplateHelpers`

* improvement: import Ash.Expr in modules where it is used
improvement: require Ash.QUery in modules where it makes sense

* fix!: keyword lists are no longer special cased in ash expressions

* improvement: add structs for more context implementations

* chore: small tweaks, finish `:all` -> `:*` conversion

* chore: update DSL docs for multitenancy.global?

* improvement: ensure selects are applied on destroys
chore: remove TODOs

* chore: some docs changes

* improvement!: introduce strict mode to calculations

* chore: update tests

* improvement: support custom expressions

* docs: document custom expressions

* chore: fix and test custom expressions and function fragments
docs: update relevant docs w/ the changes

* improvement!: reverse order of before action & before transaction hooks

* improvement!: default read actions are now paginatable

* improvement!: require explicit accept lists in default actions

* chore: update docs

* improvement!: remove Ash.Flow and Ash.Engine

* chore: unlock unused deps

* chore: don't use unused variable

* chore: include ash flow change in upgrade guide

* improvement!: standardize various exception keys and names

* improvement!: use `Splode` for errors

* improvement: update upgrade guide to include Splode

* feat: code interface on the domain

* improvement: only require primary key if resource has actions or fields
improvement: only build schema if resource has actions or fields
improvement: verify primary key in its own verifier

* improvement: add `resource/1` builtin check

* improvement!: move simple_notifiers to an option instead of a DSL builder
improvement!: update spark for better autocomplete, configure autocomplete for key functions
docs: replace `an domain` with `a domain`

* improvement: better code interface documentation

* fix: set tenant on query so that root calles to Api.aggreagte work as expected (#929)

* chore: fixes from previous improvements

* chore: update splode

* chore: update splode

* improvement!: swap position of sort order and arguments in calculation sorting

* improvement!: add `include_nil?` aggregate option, and default it to `false`

* improvement: support notifiers within actions

* improvement: support specifying multiple filters

* improvement: add `sortable?` flags to all fields
improvement: support multiple filters on relationships

* improvement: support sensitive? on calculations and arguments

* improvement: validate resources in inputs to code interface

* chore: don't require explicit accept lists when using `default_accept :*`

* chore: update spark

* chore: update public attribute handling per 3.0

* improvement: update reactor and tests

* chore: better error message

* chore: fix rebase issue

* chore: handle merge issues
improvement: don't require domain on relationships if destination has domain

* improvement!: errors on unknown inputs for calculations

* improvement: always choose to cast atomic

* improvement: support casting some embeds atomically

* improvement: various 3.0 updates, documented in upgrade.md

* chore: Add failing tests for loads with with explicit domains. (#948)

Co-authored-by: James Harton <james@harton.nz>

* improvement: ensure non-static dynamic domains works

* improvement: add Ash.ToTenant protocol

* chore: add docs for no ToTenant option

* fix: properly construct new query in `build/3`

* chore: update simple_sat dependency

* chore: don't reselect when missing primary keys

* chore: remove IO.inspect

* chore: update spark

* chore: update spark

* improvement: use `Keyword.put_new` in `Ash.Context.to_opts` (#953)

* improvement: support bulk and atomic operations in code interfaces

---------

Co-authored-by: James Harton <james@harton.nz>
Co-authored-by: WIGGLES <55168935+WIGGLES-dev@users.noreply.github.com>
Co-authored-by: Dmitry Maganov <vonagam@gmail.com>
2024-03-27 16:31:59 -04:00
86d74ed789
feat(Ash.Reactor): Add a Reactor extension that makes working with resources easy. (#683)
* feat: Add `Ash.Reactor` with create support.

* improvement: Add `Ash.Reactor` update support.

* improvement: Add `Ash.Reactor` destroy support.

* improvement(Ash.Reactor): Support for transactional handling of notifications.

* improvement(Ash.Reactor): Add `read` and `get` steps.

* docs: Add the beginnings of a Reactor topic.

* improvement(Ash.Reactor): add support for generic actions.

* improvement: Add `undo` capability to `create` step.

* improvement: transaction and undo working.

* docs: Start documenting undo behaviour.

* chore: Update to Reactor 0.6.

* improvement: Automatically thread Ash tracers through Reactor.

* improvement(Ash.Reactor): Add undo to generic actions.

* docs: Improve reactor documentation.

* fix: Mimic copying `Ash.Notifier` seems to break the compiler for some reason.
2024-03-02 10:26:25 +13:00
Zach Daniel
3d30fd848f fix: ensure we retain the sort order of embedded resources
fixes #883
2024-02-13 13:55:07 -05:00
Dmitry Kulakov
5846b70315 feat: allow using custom delimiters for pubsub topics 2024-02-11 16:45:05 -04:00
Zach Daniel
d7721d9b1e chore: docs & formatter 2024-01-29 18:03:56 -05:00
Zach Daniel
d8c5b91090 chore: update spark.formatter 2024-01-12 09:00:46 -05:00
Zach Daniel
6b74072ada chore: formatter, cheat sheets, credo 2024-01-11 15:05:25 -05:00
Zach Daniel
955ba4987b chore: credo/tasks 2023-12-12 08:51:18 -05:00
James Harton
5f6920ef92
improvement: Allow resources to opt out of the primary key requirement. (#687)
This is experimental and will likely cause breakages. It's to support time series tables.
2023-09-06 10:21:42 +12:00
Zach Daniel
c5ea541b2d chore: rework atomics to atomic_update change and function
improvement: add `Ash.context_to_opts/1-2`
2023-08-29 14:39:38 -04:00
Zach Daniel
18cb24e7f7
improvement: implement atomics, expression-based changes (#682)
there is still a lot of potential work that needs to be on this front.
1. supporting atomics on create actions.
2. supporting atomics in upserts (this one may actually be much easier than the first one, for postgres specifically, due to ecto implementation details)
3. discovering places atomics can be more nicely integrated into existing changes, validations, policies
2023-08-28 16:05:26 -04:00
Zach Daniel
376ac3889f improvement: add plural_name
fix: handle atomic/string union type identifiers better
2023-08-14 14:09:08 -07:00
Zach Daniel
545a3b614f chore: run formatter 2023-08-04 18:45:20 -04:00
Zach Daniel
c0d8a86987 improvement: support resources directly in API modules
improvement: compile time warning on resources not detected in any apis
2023-07-13 01:38:21 -04:00
Zach Daniel
7114b5efbb improvement: exists type aggregate 2023-07-13 00:08:51 -04:00
Zach Daniel
8e12a14b25 improvement: add field_policy_bypass
fix: fix and improve policy breakdown logs
improvement: optimize field selection/loading when possible
2023-07-11 10:28:07 -04:00
Zach Daniel
5d20af82c3 improvement: support partial eager evaluation of functions 2023-06-27 19:11:03 -04:00
Zach Daniel
0b6d93c7c4 feat: add field_policies
see included documentation for more information on how field policies
work.
2023-06-22 14:00:11 -04:00
Zach Daniel
f04ffd5ebd improvement: support bulk upserts 2023-05-02 21:56:15 -04:00
Zach Daniel
49949ff58f improvement: initial support for basic actions 2023-05-02 01:54:53 -04:00
Zach Daniel
ed45a72ea6 improvement: add skip_global_validations? option for actions 2023-03-21 13:33:48 -04:00
Zach Daniel
8b722e6460 fix: various fixes in aggregate authorization behavior
improvement: add `:read_action` and `:authorize?` configurations for resource aggregates
2023-03-17 12:02:37 -04:00
Zach Daniel
9fa3e21515 chore: update .formatter.exs 2023-03-03 13:18:42 -05:00
Zach Daniel
e4004de15e improvement: support uniq? for count/list attributes 2023-02-09 15:42:43 -05:00
Zach Daniel
28b7def5c9 improvement: no async loads except when loading on initial data 2023-01-30 00:06:34 -05:00
Zach Daniel
70bc983b17 improvement: add Api.calculate/3 and define_calculation code interface builder 2023-01-08 23:39:12 -05:00
Zach Daniel
d41d195941 improvement: add simple_notifiers as a compile time optimization 2022-12-27 18:25:24 -05:00
Zach Daniel
34c33c7247 improvement: dep updates & new aggregate types avg/min/max/custom 2022-12-07 20:35:32 -05:00
Zach Daniel
82d3ec3946 improvement: add not_found_error? option to interface builder and when calling 2022-11-29 17:18:57 -05:00
Zach Daniel
a31da97d4c chore: properly set error vars and run spark.formatter 2022-11-02 21:29:12 -07:00
Zach Daniel
b20c4afd9b improvement: haltable flows, branch step type
fix: fix chart links rendering
2022-10-06 17:04:44 -04:00
Zach Daniel
978e3ef6f0 improvement: experimental support for calcualtions accepting expression arguments 2022-10-05 15:02:45 -04:00
Zach Daniel
0efad5ae4e improvement: various Ash.Flow improvements, including returning the new Ash.Flow.Result 2022-10-04 16:21:38 -04:00
James Harton
479b09951c
fix(Ash.Calculation): fix return type for load/3 callback. (#384) 2022-09-22 00:44:09 -04:00
Zach Daniel
1bb3468851 improvement: add tracing and telemetry 2022-08-28 19:27:44 -06:00