Commit graph

893 commits

Author SHA1 Message Date
Zach Daniel
7ec98ef8ab fix: properly persist simple_notifiers 2024-05-15 16:46:16 -04:00
Zach Daniel
5b18e71738 fix: accept ids in code interfaces again 2024-05-15 15:45:58 -04:00
Zach Daniel
ad0274b0a3 improvement: add pattern matching for clarity on ref/1 and ref/2
chore: remove debug logger configuration from test
2024-05-15 11:25:54 -04:00
Zach Daniel
2681684922 improvement: add can_return_nil?/1 callback to Ash expressions 2024-05-14 17:58:13 -04:00
Zach Daniel
3263ec2ee9 fix: don't show a type error on nil for lists
closes #1166
2024-05-14 17:09:34 -04:00
Davide Briani
449da541e2
Fix: keep data's metadata in atomic update (#1165) 2024-05-14 13:17:51 -04:00
Zach Daniel
23d78ec43f improvement: use the source configuration for attributes in embedded resources
closes #1143
2024-05-14 12:32:25 -04: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
11f0f9aa03 fix: ensure that changeset filters are honored in ETS destroy/update_query
fix: in simulated bulk actions, a stale record should be ignored
fix: don't rollback transactions on stale records
2024-05-12 16:16:39 -04:00
Riccardo Binetti
1f8c27225f
chore: add failing tests for filter on stream bulk update/destroy (#1151) 2024-05-12 15:32:13 -04: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
Zach Daniel
32446b0b2e chore: fixes around policy exceptions
docs: add policy how-to guide
2024-05-10 15:26:23 -04:00
Riccardo Binetti
d5ae3f37b6
fix: ignore required pagination for relationships (#1147)
Maintain backwards compatibility
2024-05-10 11:48:10 -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
Riccardo Binetti
0e899dbbb3
improvement: add tenant to data earlier in read (#1137) 2024-05-08 09:21:01 -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
Barnabas Jovanovics
d2bfaff377
test: add test for calc deps that are forbidden (#1128) 2024-05-07 15:39:04 -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
Riccardo Binetti
7f701cfb57
chore: add failing test for calculation reuse across loads (#1127) 2024-05-07 12:28:22 -04:00
Zach Daniel
64ecdad657 fix: properly deduplicate calculations 2024-05-06 20:32:41 -04:00
Riccardo Binetti
c3c330224d
chore: add failing test for calculation loaded twice in Ash.load/3 (#1122) 2024-05-06 19:25:17 -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
Riccardo Binetti
5dfea1df9b
feat: add relationship pagination (#1050) 2024-05-04 05:56:46 -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
a26efe03e1 test: add test for requiring actor in atomic changes 2024-05-03 12:36:20 -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
Riccardo Binetti
a3418e32ef
fix: ensure only the intended failing test fails (#1105)
It was making also other tests fail
2024-05-02 19:15:26 -04:00
Riccardo Binetti
5ce12e35f8
chore: failing test for bulk update with global validations (#1104) 2024-05-02 17:18:08 -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
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
8a7a4763fd chore: update bulk create test 2024-05-01 22:13:24 -04:00
Riccardo Binetti
bb22724ef9
chore: failing tests for after_transaction hooks on bulk failures (#1090) 2024-05-01 17:34:49 -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
Riccardo Binetti
b4821f2e13
chore: failing tests for before_transaction hooks in bulk actions (#1081) 2024-04-30 20:51:39 -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
Jeremy Grant
45b76c209d
fix: union array argument/attribute handling when current attribute is (#1023) 2024-04-29 22:24:44 -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
Zach Daniel
2f1a0fec71 fix: set resource option in bulk interfaces 2024-04-27 23:56:11 -04:00
Zach Daniel
3f977ff98d improvement: simplifications and clarifications around bulk callback behavior 2024-04-27 10:14:31 -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
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
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
Jechol Lee
7ed746990a
Fixed validation tests for embedded (#1049) 2024-04-23 12:38:29 -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
fc931ab224 test: add tests for code interfaces that take maps 2024-04-20 15:14:21 +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
Riccardo Binetti
7c189ede32
fix: fix typo in load test (#1031) 2024-04-16 12:06:48 +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
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
Lukas Ender
10e3722446
fix: code_interface actions accept @context (#1016) 2024-04-12 10:26:46 -04:00
Zach Daniel
47dde10329 improvement: adding domain to embedded resource is an error 2024-04-11 22:28:47 -04:00
Zach Daniel
2474fbed44 improvement: raise more sensible error on unsupported pagination 2024-04-11 09:38:49 -04:00
Riccardo Binetti
f2236c9092
chore: failing test for strict loads on nested relationship loads (#1011) 2024-04-11 09:29:12 -04:00
Jechol Lee
0b79515f69
fix: fix date_add query function (#1010) 2024-04-11 07:42:11 -04:00
Riccardo Binetti
cd4299d6e5
chore: add failing test for calculations on private relationships (#1008) 2024-04-10 18:26:42 -04:00
Zach Daniel
829f6d6e49 improvement: support builder options in read code interfaces 2024-04-10 15:57:30 -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
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
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
5e1df439d7 chore: format 2024-04-08 12:15:09 -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
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
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
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
950ff3d060 fix: set tenant in bulk creates after setting up changeset 2024-04-04 20:34:37 -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
Riccardo Binetti
a7c865ed20
chore: changing_attributes with to field failing test (#961) 2024-03-29 17:18:45 -04:00
Dmitry Maganov
99153144c7
improvement: change type argument position in Ash.Query.calculate (#959) 2024-03-29 11:14:12 -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
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
Zach Daniel
88d0b46dec improvement: detect loaded-through types 2024-03-24 23:25:28 -04:00
Zach Daniel
ac0ff0e2e4 improvement: restore old behavior of leveraging in memory values for calculations 2024-03-24 19:25: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
Dmitry Maganov
ed4655cd83
improvement: add matches built-in policy check (#937) 2024-03-21 08:39:21 -04:00
Hannes Wüthrich
b398107ca3
fix: don't double-encode vector data (#934) 2024-03-20 16:32:45 -04:00
Tun Cham Roeun
7d7bcaa3d7
fi: fetch_count/4 use the query after applying before_action hooks (#922)
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-03-12 20:28:52 -04:00
e5f01bbd59
improvement(Ash.Reactor): Backport improvements from 3.0 branch. 2024-03-08 10:51:40 +13: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
9b88628b07
improvement: Make undo actions for update and destroy actions more explicit. (#920)
* chore(Ash.Reactor): Follow on from `get` -> `read_one` rename.

* improvement(Ash.Reactor): Make undo actions for `update` and `destroy` more explicit.
2024-03-05 11:30:35 +13:00
Zach Daniel
7f0e2d8037 improvement: rename get to read_one in Ash.Reactor 2024-03-02 16:51:00 -05: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
650205a9bc fix: ensure calculation arguments are not ignored when parsing filters
fixes #917
2024-02-29 00:41:24 -05:00
Zach Daniel
1a99098f52 fix: ensure that policies are applied to aggregates referenced in calculations 2024-02-26 13:00:12 -05:00
Zach Daniel
0e1fe24f46 fix: ensure actor context is set in filter 2024-02-25 08:24:19 -05:00
Zach Daniel
eab194fac5 fix: properly handle limit/offset for aggregates 2024-02-24 20:21:13 -05:00
Zach Daniel
0fd4e36b2e add test for read_one and limit 2024-02-23 08:46:17 -05:00
Zach Daniel
701f9b4cc6 fix: honor soft destroys for atomic bulk destroys 2024-02-22 08:02:01 -05:00
Zach Daniel
3027afe5fc fix: pass correct options into Api.stream! for bulk_destroy 2024-02-21 08:09:20 -05:00
Robert Graff
8fd0106528
test: add test for bulk_destroy with policy and query (#908) 2024-02-21 08:00:20 -05:00
Zach Daniel
944f69b16e fix: properly annotate run_flow's recursive DSL tag
docs: update spark & docs
2024-02-16 21:25:18 -05:00
Jechol Lee
3a353c2fa0
test: Reproduce run_flow is not counted as step inside map, branch (#902) 2024-02-16 20:21:22 -05: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
Jechol Lee
b4ade107cd
test: Reproduce flow custom step has no tenant in context (#901) 2024-02-16 17:47:54 -05:00
Zach Daniel
f847f0d971 test: update test w/ not_found_error? fix 2024-02-15 23:38:52 -05:00
Zach Daniel
ba2ab31f8d test: correct flow tests 2024-02-15 23:30:09 -05:00
Jechol Lee
aa7278fe79
test: Reproducing a bug where the flow does not honor tenant (#900) 2024-02-15 23:26:44 -05:00
Jechol Lee
e214043218
chore: Rename test/flow_test to test/flow (#899) 2024-02-15 23:23:57 -05:00
Jechol Lee
896725597b
test: Reproducing a bug where Flow ignores the authorization setup. (#895) 2024-02-15 08:57:11 -05: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
45999cac07 chore: test fix for after transaction hooks 2024-02-11 11:44:11 -05:00
Zach Daniel
2b7a99905c improvement: support policies requiring original data 2024-02-09 17:19:45 -05:00
Zach Daniel
0893518f39 improvement: change atomicity requirements when datalayers don't support it
test: make tests pass on 3.0
2024-02-08 15:17:32 -05:00
Dmitry Maganov
5eccdcd7f8
improvement: add on_match: :update_join to manage_relationship (#875) 2024-02-08 11:18:32 -05:00
Dmitry Maganov
d47eb086a2
fix: continue cleanup in ManagedRelationshipHelpers (#873) 2024-02-07 14:56:04 -05:00
Zach Daniel
2cd6360379 fix: fix pattern match error on certain policy conditions
improvement: various policy behavior cleanups
2024-02-06 19:30:18 -05:00
Zach Daniel
e707758c93 fix: retain metadata on updates, atomic and otherwise
fix: properly load expression -> runtime calculation deps
2024-02-01 10:21:22 -05:00
Zach Daniel
fc3cbc4e2c improvement: change nested field filtering to be done with at_path 2024-01-31 15:41:10 -05:00
Zach Daniel
f7716c5222 improvement: support referencing non-array embeds in input filters 2024-01-31 12:11:36 -05:00
Zach Daniel
6602ae63e6 fix: support expression calculations referencing runtime calculations 2024-01-30 16:34:17 -05:00
Zach Daniel
550a9c1424 chore: fix file name 2024-01-30 15:23:04 -05:00
Zach Daniel
9f748b5c55 test: update authorizer tests
fix: properly handle the case where all valid scenarios are pruned
2024-01-30 13:11:47 -05:00
Barnabas Jovanovics
406a076ef1
test: add test that shows expr condition does not work with access_type :strict (#858) 2024-01-30 12:53:23 -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
Zach Daniel
c02bced508 improvement: support loading and selecting in bulk operations 2024-01-29 14:29:50 -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
Barnabas Jovanovics
fb3e7050a1
fix: only count resources the actor is allowed to see (#853)
* fix: only count resources the actor is allowed to see

* remove specc added by vscode
2024-01-26 13:33:03 -05:00
Barnabas Jovanovics
f2994502b9
add test for selecting policy (#852) 2024-01-25 11:08:31 -05:00
Jechol Lee
0d504ec429
test: Remove unnecessary authorize?: false in belongs_to_test (#849) 2024-01-25 10:50:37 -05:00
Zach Daniel
1807523ba2 improvement: support transactions in bulk updates 2024-01-23 21:36:17 -05:00
Zach Daniel
878011bd3e improvement: count_nils/1 function
improvement: `present/absent` atomic implementation
improvement: add `atomic_ref/1` template helper
2024-01-23 19:13:14 -05:00
Nduati Kuria
d229ade9fc
Add :decimal aggregate support to DataLayer.Ets [WIP] (#841)
* Add `:decimal` aggregate support to `DataLayer.Ets`

* Add regression test

* Fix dialyzer

* Handle nils in `:avg` calculation

* Refactor nested ifs

* Refactor test
2024-01-22 16:03:34 -05:00
Zach Daniel
7aaea7bd55 fix: only load through calculations in the correct order 2024-01-20 13:53:35 -05:00
Zach Daniel
e5d78ae074 fix: get tests passing for bulk creates again 2024-01-19 10:49:26 -05:00
Zach Daniel
c48cb08026
improvement: rewrite read actions to not use Ash.Engine (#836) 2024-01-19 00:05:42 -05:00
Zach Daniel
4c96fdd40f fix: don't ignore stream batch size 2024-01-13 21:48:11 -05:00
Zach Daniel
59e50f8dfa fix: set tenant attribute in bulk create
fixes: #830
2024-01-12 08:19:55 -05:00
Jechol Lee
250c4ab8c8
improvement: support Ash.CiString in string_join (#832) 2024-01-12 00:21:30 -05:00
Zach Daniel
bbd866956d improvement: authorize each related join using join_filters 2024-01-12 00:17:37 -05:00
Rebecca Le
0a4a7c057d
feat: Allow :self as an option when requesting a relative page from a given page (#833) 2024-01-12 00:16:41 -05:00
Zach Daniel
35573a6f4e improvement: support join_filters in aggregates 2024-01-11 14:57:22 -05:00
Zach Daniel
5b82ce293f fix: authorize aggregate references in calculations 2024-01-10 07:11:02 -05:00
Alan Heywood
dbb4a38ea3
fix: only put keywords to be interpolated in message in error vars (#821)
* fix: only put keywords to be interpolated in message in error vars
---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-01-08 18:08:17 -05:00
Zach Daniel
a12131cf70 improvement: simplify aggregate loading, remove Ash.Engine from it
improvement: add atomic implementation for builtin `increment` change
improvement: simplify related path authorization, use same tool as aggregates now use
2024-01-08 15:31:09 -05:00
Zach Daniel
6061a2a16a improvement: add some atomic implementations 2024-01-03 16:48:15 -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
Dmitry Maganov
a6d381a171
test: fix typo in a test name (#815) 2023-12-28 12:07:55 -05:00
Zach Daniel
4ee80297d7 improvement: support using the new api option in actions 2023-12-27 18:14:29 -05:00
Zach Daniel
31879077b7 chore: comment out test for 3.0 fix 2023-12-27 17:48:13 -05:00
Zach Daniel
3e296a4bba Revert "chore: comment out test for now
This reverts commit cc21661559.
2023-12-27 17:47:50 -05:00
Zach Daniel
17afb821a7 fix: don't include unknown authorize? value in changesets 2023-12-27 17:37:51 -05:00
Zach Daniel
14d4e26d9c chore: remove IO.inspect 2023-12-27 17:36:09 -05:00
Zach Daniel
cc21661559 chore: comment out test for now 2023-12-27 17:28:52 -05:00
Rohan Relan
750dc17286
test: Adds a test to ensure authorization occurs when the actor is set and authorization? is by_default (#813)
Co-authored-by: Rohan Relan <roresemail@gmail.com>
2023-12-27 10:27:22 -05:00
Zach Daniel
eb05e9be63 improvement: support streaming without keyset pagination
use the new `allow_stream_with` and `stream_with` options to control
what strategy may be used to stream query results.
2023-12-21 08:35:49 -05:00
Zach Daniel
ed887413d7 improvement: base case iterative bulk destroy implemented 2023-12-20 21:08:40 -05:00
Zach Daniel
8c17434803 improvement: add iterative, streaming implementation for bulk updates 2023-12-20 17:33:43 -05:00
Zach Daniel
2233a33523 improvement: support tenancy on manual actions
docs: update cheat shets
fix: honor tenant option on aggregates

closes #805
2023-12-16 10:33:10 -05:00
Zach Daniel
3be83d6ca4 improvement: lay the groundwork for fully atomic actions 2023-12-16 10:14:02 -05:00
Zach Daniel
52a62c7c45 chore: fix tests 2023-12-15 15:45:23 -05:00
Zach Daniel
e22c6c7927 fix: ensure actions always raise an error class 2023-12-15 15:33:10 -05:00
Zach Daniel
ad22eeb7e9 improvement: rewrite creates to not use Ash.Engine 2023-12-15 15:10:01 -05:00
Thales Grilo
9d2da58fb2
improvement: Adds %Ash.NotSelected{} to ash 3 (!634) (#804)
*  create Ash.NotSelected, add test

*  add ash_three test

* 👌 fix formatting

* 👌 add missing field value

---------

Co-authored-by: thales <thales@uplearn.co.uk>
2023-12-14 16:14:15 -05:00
Robert Graff
014621cc09
test: reproduce bug casting embedded union arguments (#803) 2023-12-14 09:04:56 -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
7298a4b51b improvement: honor field policies in sort expressions 2023-12-13 15:08:39 -05:00
Zach Daniel
5c0275a78b test: add test for simple data layer pagination 2023-12-11 19:58:14 -05:00
Zach Daniel
c38cba51b0 fix: test failures and credo issue 2023-12-10 13:13:06 -05:00
Jechol Lee
30deb8c32e
test: Remove unnecessary 'authorize?: false' and explicitly specify the filter policy results. (#798) 2023-12-07 20:22:46 -05:00
Zach Daniel
c7e6133317 improvement: support embed_nil_values? for trimming down stored embeds 2023-12-06 10:29:39 -05:00
Robert Graff
636f99fb2d
test: Add test for updating embedded union values (#796) 2023-12-06 10:16:19 -05:00
Jechol Lee
7b70c3a58e
test: Fix ParentTest (#793) 2023-12-05 01:36:40 -05:00
Jechol Lee
86e171a0c1
test: various test improvements (#795) 2023-12-05 01:34:21 -05:00
Jechol Lee
728226bfee
test: Fix typo in MultitenancyTest (#789) 2023-12-01 13:02:06 -05:00
Darren Black
7106c61545
test: Failing test for Api.get (#786) 2023-11-29 20:05:36 -05:00
Zach Daniel
be935723d2 fix: properly resolve nested calculation dependencies 2023-11-24 07:23:38 -05:00
Jeremy Grant
1ce05562aa
fix: change_attribute failing on a union attribute (#778) 2023-11-20 19:10:35 -05:00
Zach Daniel
b9f804db10 fix: properly set actor context on calc expressions in ets data layer 2023-11-16 08:18:39 -05:00
Daniel Newman
8103831cf6 Bug: Actor not being passed 2023-11-15 17:05:31 -05:00
Simon Bergström
b0d5c08f5d
fix: properly include relationship name message when relationship cannot be found (#770) 2023-11-13 17:04:35 -05:00
Barnabas Jovanovics
abb0854ae9
fix: remove destroyed or unrelated data from the relationship (#767) 2023-11-13 13:58:09 -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
Zach Daniel
7b50a401d8 fix: optimize and make Ash.Type more consistent 2023-10-26 22:04:57 -04:00
Robert Graff
a48d43e79d
fix more handle change use cases (#757) 2023-10-25 17:47:50 -04:00