Commit graph

150 commits

Author SHA1 Message Date
Zach Daniel
b841eaf54c chore: add tests for accept & some opts improvements 2024-08-21 11:58:11 -04:00
Zach Daniel
d593e3cee9 improvement: error at compile for bypasses that will have no effect
chore: remove unused `checks` field from `%Ash.Policy.Authorizer.Policy{}`
2024-08-20 21:30:55 -04:00
Zach Daniel
a43624c9f3
improvement: add cascade update built in change (#1398)
---------

Co-authored-by: Alykhan Jetha <aj@marketcircle.com>
2024-08-19 11:34:38 -04:00
m0rt3nlund
4508b439a5
improvement: Add defaults and typespec to resulting Resource struct (#1364)
* improvement: Add typespec to resource if it doesn't exist

---------

Co-authored-by: morten.lund@maskon.no <morten.lund@maskon.no>
Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-08-05 10:35:17 -04:00
Alessio Montagnani
7f2e7d3ec1
improvement: bring uuid version 7 into the core (#1253) 2024-06-23 18:16:20 -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
Zach Daniel
1fe799c7bb chore: fix match eror in changeset hook runner 2024-06-15 11:31:39 -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
Riccardo Binetti
9fc5ddfe2b
fix: make Ash.Resource.Validation.Changing work correctly in atomics (#1178)
- Use the correct option key to select the field
- Fail without hitting the data layer if the attribute is not changing
- Allow checking relationships like the non-atomic counterpart
2024-05-16 18:15:35 -05:00
Zach Daniel
23d7479417 fix: handle nil notification results better
fix: don't emit after batch notifications if `notify?: false`
2024-05-16 11:19:24 -05:00
Rebecca Le
619a0d61ad
bug: Add more failing tests around cascade_destroy functionality (#1173)
Issues occur when there is no data to cascade destroy, or notifications are requested but none are returned
2024-05-16 09:54:22 -05:00
12de8d19a5 fix(cascade_destroy): Always return and explicitly dispatch notifications.
**note** `notify?` option is now `return_notifications?`.
2024-05-13 09:28:20 +12:00
70c1a688f8 feat: Add cascade_destroy to builtin changes. 2024-05-13 09:28:20 +12:00
Zach Daniel
b48c989b15 fix: don't check required belongs to fields until after setting them in bulk creation
docs: fix doc links for code interface guide

fixes #1154
2024-05-12 14:12:24 -04:00
Jinkyou Son
1acbce4ebb
improvement: Treat asterisk as a single arguemnt in accept (#1062) 2024-04-26 03:26:15 -04:00
Zach Daniel
c8e93877ea improvement: support atomics, update_query, destroy_query in ETS data layer 2024-04-25 22:18:54 -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
Zach Daniel
47dde10329 improvement: adding domain to embedded resource is an error 2024-04-11 22:28:47 -04:00
Rebecca Le
3fce34cda6
fix: Validate all conditions in a numericality validation instead of only the last (#997)
The previous `reduce` loop did not break on the first failure and
return the error, it returned the last iteration of the loop

Some more work may need to be done on the atomic side of the validation,
I'm not familiar with how they work!
2024-04-10 09:25:42 -04:00
Zach Daniel
25c1063e45 fix: add context argument to before_action and after_action for read actions
closes #999
2024-04-09 13:21:06 -04:00
Andreas Donig
95ecc5155c
fix: add base case for Ash.Resource.Info.public_relationship/2 (#1000)
test: Add a simple test for Ash.Resource.Info.public_relationship/2

---------

Co-authored-by: Andreas Donig <git@innwiese.de>
2024-04-09 13:17:03 -04:00
Riccardo Binetti
7d75e64d86
feat: add update_change function and builtin change (#976) 2024-04-07 05:02:38 -04:00
Riccardo Binetti
355bd73bf9
improvement: make Ash.Resource.Validation.Match partially atomic (#979)
* fix: handle partially atomic validations in run_action_changes

* improvement: make Ash.Resource.Validation.Match partially atomic
2024-04-06 17:50:54 -04:00
Zach Daniel
3eaeb864ea fix: ending a policy w/ authorize_if had flipped conditional 2024-03-31 23:53:59 -04:00
Zach Daniel
baa3289a09 fix: properly retain input order for embedded attributes
improvement: better error messages for private attribute accepting
2024-03-29 21:24:05 -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
18cc9c9b26 fix: ensure that message is honored in atomic validations
fix: don't require actor when constructing aggregate query
2024-03-07 10:47:43 -05:00
Zach Daniel
9e02b0d0c7 improvement: introduce require_atomic?, which defaults to false in 2.0, true in 3.0
fix: properly prevent the atomic handling of manual update actions
improvement: better support around the mixing of atomic and non atomic changes/validations
2024-01-30 12:32:41 -05:00
Dmitry Maganov
c40f762eee
fix: use correct option for relationship in atomic relate_actor (#855)
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-01-27 09:53:03 -05:00
Zach Daniel
e5d78ae074 fix: get tests passing for bulk creates again 2024-01-19 10:49:26 -05:00
Zach Daniel
40aa17eab8 fix: ensure __source__ is set on nested embedded attributes 2023-12-28 14:47:40 -05:00
Robert Graff
69ff044214
test: pass the source context with data to embedded resource validations (#811) 2023-12-28 13:25:49 -05:00
Zach Daniel
d09c694132 fix: thread context through when setting source constraint on embeds 2023-12-13 17:11:52 -05:00
Robert Graff
e13bb6e0b4
test: Failing test for threading source information through embedded attributes (#801) 2023-12-13 16:47:11 -05:00
Zach Daniel
c38cba51b0 fix: test failures and credo issue 2023-12-10 13:13:06 -05:00
Eduardo B. A
1775ab5a14
feat: Expand upsert_fields option (#761)
With this change, upsert_fields accepts the following options:

* `nil`: upsert fields not set;
* `:replace_all`: all fields from resource will be updated;
* `{:replace_all_except, [fields]}`: all fields from resource except fields inside `fields` will be updated;
* `{:replace, [fields]}`: only fields inside `fields` will be updated.
2023-11-13 13:23:16 -05:00
Pierre Le Gall
e14e1b2e29
improvement: set default many to many options (#737)
Many to many relationship `source_attribute_on_join_resource`
and `destination_attribute_on_join_resource` are now guessed
by there module name if not explicitly set in the relationship.
2023-10-17 10:03:21 -04:00
Zach Daniel
1ab4b6e69a improvement: support atomics on upserts 2023-10-11 15:09:06 -04:00
Zach Daniel
1d43b26127 chore: move validate_relationship_attributes to a verifier 2023-09-20 16:51:38 -04:00
Zach Daniel
91013c2de0 improvement: support stacktraces in set_error 2023-09-12 11:26:11 -04: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
567dcf6372 fix: better handling for negate error messages 2023-09-04 16:01:48 -04:00
Tchowa Franck A
7e47bfb60f
improvement: validate all actions and accept/reject fields at once. (#674) 2023-08-18 20:47:35 -04:00
Tchowa Franck A
f302dca003
Feature: Ensure aggregate field is attribute or calculation. (#671) 2023-08-17 18:02:05 -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
Mariusz Morawski
5ed2109e33
improvement: Add Negate validation (#636)
* Add `Negate` validation
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2023-07-05 16:25:51 -04:00
Alan Heywood
4ab7e84e4f
fix: typo in at_most validation message (#640) 2023-07-04 08:59:12 -04:00
Zach Daniel
4376cf9adb chore: fix reserved name test 2023-06-22 14:24:50 -04:00
Abhishek Tripathi
06329b97cf
improvement: add verifier for identity fields. (#626)
* improvement: adds verifier for identity fields.
---------

Co-authored-by: abhishek <abhishek.tripathi@tinymesh.in>
2023-06-20 01:05:41 -04:00
RaspberryLambda
ffaf6d57df
* improvement: add data layer introspection to Ash.Resource.Info (#610)
---------

Co-authored-by: Daniel Stewart <mgdog1@googlemail.com>
2023-06-10 13:17:17 -04:00