Commit graph

139 commits

Author SHA1 Message Date
Zach Daniel
cb80df9ed8 test: test new default keyset pagination 2024-08-30 17:36:10 -04:00
Zach Daniel
7cf38273fa improvement: prevent unnecessary calls to Ash.load 2024-08-20 11:55:46 -04:00
Jonatan Männchen
e200b5b9d1
chore: Implement upsert_condition for bulk create (#1389) 2024-08-14 20:26:03 -04:00
Jonatan Männchen
93775109c7
improvement: Implement condition for upsert (#1386)
Resolves #1385
2024-08-13 19:19:13 -04:00
Zach Daniel
545b7a60f2
improvement: Optimize option validation with compile time validators (#1387)
A user doing load testing of their Ash application is seeing *wildly* significant performance improvements from this change. Unexpected, but naturally very pleasing.
2024-08-13 19:04:58 -04:00
Jonatan Männchen
68ef4d3144
chore: Dialyzer Fixes (#1374) 2024-08-08 09:07:18 -04:00
Jonatan Männchen
4efe51418e
improvement: Warn on bulk action return_stream? without any other return_*? options enabled. (#1370)
Resolves #1368
2024-08-07 14:51:15 -04:00
Zach Daniel
c4a910a5d1 improvement: support authorize_with option on Ash.read 2024-08-05 12:36:19 -04:00
Zach Daniel
de2b3d0d4e improvement: use :utc_datetime_usec for now() return type
fix: fix typespecs for `Ash.can?`
2024-07-25 16:26:11 -04:00
Zach Daniel
ed30dcf1dd fix: support skip_unknown_inputs on generic actions 2024-07-24 10:31:44 -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
98dec63998 fix: handle {record, action, input} types in Ash.can? 2024-07-23 09:32:48 -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
Torkild Gundersen Kjevik
ad6954aca8
improvement: add strict? option to Ash.Query.load (#1302)
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-07-11 09:34:30 -04:00
Zach Daniel
5727cc273f improvement: add mix ash.install
improvement: add `mix ash.gen.resource`
improvement: add `mix ash.gen.base_resource`
improvement: add `mix ash.gen.domain`
improvement: add `mix ash.extend`
2024-06-21 19:09:35 -04:00
Davide Briani
b256e1d8a3
test: Test loading paginated relationship when tenant is in primary key (#1252)
* Chore: test loading paginated relationship when tenant is in primary key

Ash is already able to load paginated relationships on multitenant
resources after a create or update action.
However this change specifically test the case of a many to many
relationship where the tenant is included in the primary key of the
joined resources.

Signed-off-by: Davide Briani <davide@briani.dev>

* fix: apply pagination at runtime for non lateral join queries
fix: consider multitenancy when checking if through-join is unique

---------

Signed-off-by: Davide Briani <davide@briani.dev>
Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-06-21 15:00:50 -04:00
Zach Daniel
cb29738927 chore: fix credo/build 2024-06-20 18:43:51 -04:00
Davide Briani
71d871b54a
Test loading relationships on multitenant resources after create or update (#1249)
* Chore: add tests on loading relationship on multitenant resource

Add tests to verify that relationships can be loaded on multitenant
resources after a create or update action.

Signed-off-by: Davide Briani <davide@briani.dev>

* fix: set tenant in ets data layer when generating aggregates

---------

Signed-off-by: Davide Briani <davide@briani.dev>
Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-06-20 16:46:29 -04:00
Zach Daniel
fa5d4a1a96 fix: don't start async limiter tasks if async is disabled
fix: properly set default timeout to `:infinity`

this avoids unnecessary processes starting when in the vast majority of cases some external thing is imposing a timeout.

fix: pass down `identity` when doing upserts, for new feature support
2024-06-17 10:56:48 -04:00
Jechol Lee
99cc10a9c7
Ash.can? to be boolean | no_return (#1210) 2024-05-29 07:32:32 -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
ab3786ebf6
feat(Ash.Reactor): Add bulk_update step type. (#1185) 2024-05-22 15:26:51 +12:00
Riccardo Binetti
65e9f51907
fix: don't require domain for empty stream bulk update and destroy (#1175)
It can't be extracted from an empty list, but it's not actually needed
2024-05-16 09:57:10 -05:00
Simon Nyström
f69e946a7d
docs: Fix incorrect documentation for Ash.create (#1157) 2024-05-13 09:11:13 -04:00
Zach Daniel
bc3463e135 docs: document Ash.can 2024-05-09 20:43:49 -04:00
Riccardo Binetti
5dfea1df9b
feat: add relationship pagination (#1050) 2024-05-04 05:56:46 -04:00
Frank Dugan III
09af174e4c
docs: clarify functionality of notify? and return_notifications? (#1099) 2024-05-02 11:36:28 -04:00
Frank Dugan III
718adb4891
feat: add read_action option to bulk actions (#1088) 2024-05-01 16:26:33 -04:00
Zach Daniel
fa7cfe5488 improvement: add pre_flight option for Ash.can 2024-04-30 22:55:32 -04:00
Pierre Le Gall
4ddc91be51
improvement: better create/update first argument (#1060)
* improvement: better create/update first argument

First argument of Ash.create (with a resource)
and Ash.update (with a record) no longer are in a tuple
with its arguments.

Arguments are moved in the input option.

* improvement: create/update params no more an opts

`Ash.create(User, %{name: "Yasmine"})` 🎉

* improvement: raise if changeset already validated

Raise an argument error for already validated changeset
when params are given.
2024-04-30 13:02:27 -04:00
Zach Daniel
c8e93877ea improvement: support atomics, update_query, destroy_query in ETS data layer 2024-04-25 22:18:54 -04:00
Pierre Le Gall
65e26cbc16
feat: Ash.create and Ash.update oneliner (#1055)
* feat: Ash.create and Ash.update oneliner

See #1015.

* fix: opts dispatch for create and update

* chore: shorten arguments by args
2024-04-24 15:28:26 -04:00
Zach Daniel
a147062523 improvement: add Ash.read_first 2024-04-16 18:19:20 +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
268b335946 chore: fix return type matching for generic actions 2024-04-10 13:58:22 -04:00
Zach Daniel
bae263ca12 improvement: support omitting generic action return types 2024-04-10 13:46:44 -04:00
Zach Daniel
5c70935f2f improvement: support skip_unknown_inputs in Ash.bulk_create
closes: #998
2024-04-09 13:24:03 -04:00
Zach Daniel
d2ea5bb108 docs: rewrite action docs
improvement: synthesize attributes from atomics for better notifications
2024-04-07 08:02:10 -04:00
Dmitry Maganov
5c600c1f42
fix: remove internal? and stacktraces? from common opts (#988) 2024-04-07 06:00:32 -04:00
Zach Daniel
8249b6cabd fix: include options for generic action code interfaces 2024-04-07 05:00:50 -04:00
Zach Daniel
a21341d880 chore: fix typespec for stream!/2 2024-04-02 22:04:49 -04:00
Zach Daniel
05f3de2538 fix: fix typespec for bulk_create 2024-04-01 17:19:23 -04:00
Zach Daniel
8f1217ea03 chore: fix typespecs and format 2024-03-29 16:55:32 -04:00
Zach Daniel
48d8181967 improvement: ignore unknown string-keyed inputs beginning with _
improvement: support requesting to ignore additional keys
2024-03-28 18:20:22 -04:00
Zach Daniel
f8384e44b5 improvement: add skip_unknown_inputs option, use it for embeds in unions 2024-03-28 16:29:37 -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
Zach Daniel
a06912f9b0 fix: honor not_found_error? in read_one
improvement: pass `tenant` to context in custom changes
improvement: `Ash.context_to_opts` now checks for a `tenant`
2024-02-16 17:56:23 -05:00
Jinkyou Son
2368fe82b6
improvement: Change typespec of tenant from String.t() to term() (#845) 2024-01-23 13:16:04 -05:00
Zach Daniel
072486bebd docs: revamp hexdocs
fix: use current read action for counting
2024-01-12 14:07:35 -05:00
Zach Daniel
2dbebf39e1 fix: properly determine resource from Ash.get!/2 2023-10-20 06:22:32 -04:00