Commit graph

2750 commits

Author SHA1 Message Date
Zach Daniel
dbf848e264 fix: property tests should allow private attributes that are accepted 2024-05-10 10:39:26 -04:00
Zach Daniel
bc3463e135 docs: document Ash.can 2024-05-09 20:43:49 -04:00
Zach Daniel
b3a34d0d65 fix: ensure source_context is a map
fixes #1141
2024-05-09 08:49:39 -04:00
Zach Daniel
7bb914444e fix: get underlying type before calling rewrite on it 2024-05-08 21:03:44 -04:00
Zach Daniel
b6c8b1c2ec fix: allow calculations to access what would forbidden fields of related items
context for this change:

this requires a potentially risky modification to how field policies are
applied for nested queries and embedded types, which is that we now
apply field policies for nested queries in a post-processing pass.

Bugs in this code could lead to forbidden fields being displayed
when they shouldn't be. Luckily we have tests for this kind of thing :)
2024-05-08 16:22:48 -04:00
Barnabas Jovanovics
aecd421a29
fix: access to change context in get_and_lock(_for_update) changes (#1135) 2024-05-08 09:22:12 -04:00
Riccardo Binetti
0e899dbbb3
improvement: add tenant to data earlier in read (#1137) 2024-05-08 09:21:01 -04:00
Zach Daniel
078cc4f28b improvement: reintroduce deslection of known forbidden fields
this was an optimization that was temporarily removed, but can now
safely be added because we track depended on fields
2024-05-07 22:42:23 -04:00
Zach Daniel
797a0bf50b fix: properly upgrade static expression calculations to literal calculations 2024-05-07 22:33:05 -04:00
Zach Daniel
04b4769e87 improvement: always reselect positionally on embedded resources 2024-05-07 22:05:50 -04:00
Zach Daniel
48c6438212 improvement: change default timeout to :infinity, for efficiency 2024-05-07 17:01:11 -04:00
Zach Daniel
0e004ead7a fix: support empty lists as bulk arguments to code interface options
fixes #1126
2024-05-07 16:46:41 -04:00
Zach Daniel
ce559bc018 fix: temporarily disable field policy deselection optimization
also added a test for related field calc dependencies,
commented out until I fix it later
2024-05-07 16:08:56 -04:00
Zach Daniel
f5ab6a6bd8 fix: ensure that reuse_values? is honored all the way down the chain 2024-05-07 15:38:03 -04:00
Barnabas Jovanovics
9d16ca07dc
feat: check global changes and validations for atomicity during compile time (#1129) 2024-05-07 12:09:12 -04:00
Zach Daniel
09cff72d03 chore: ensure changeset is set on atomic upgraded errors
docs: update livebook
2024-05-06 21:57:11 -04:00
Zach Daniel
1d519e37e0 chore: better inspecting for error classes 2024-05-06 20:58:39 -04:00
Zach Daniel
64ecdad657 fix: properly deduplicate calculations 2024-05-06 20:32:41 -04:00
Zach Daniel
b810e2e55b fix: better performance and ability to add a stream to runtime sort logic 2024-05-06 13:05:34 -04:00
Zach Daniel
36308a9e4f chore: reword some docs 2024-05-06 10:52:17 -04:00
Moxley Stratton
aa09589fbd
docs: Add documentation for Ash.Filter, linking to Expressions guide (#1114)
* Add documentation for Ash.Filter, linking to Ash.Filter.Functions.*

* Update PR: Rename section to "Expressions"
2024-05-06 07:47:35 -04:00
Pierre Cavin
3cf9fcd8e5
feat: add new remove_nil_items? array type constraint (#1116) 2024-05-05 12:05:04 -04:00
Pierre Cavin
c05544663e
fix: run array type nil check after item constraints (#1115) 2024-05-05 11:49:23 -04:00
Zach Daniel
a802e04a93 docs: rework ash state machine cook book, clean up both cookbooks 2024-05-05 09:30:42 -04:00
Zach Daniel
6882d15098 chore: fixes around inspect logic and cookbook 2024-05-04 07:03:03 -04:00
Riccardo Binetti
5dfea1df9b
feat: add relationship pagination (#1050) 2024-05-04 05:56:46 -04:00
Zach Daniel
e03e4379a9 fix: small logic fixes for optimistic locking error case
chore: a bunch of QoL fixes around inspecting expressions
2024-05-04 01:10:04 -04:00
Zach Daniel
3b85451289 fix: more fixes for atomic changeset context setting 2024-05-03 20:39:10 -04:00
Jechol Lee
70f5264f17
Fix: missing tenant for many_to_many read (#1107)
* Fix missing tenant for many_to_many read

* Set tenant earlier
2024-05-03 18:51:52 -04:00
Riccardo Binetti
7507cdd731
fix: make lateral join filtering in ETS data layer work (#1111)
One of the two branches was using the non-bang version of a function, which
returned `{:ok, filter}`. That value was then directly put in the Query struct,
resulting in an invalid filter that was never applied.
2024-05-03 16:56:18 -04:00
Zach Daniel
28c8c6565a chore: fix typo 2024-05-03 12:45:50 -04:00
Zach Daniel
2ab788fd35 fix: properly retain context from initial changeset in fully atomic changeset 2024-05-03 12:14:26 -04:00
Rebecca Le
9d7bb3b184
docs: Fix syntax error in builtin change documentation (#1108) 2024-05-03 10:41:48 -04:00
Zach Daniel
a49b951d32 fix: ensure transaction is rolled back on data layer errors during streaming 2024-05-03 10:33:36 -04:00
Zach Daniel
6a1359c3d8 fix: various fixes around bulk actions, types, error handling 2024-05-02 23:48:10 -04:00
Zach Daniel
1bdc095b04 fix: fix match validation when performed atomically 2024-05-02 20:30:37 -04:00
Sergey Moiseev
0efa1a0a10
fix: trim spaces from codegen name (#1106) 2024-05-02 19:14:10 -04:00
Zach Daniel
7fd063239f fix: set notify?: true when return_notifications?: true is set
closes #1100
2024-05-02 14:51:35 -04:00
Dmitry Maganov
e1188aa552
improvement: normalise List.wrap usage for policy checks (#1103) 2024-05-02 14:11:47 -04:00
Dmitry Maganov
712078877c
fix: fix changing_attributes for multiple attributes (#1101) 2024-05-02 11:42:18 -04:00
Frank Dugan III
09af174e4c
docs: clarify functionality of notify? and return_notifications? (#1099) 2024-05-02 11:36:28 -04:00
Zach Daniel
245ee998b4 fix: use InvalidReturnType, not AssumptionFailed for callback returns 2024-05-02 09:27:08 -04:00
Zach Daniel
5ad47c10cf fix: enforce that transaction hooks are not added from other hooks
closes #1096
2024-05-02 09:23:41 -04:00
Dmitry Maganov
1e2baf7809
fix: fixes to some atomic validations (#1094) 2024-05-02 08:59:01 -04:00
Zach Daniel
b8c01596cb fix: multiple small bugs when loading for calculate
closes 1091
2024-05-02 00:29:01 -04:00
Zach Daniel
c1354d503e fix: run changesets w/ after_transaction hooks through standard logic 2024-05-02 00:06:31 -04:00
Zach Daniel
0273b7d949 chore: fix remove after_transaction hooks after processing them 2024-05-01 20:29:58 -04:00
Zach Daniel
ec7e6905da fix: properly hydrate refs in related query 2024-05-01 17:18:24 -04:00
Frank Dugan III
718adb4891
feat: add read_action option to bulk actions (#1088) 2024-05-01 16:26:33 -04:00
Moxley Stratton
65ad0c6039
docs: Add doc text to the default option (#1077)
* Add doc text to  option

* Second version of the change

* Adjust docs for `:default`, and generate .md files

* Fix type
2024-05-01 16:03:09 -04:00
Zach Daniel
1f32fad9a8 chore: update data layer docs tagline 2024-05-01 14:16:34 -04:00
Zach Daniel
b224cc1134 chore: remove an unnecessary note 2024-05-01 14:14:11 -04:00
Zach Daniel
34ab8d4082 fix: properly express not atomic reason in bulk updates 2024-05-01 11:27:23 -04:00
Zach Daniel
ccd2043d4e fix: properly set actor on query in bulk update 2024-05-01 10:21:27 -04:00
Zach Daniel
be2caade74 fix: no need to restrict sorting on arrays 2024-05-01 09:35:26 -04:00
Zach Daniel
65395c37c6 fix: properly execute before_batch callbacks in bulk actions 2024-05-01 08:59:03 -04:00
Zach Daniel
6f0524d67d fix: missing pattern match on error query in read
closes #1084
2024-05-01 08:00:22 -04:00
Zach Daniel
fa7cfe5488 improvement: add pre_flight option for Ash.can 2024-04-30 22:55:32 -04:00
Zach Daniel
723276f41a fix: remove debugging code
improvement: make `Ash.Filter.map` more consistent
improvement: better inspect behavior for calculations
improvement: better inspect behavior for fragments
fix: don't call `Keyword` functions on maps in unions
2024-04-30 13:31:33 -04:00
Riccardo Binetti
c50d047614
fix: streaming with limit/offset and no pagination (#1080)
If there were 0 results, it just kept reading and reading forever
2024-04-30 13:03:49 -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
Riccardo Binetti
09238490c4
fix: don't pass an error tuple to rollback in bulk update (#1079) 2024-04-30 06:40:42 -04:00
Jeremy Grant
45b76c209d
fix: union array argument/attribute handling when current attribute is (#1023) 2024-04-29 22:24:44 -04:00
Sergey Moiseev
417d39e7de
Add documentation on disabling pagination (#1076) 2024-04-29 20:40:19 -04:00
Zach Daniel
28c75df7b8 improvement: support new data layer capability calculate/3
fix: solve for custom expressions and one-off calculations
2024-04-29 16:58:37 -04:00
Zach Daniel
0fa257e7ea chore: don't add atomic allow nil hooks to primary key attributes
improvement: add debug logging for ets data layer
2024-04-29 15:43:47 -04:00
Dmitry Maganov
3ee24da7eb
improvement: pass context to anonymous validate functions (#1070) 2024-04-29 12:53:45 -04:00
Jechol Lee
ae3f632157
Fix is_belongs_to_rel_being_managed? to match list with more than 2 elements (#1072) 2024-04-29 12:49:26 -04:00
Zach Daniel
ca7b0824d7 fix: properly intercept thrown errors in Ash.bulk_create 2024-04-29 09:12:03 -04:00
Zach Daniel
a24fdcfe59 docs: fix code interface example 2024-04-29 07:49:25 -04:00
Jechol Lee
856ac698b7
fix: Changeset.present? to be false when belongs_to is set to nil (#1067)
* Changeset.present? to be false when belongs_to is set to nil

* match empty list

* match empty list 2
2024-04-29 07:38:06 -04:00
Jechol Lee
caf1c5ee2a
Improvement: Changeset.attributes_present? to attribute_present? (#1066) 2024-04-29 06:51:14 -04:00
Zach Daniel
5ef8de03f3 fix: fix simple_equality in attribute type 2024-04-28 00:41:57 -04:00
Zach Daniel
2f1a0fec71 fix: set resource option in bulk interfaces 2024-04-27 23:56:11 -04:00
Zach Daniel
69f844dc69 chore: fix typo 2024-04-27 23:35:12 -04:00
Zach Daniel
fa6c2ade6d fix: check resource match below checking query input 2024-04-27 23:33:04 -04:00
Zach Daniel
26225fc7f5 fix: only use Map.new for inputs if input is keyword in code interface 2024-04-27 23:21:34 -04:00
Zach Daniel
65c6f66b91 fix: properly set action type on changeset 2024-04-27 11:20:03 -04:00
Zach Daniel
8c4e9c44d6 fix: set changed? context on bulk actions 2024-04-27 10:43:53 -04:00
Zach Daniel
3f977ff98d improvement: simplifications and clarifications around bulk callback behavior 2024-04-27 10:14:31 -04:00
Zach Daniel
75b63917c7 improvement: don't add autogenerated_id to embeds by default
one list *very mild* breaking change
2024-04-27 00:53:22 -04:00
Zach Daniel
69295daf78 improvement: allow skipping primary keys on embedded resources 2024-04-27 00:41:12 -04:00
Zach Daniel
41f68ca4a4 improvement: support changeset filters in ets 2024-04-27 00:33:00 -04:00
Zach Daniel
03b1579d9c fix: properly handle atomic upgrade when policies can't be strict checked 2024-04-26 23:53:54 -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
2d0b73af96 chore: set authorization context ahead of query build 2024-04-26 03:15:46 -04:00
Zach Daniel
726c6c3f0f fix: various fixes around bulk action upgrades, atomics 2024-04-26 03:13:22 -04:00
Zach Daniel
41c951d2e5 chore: fix missing clause andhydrate atomic refs 2024-04-25 23:46:11 -04:00
Zach Daniel
ad076735ae chore: fix batch size detection while streaming 2024-04-25 22:56:41 -04:00
Zach Daniel
c8e93877ea improvement: support atomics, update_query, destroy_query in ETS data layer 2024-04-25 22:18:54 -04:00
Barnabas Jovanovics
00ee13143b
fix: handle resource being passed as query code_interface.ex (#1057)
* handle resource being passed as query code_interface.ex

This bit me today because I had code  like this 

```elixir
                Resource
                |> filter_board_codes(board_codes)
                |> filter_min_price(min_price)
                |> filter_max_price(max_price)
                |> filter_refundable_only(refundable_only)
```

and all the `filter_*` functions looked like this

```elixir
def filter_something(query, nil), do: query

def filter_something(query, something) do
  query
  |> Ash.Query.filter(....)
end
```

* Update lib/ash/code_interface.ex

* add another case

---------

Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-04-25 10:37:44 -04:00
Barnabas Jovanovics
02c10c9216
fix: do not use Enum.map_join (#1058)
values are only a flat list of values, and map_join would need a function as the third argument if you specify a `joiner`
2024-04-25 07:53:52 -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
f146258159 improvement: remove after_atomic and instead support after_batch
supporting `after_batch` allows things like `archive_related` in `ash_archival`
to dispatch batches of cascading archives
2024-04-24 11:56:36 -04:00
Jechol Lee
56b10be097
fix: use Splode.ErrorClass for error classes (#1054) 2024-04-24 06:14:55 -04:00
Jechol Lee
44c38277e5
improvement: Add attributes_present, attributes_absent. (#1046)
* Add attribute_present, attribute_absent.

* Refactor

* plural name: attributes_present/absent

* Fix conflict
2024-04-23 22:01:35 -04:00
Zach Daniel
dad4d5effc fix: ensure that errors for nested forms are transformed 2024-04-23 14:03:40 -04:00
Jechol Lee
184dfb3642
fix: Set tenant for managed relationship changeset (#1044) 2024-04-23 10:40:19 -04:00
Zach Daniel
5ff767a1aa fix: don't carry over all changes during atomic upgrade
Doing this was causing us to carry over changes that were produced
as part of running the changes in the original changeset build

fixes #1042
2024-04-22 19:01:05 -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
7e86b971a4 chore: fix migrate task file name 2024-04-22 12:27:43 -04:00
Zach Daniel
34470d4494 improvement: make extension discovery faster 2024-04-21 11:16:33 -04:00
Zach Daniel
8317e6fca9 fix: properly pin Enum.join in atomic for enum types
fixes #1033
2024-04-20 15:50:11 +01:00
Zach Daniel
d49f991021 fix: ensure actor is set when building queries in filter 2024-04-20 15:46:49 +01:00
Zach Daniel
c7991ec8a7 fix: don't eager evaluate type because it breaks data layers 2024-04-19 16:09:42 +01:00
Rebecca Le
7c75e5c102
refactor: Move opt schema definitions for built-in changes and validations to their specific modules (#1036)
* refactor: Move Spark opts definitions for built-in changes to the relevant change modules

This allows the change modules to be read and grokked standalone, without
needing to refer back to the `Builtins` module just for the opts

* refactor: Move Spark opts definitions for built-in validations to the relevant validation modules

This allows the change modules to be read and grokked standalone, without
needing to refer back to the `Builtins` module just for the opts
2024-04-19 15:43:35 +01:00
Zach Daniel
94f319a5f4 chore: invert code interface for simpler checking 2024-04-19 14:19:49 +01:00
Zach Daniel
89f15103c8 fix: ensure __union_tag__ is set when calling sub-union types 2024-04-19 13:41:05 +01:00
Zach Daniel
a2ac66093c fix: handle more &Mod.fun/n variations in fragments 2024-04-17 16:12:55 +01:00
Zach Daniel
28136ec43f chore: format 2024-04-17 15:08:29 +01:00
Zach Daniel
45b66f539b chore: remove atomic
fix: ensure validations are considered atomic
2024-04-17 15:07:15 +01:00
Zach Daniel
8e1fd3b833 improvement: better eager expression parsing and atomic error anticipation 2024-04-17 02:34:33 +01:00
Zach Daniel
ccb06b1628 fix: ensure tenant and actor are properly set in Ash.can?
fixes #1027
2024-04-17 00:14:31 +01:00
Zach Daniel
f960e69437 chore: remove IO.inspect 2024-04-16 21:49:59 +01:00
Zach Daniel
70cd40065b fix: ensure changeset filter is parsed for templates 2024-04-16 21:03:25 +01:00
Zach Daniel
65675ef337 fix: properly parse additional changeset expression 2024-04-16 20:45:43 +01:00
Zach Daniel
371c2d1515 fix: properly parse changeset template for filters 2024-04-16 20:41:19 +01:00
Zach Daniel
3044339396 fix: properly parse changeset filter 2024-04-16 20:35:30 +01:00
Zach Daniel
4b50550149 chore: fix typo 2024-04-16 20:31:57 +01:00
Zach Daniel
3b8a15fd34 fix: ensure changeset filters are applied on bulk destroy/update 2024-04-16 20:27:42 +01:00
Zach Daniel
a147062523 improvement: add Ash.read_first 2024-04-16 18:19:20 +01:00
Zach Daniel
77ee3686eb improvement: helpful output in mix tasks helper 2024-04-16 17:37:15 +01: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
Dmitry Maganov
8bcbfc5b17
fix: support all calculate opts in code interface methods (#1026) 2024-04-15 22:34:33 +01:00
Riccardo Binetti
11de5dd64f
improvement: use explicit read actions when reading relationships (#1029)
While filter, sorts etc are already copied from the read action into the query,
using the right action is relevant, for example, when it's checked against in
policies, or in preparations that check the action name from the query
2024-04-15 22:33:56 +01:00
Riccardo Binetti
3338b343ac
improvement: use cached to_tenant when setting tenant attribute (#1021) 2024-04-14 11:53:09 -04:00
Zach Daniel
3519a85cee fix: ensure to_tenant is copied to aggregate query 2024-04-13 20:47:01 -04: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
Riccardo Binetti
9c74e52bd8
improvement: make match/1 overridable in Ash.Type.Enum (#1020)
Allow handling additional inputs to map them to one of the enum values
2024-04-13 14:07:23 -04:00
Zach Daniel
0e2b392413 fix: compilation time improvements (hopefully) 2024-04-12 14:14:14 -04:00
Lukas Ender
10e3722446
fix: code_interface actions accept @context (#1016) 2024-04-12 10:26:46 -04:00
Zach Daniel
8ea51ec506 fix: ensure tenant is set to opts in action helpers 2024-04-11 23:33:22 -04:00
Zach Daniel
47dde10329 improvement: adding domain to embedded resource is an error 2024-04-11 22:28:47 -04:00
Zach Daniel
0416ce1d0d fix: ensure more consistent use of Ash.Tenant.to_tenant/2 2024-04-11 11:41:29 -04:00
Zach Daniel
dc1205a48f fix: ensure that strict loads are applied at all nesting levels 2024-04-11 10:16:24 -04:00
Zach Daniel
2474fbed44 improvement: raise more sensible error on unsupported pagination 2024-04-11 09:38:49 -04:00
Zach Daniel
752320c139 fix: properly load depended on fields for relationships even if public?: false 2024-04-11 08:04:20 -04:00
Jechol Lee
0b79515f69
fix: fix date_add query function (#1010) 2024-04-11 07:42:11 -04:00
Zach Daniel
e1a0b48172 fix: pass name through to underlying tasks 2024-04-10 19:02:42 -04:00
Zach Daniel
829f6d6e49 improvement: support builder options in read code interfaces 2024-04-10 15:57:30 -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
Riccardo Binetti
9f2b4ab8ba
improvement: call ToTenant protocol when setting tenant in actions (#1004) 2024-04-10 09:35:39 -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
f504ab6a67 chore: fix domain behaviour impl 2024-04-10 07:55:37 -04:00
Riccardo Binetti
8eb98bc663
fix: swap the parameters in Ash.ToTenant.to_tenant/2 (#1003)
This is technically a breaking change, but without this the protocol would never
work as intended since the funtion gets dispatched based on the type of the
first parameter and the resource parameter will always be an atom (precisely, an
alias) so the implementation for Atom will always be called
2024-04-10 06:58:53 -04:00
Zach Daniel
2f28bd9ee7 chore: better use Ash.Resource options
chore: atom -> module
2024-04-09 22:55:26 -04:00
Zach Daniel
46ed97dd10 improvement: add ash.rollback mix task
chore: fix some naming/mix task steps
2024-04-09 20:24:08 -04:00
Zach Daniel
4f26773fe0 improvement: add ash.rollback task 2024-04-09 14:54:44 -04:00
139058d4c0 fix(Ash.Reactor): crash when calling an ash reactor for the first time.
Thanks to @carlgleisner for the [detailed reproduction](https://github.com/carlgleisner/reactor_notification_worker_issue).

The problem was caused by an attempt to not have nested reactors indepdently publish their notifications separate to the parents but contained a logic flaw which caused the agent to not start, but only the first time you try and use a given reactor.

The fix involves _always_ starting a notification agent for each reactor, but nesting them.  When a reactor completes it either publishes it's notifications to the parent reactor or to ash if there are no parent reactors.
2024-04-10 06:19:38 +12:00
Zach Daniel
1854880def improvement: add config :ash, require_atomic_by_default?, false, for upgrading 2024-04-09 13:45:19 -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
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
321f43bd05 feat(Ash.Reactor): Add new change step type which can be used to modify changesets. 2024-04-09 09:03:04 +12:00
2973c0db94 improvement(Ash.Reactor): Allow create to be provided an initial value.
The initial value can be either a resource or a changeset.
2024-04-09 09:03:04 +12:00
c67295de6e
improvement: Allow Reactor modules to be run directly from generic actions. (#993)
- Extends the generic action runner to detect when the `run` module is a Reactor and automatically executes it in the correct way.
- Adds a verifier that detects said actions and ensures that action arguments are present for all expected inputs.
2024-04-08 16:48:58 -04:00
Zach Daniel
4cbf2d3e14 docs: more restructuring, reviewing of guides 2024-04-08 13:39:45 -04:00
Zach Daniel
5e1df439d7 chore: format 2024-04-08 12:15:09 -04:00
Zach Daniel
e91da15564 docs: moved around some documentation
docs: added changes guide
docs: moved around validations guide, removed extra one
2024-04-08 12:05:36 -04:00
Zach Daniel
05dd917af0 docs: update explanation of sort parser
fix: honor new calcualtion sort format in sort parser
2024-04-08 09:54:05 -04:00
Zach Daniel
c31fbc9c3e fix: don't raise error on keyword input to create interface 2024-04-08 08:41:33 -04:00
Zach Daniel
6d3b00f77f fix: action is an atom in erroor case for bulk update 2024-04-08 08:33:14 -04:00
Zach Daniel
d153b40dea docs: consolidate guides into relationships.md
improvement: add `Ash.Query.apply_to/3`
2024-04-07 15:31:26 -04:00
Zach Daniel
773e9cea91 docs: move identities guide 2024-04-07 14:50:18 -04:00
Zach Daniel
d2612a9ed8 docs: doc fixes, move code interface docs 2024-04-07 12:33:59 -04:00
Zach Daniel
49958975a1 chore: remove dedicated constraints guide, put it in Ash.Type 2024-04-07 10:52:18 -04:00
Zach Daniel
2226b00ca5 docs: more condensation/relocation of docs 2024-04-07 10:11:19 -04:00
Zach Daniel
957ac1880e docs: better docs on atomics & upserts 2024-04-07 09:36:09 -04:00
Zach Daniel
951eaba973 chore: fix build/test 2024-04-07 08:05:23 -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
bc00873cfd
fix: undo adding primary key argument for methods with get? (#989) 2024-04-07 06:41:03 -04:00
Dmitry Maganov
5c600c1f42
fix: remove internal? and stacktraces? from common opts (#988) 2024-04-07 06:00:32 -04:00
Zach Daniel
ea463402a2 fix: pattern match error in managed relationships
closes #986
2024-04-07 05:17:05 -04:00
Rebecca Le
98d7ee759f
docs: Fix formatting of examples for Ash.Resource.Preparation.Builtins (#987)
* docs: Fix other cases of unformatted code examples
2024-04-07 05:03:21 -04:00
Riccardo Binetti
7d75e64d86
feat: add update_change function and builtin change (#976) 2024-04-07 05:02:38 -04:00
Zach Daniel
8249b6cabd fix: include options for generic action code interfaces 2024-04-07 05:00:50 -04:00
Zach Daniel
26a6efe10d fix: logic errors around arguments/changing attributes in validations 2024-04-06 18:40:40 -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
f9eff8810f docs: refactor security guides 2024-04-06 17:40:05 -04:00
Zach Daniel
a7b69303ca chore: properly manage sat solver dependencies 2024-04-05 15:11:09 -04:00
Zach Daniel
8927460f77 fix: more improvements to resource matching in can? 2024-04-05 15:06:44 -04:00
Jefferson Queiroz Venerando
51db6c5b1a
chore: fix typo in sort error message (#984) 2024-04-05 12:38:56 -04:00
Zach Daniel
b0ff379d00 docs: work on organizing docs
fix: detect more cases for domain extraction from resources
2024-04-05 12:24:12 -04:00
Zach Daniel
6a486a4a9a fix: properly dispatch managed relationships to proper domain 2024-04-05 09:57:52 -04:00
Zach Daniel
4e329cde31 fix: check target resource's domain before assuming it is the same as current domain 2024-04-05 06:37:20 -04:00
Riccardo Binetti
38c1ca808d
fix: return {:error, query} for invalid query in Aggregate.run/4 (#982)
Avoid making callers like Ash.aggregate crash with a WithClause error
since they expect an :ok/:error tuple
2024-04-05 06:36:05 -04:00
Zach Daniel
f473b32297 fix: allow strings in Ash.Type.Enum again 2024-04-05 06:25:54 -04:00
Zach Daniel
7534d6bcb1 chore: try again w/ domain priority 2024-04-04 22:55:30 -04:00
Zach Daniel
950ff3d060 fix: set tenant in bulk creates after setting up changeset 2024-04-04 20:34:37 -04:00
Zach Daniel
0f8c8152c7 chore: format 2024-04-04 20:07:49 -04:00
Riccardo Binetti
fb66b83670
chore: show the correct alternatives for already validated changesets (#978) 2024-04-04 18:56:00 -04:00
Zach Daniel
3f82e3fe0a fix: use the resource's domain above option domain 2024-04-04 18:44:25 -04:00
Zach Daniel
ca89ee4840 chore: format 2024-04-04 18:21:51 -04:00
Zach Daniel
3cfa980762 docs: start on docs overhaul 2024-04-04 16:24:55 -04:00
Zach Daniel
ec76778b49 chore: backport fixes from 2.0 2024-04-04 14:45:03 -04:00
Zach Daniel
cce4a0f2c3 fix: properly cast identity keys before comparison
fixes #877
2024-04-04 14:30:50 -04:00
Zach Daniel
9cf1e3a215 fix: properly handle multiple paths for checking sortable relationships 2024-04-04 09:55:12 -04:00
Zach Daniel
9d9cfee1a6 chore: raise explicit error instead of a match error 2024-04-04 07:21:10 -04:00
7721dc1c61
fix: multi-line DSL doc options in Ash.Reactor. (#974)
Closes #973.
2024-04-03 22:56:42 -04:00
Zach Daniel
28f0b4f62c fix: don't call domain at compile time if its not loaded
we assume some other error will occur
2024-04-03 17:15:34 -04:00
Zach Daniel
f1a9ad949c fix: ensure that generic action arguments have proper default for public? 2024-04-03 12:36:04 -04:00
Zach Daniel
d9aebaec1c improvement: add skip_unknown_inputs for generic actions 2024-04-03 07:28:19 -04:00
Zach Daniel
a21341d880 chore: fix typespec for stream!/2 2024-04-02 22:04:49 -04:00
Zach Daniel
17d8e5eb00 chore: fix typo from flatten -> wrap 2024-04-02 20:23:03 -04:00
Zach Daniel
3776619aba fix: ensure we don't double-query values after manual actions 2024-04-02 20:17:41 -04:00
Zach Daniel
ab0ec1d40e fix: properly handle lists of errors added by validations 2024-04-02 11:47:43 -04:00
Zach Daniel
48e50cfe63 fix: honor only_when_valid? on validations in bulk actions 2024-04-01 23:29:13 -04:00
Dmitry Maganov
43d2246530
improvement: support allow_nil_input dsl option in update/destroy (#964) 2024-04-01 17:26:21 -04:00
Zach Daniel
05f3de2538 fix: fix typespec for bulk_create 2024-04-01 17:19:23 -04:00
Zach Daniel
a53ee04441 chore: add missing clause 2024-04-01 17:01:56 -04:00
Zach Daniel
ae5a9609ac chore: wrap up private attribtue acceptance feature 2024-04-01 16:56:54 -04:00
Zach Daniel
b1c7c01701 improvement: allow accepting private attributes
docs: update upgrade guide
2024-04-01 16:43:56 -04:00
Zach Daniel
3eaeb864ea fix: ending a policy w/ authorize_if had flipped conditional 2024-03-31 23:53:59 -04:00
Dmitry Maganov
bc34287edc
fix: handle sensitive? option in query aggregate/calculation (#963) 2024-03-31 21:28:42 -04:00
Zach Daniel
f885a0753f improvement: allow adding non-public attributes to explicit accept lists
docs: update upgrade guide
2024-03-30 11:42:52 -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
14ad3a1f6d improvement: use resource api when verifying its presence in a known api 2024-03-29 19:49:32 -04:00
Zach Daniel
2ef23840cc fix: fix changing_attributes check implementation 2024-03-29 17:31:26 -04:00
Zach Daniel
8f1217ea03 chore: fix typespecs and format 2024-03-29 16:55:32 -04:00
Dmitry Maganov
99153144c7
improvement: change type argument position in Ash.Query.calculate (#959) 2024-03-29 11:14:12 -04:00
Mitchell Hanberg
009dbb6c2c
refactor: erroneous else (#957)
* refactor: erroneous else

* Update lib/ash/actions/helpers.ex

---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-03-29 08:27:39 -04:00
Dmitry Maganov
10e7129e5b
improvement: allow simple check to return error tuple (#956) 2024-03-29 08:25:48 -04:00
Zach Daniel
e00a50c9f6 improvement: skip unknown inputs when managing relationships 2024-03-28 19:46:12 -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
ff949be810 chore: fix bad merge 2024-03-27 21:13:49 -04:00
Zach Daniel
2cf6816747 improvement: ensure that update defaults are set 2024-03-27 20:39:52 -04:00
Zach Daniel
fe32acf281 fix: properly handle transaction errors from bulk creates 2024-03-27 19:55:00 -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
Riccardo Binetti
b7cfddf77c
fix: make bang variant of field aggregates work correctly (#954)
split_aggregate_opts/1 was called too early so it didn't handle the translation
of :read_action to :action, leading to a NimbleOptions error during validation
2024-03-27 14:22:49 -04:00
Riccardo Binetti
8826c9ec35
fix: enforce multitenancy on aggregates (#952)
The multitenancy attribute was already considered as a filter in
aggregates, but the presence of the tenant was not enforced
2024-03-27 10:07:53 -04:00
Dmitry Maganov
4522d7349d
fix: fix missing tenant in some bulk contexts (#951) 2024-03-27 07:31:19 -04:00
WIGGLES
65a28cff33
fix: Fix places where tenant is not passed along (#950)
* pass tenant to top legel aggregate api

* pass tenant manage relationship when loading relationships
2024-03-26 13:30:37 -04:00
Zach Daniel
35d45238c9 fix: don't try to reselect fields when pkeys are missing 2024-03-26 02:10:03 -04:00
Zach Daniel
88d0b46dec improvement: detect loaded-through types 2024-03-24 23:25:28 -04:00
Zach Daniel
9f1d1ff723 chore: format 2024-03-24 19:39:06 -04:00
Zach Daniel
4e93212838 chore: fix match clause on calculation evaluation 2024-03-24 19:30:21 -04:00
Dmitry Maganov
a85f559a20
fix: convert %{__struct__: T} into %T{} (#947) 2024-03-24 19:26:38 -04:00
Dmitry Maganov
e6315e2928
improvement: support load option for create/update/destroy (#946) 2024-03-24 19:26:04 -04:00
Zach Daniel
ac0ff0e2e4 improvement: restore old behavior of leveraging in memory values for calculations 2024-03-24 19:25:13 -04:00
Dmitry Maganov
7734ac0967
fix: corrections for reload/reload! (#942) 2024-03-23 15:42:30 -04:00
Dmitry Maganov
d65294c174
fix: show that Policy.Check.strict_check can return an error tuple (#945) 2024-03-23 15:41:20 -04:00
Zach Daniel
0afb9ade26 chore: fix typo 2024-03-22 03:38:28 -04:00
Zach Daniel
6f21ecf0f8 chore: fix typo & remove unused variable 2024-03-22 03:23:27 -04:00
Zach Daniel
d1c0f0e6d6 improvement: simplify inspect for aggregates
fix: remove unnecessary function
2024-03-22 03:10:13 -04:00
Minsub Kim
75b2d2eb00
feat: add less_than, greater_than constraints to float, decimal (#936) 2024-03-22 02:39:59 -04:00
Riccardo Binetti
23055f0a18
feat: allow providing descriptions to Ash.Type.Enum values (#940)
As discussed in https://github.com/ash-project/ash_graphql/issues/116, this
allows extensions to use the description to use the provided descriptions.

The documentation assumes that if a user provides a description, it does so for
all values (since this seems to be a reasonable assumption and allows the nicer
keyword list syntax). However tests also cover an enum with some missing
descriptions.
2024-03-22 02:38:59 -04:00
Zach Daniel
5a338206b7 fix: fully expand calculation and aggregate references for applying authorization 2024-03-22 01:10:15 -04:00
Hannes Wüthrich
00b1ef3bee
fix: batch_change/3 is never called for updates (#938)
* fix: bulk updates for streams ignore :batch_size
2024-03-21 08:40:18 -04:00