improvemnt: upgrade to ash 2.0

This commit is contained in:
Zach Daniel 2022-08-18 15:24:51 -04:00
parent 443342c76f
commit 5723a449a7
6 changed files with 30 additions and 27 deletions

View file

@ -51,10 +51,10 @@ defmodule AshPhoenix.FilterForm do
Create a new filter form.
Options:
#{Ash.OptionsHelpers.docs(@new_opts)}
#{Spark.OptionsHelpers.docs(@new_opts)}
"""
def new(resource, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @new_opts)
opts = Spark.OptionsHelpers.validate!(opts, @new_opts)
params = opts[:params]
params = sanitize_params(params)
@ -519,10 +519,10 @@ defmodule AshPhoenix.FilterForm do
Options:
#{Ash.OptionsHelpers.docs(@add_predicate_opts)}
#{Spark.OptionsHelpers.docs(@add_predicate_opts)}
"""
def add_predicate(form, field, operator_or_function, value, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @add_predicate_opts)
opts = Spark.OptionsHelpers.validate!(opts, @add_predicate_opts)
predicate_id = Ash.UUID.generate()
@ -681,10 +681,10 @@ defmodule AshPhoenix.FilterForm do
Options:
#{Ash.OptionsHelpers.docs(@add_group_opts)}
#{Spark.OptionsHelpers.docs(@add_group_opts)}
"""
def add_group(form, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @add_group_opts)
opts = Spark.OptionsHelpers.validate!(opts, @add_group_opts)
group_id = Ash.UUID.generate()
group = %__MODULE__{operator: opts[:operator], id: group_id}

View file

@ -80,7 +80,7 @@ defmodule AshPhoenix.Form.Auto do
]
def auto(resource, action, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @auto_opts)
opts = Spark.OptionsHelpers.validate!(opts, @auto_opts)
Keyword.new(related(resource, action, opts) ++ embedded(resource, action, opts))
end

View file

@ -338,7 +338,7 @@ defmodule AshPhoenix.Form do
{opts, extra} = Keyword.split(opts, keys)
opts = Ash.OptionsHelpers.validate!(opts, schema)
opts = Spark.OptionsHelpers.validate!(opts, schema)
Keyword.merge(opts, extra)
end
@ -379,7 +379,7 @@ defmodule AshPhoenix.Form do
Creates a form corresponding to a create action on a resource.
Options:
#{Ash.OptionsHelpers.docs(@for_opts)}
#{Spark.OptionsHelpers.docs(@for_opts)}
Any *additional* options will be passed to the underlying call to `Ash.Changeset.for_create/4`. This means
you can set things like the tenant/actor. These will be retained, and provided again when `Form.submit/3` is called.
@ -392,7 +392,7 @@ defmodule AshPhoenix.Form do
manipulation of the auto forms, you can also call `AshPhoenix.Form.Auto.auto/2`, and then manipulate the
result and pass it to the `forms` option.
#{Ash.OptionsHelpers.docs(@nested_form_opts)}
#{Spark.OptionsHelpers.docs(@nested_form_opts)}
"""
@spec for_create(Ash.Resource.t(), action :: atom, opts :: Keyword.t()) :: t()
def for_create(resource, action, opts \\ []) when is_atom(resource) do
@ -466,7 +466,7 @@ defmodule AshPhoenix.Form do
Creates a form corresponding to an update action on a record.
Options:
#{Ash.OptionsHelpers.docs(@for_opts)}
#{Spark.OptionsHelpers.docs(@for_opts)}
Any *additional* options will be passed to the underlying call to `Ash.Changeset.for_update/4`. This means
you can set things like the tenant/actor. These will be retained, and provided again when `Form.submit/3` is called.
@ -548,7 +548,7 @@ defmodule AshPhoenix.Form do
Creates a form corresponding to a destroy action on a record.
Options:
#{Ash.OptionsHelpers.docs(@for_opts)}
#{Spark.OptionsHelpers.docs(@for_opts)}
Any *additional* options will be passed to the underlying call to `Ash.Changeset.for_destroy/4`. This means
you can set things like the tenant/actor. These will be retained, and provided again when `Form.submit/3` is called.
@ -630,7 +630,7 @@ defmodule AshPhoenix.Form do
Creates a form corresponding to a read action on a resource.
Options:
#{Ash.OptionsHelpers.docs(@for_opts)}
#{Spark.OptionsHelpers.docs(@for_opts)}
Any *additional* options will be passed to the underlying call to `Ash.Query.for_read/4`. This means
you can set things like the tenant/actor. These will be retained, and provided again when `Form.submit/3` is called.
@ -641,7 +641,7 @@ defmodule AshPhoenix.Form do
## Nested Form Options
#{Ash.OptionsHelpers.docs(@nested_form_opts)}
#{Spark.OptionsHelpers.docs(@nested_form_opts)}
"""
@spec for_read(Ash.Resource.t(), action :: atom, opts :: Keyword.t()) :: t()
def for_read(resource, action, opts \\ []) when is_atom(resource) do
@ -783,7 +783,7 @@ defmodule AshPhoenix.Form do
Options:
#{Ash.OptionsHelpers.docs(@validate_opts)}
#{Spark.OptionsHelpers.docs(@validate_opts)}
"""
@spec validate(t(), map, Keyword.t()) :: t()
def validate(form, new_params, opts \\ []) do
@ -1309,7 +1309,7 @@ defmodule AshPhoenix.Form do
Options:
#{Ash.OptionsHelpers.docs(@submit_opts)}
#{Spark.OptionsHelpers.docs(@submit_opts)}
"""
@spec submit(t(), Keyword.t()) ::
{:ok, Ash.Resource.record() | nil | list(Ash.Notifier.Notification.t())}
@ -1347,7 +1347,7 @@ defmodule AshPhoenix.Form do
"""
end
case Ash.Api.resource(form.api, form.resource) do
case Ash.Api.Info.resource(form.api, form.resource) do
{:ok, _} ->
:ok
@ -1515,7 +1515,7 @@ defmodule AshPhoenix.Form do
@spec update_form(t(), list(atom | integer) | String.t(), (t() -> t())) :: t()
def update_form(form, path, func, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @update_form_opts)
opts = Spark.OptionsHelpers.validate!(opts, @update_form_opts)
path =
case path do
@ -1675,7 +1675,7 @@ defmodule AshPhoenix.Form do
By default, only errors on the form being passed in (not nested forms) are provided.
Use `for_path` to get errors for nested forms.
#{Ash.OptionsHelpers.docs(@errors_opts)}
#{Spark.OptionsHelpers.docs(@errors_opts)}
"""
@spec errors(t(), Keyword.t()) ::
([{atom, {String.t(), Keyword.t()}}]
@ -2105,11 +2105,11 @@ defmodule AshPhoenix.Form do
`add_form` with not string keys/values you may not be able to depend on the shape of the `params` map (which you should ideally
not depend on anyway).
#{Ash.OptionsHelpers.docs(@add_form_opts)}
#{Spark.OptionsHelpers.docs(@add_form_opts)}
"""
@spec add_form(t(), String.t() | list(atom | integer), Keyword.t()) :: t()
def add_form(form, path, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @add_form_opts)
opts = Spark.OptionsHelpers.validate!(opts, @add_form_opts)
form =
if is_binary(path) do
@ -2155,7 +2155,7 @@ defmodule AshPhoenix.Form do
```
"""
def remove_form(form, path, opts \\ []) do
opts = Ash.OptionsHelpers.validate!(opts, @remove_form_opts)
opts = Spark.OptionsHelpers.validate!(opts, @remove_form_opts)
if has_form?(form, path) do
form =

View file

@ -26,7 +26,7 @@ defmodule AshPhoenix.SubdomainPlug do
Options:
#{Ash.OptionsHelpers.docs(@plug_options)}
#{Spark.OptionsHelpers.docs(@plug_options)}
To plug it on your router, you can use:
plug Ash.SubdomainPlug,
@ -58,7 +58,7 @@ defmodule AshPhoenix.SubdomainPlug do
alias Plug.Conn
@doc false
def init(opts), do: Ash.OptionsHelpers.validate!(opts, @plug_options)
def init(opts), do: Spark.OptionsHelpers.validate!(opts, @plug_options)
@doc false
def call(conn, opts) do

View file

@ -72,7 +72,8 @@ defmodule AshPhoenix.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:ash, ash_version("~> 1.53 and >= 1.53.3")},
# {:ash, ash_version("~> 1.53 and >= 1.53.3")},
{:ash, github: "ash-project/ash", branch: "2.0"},
{:phoenix, "~> 1.5.6 or ~> 1.6.0"},
{:phoenix_html, "~> 2.14 or ~> 3.0"},
{:phoenix_live_view, "~> 0.15"},

View file

@ -1,5 +1,5 @@
%{
"ash": {:hex, :ash, "1.53.3", "342b43d4f2bdf83b88f6614084694559f768ea08ab24a6a93f2ed7982cdd50e4", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: true]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8.0", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.3.5", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.9", [hex: :sourceror, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.5.0", [hex: :stream_data, repo: "hexpm", optional: false]}], "hexpm", "a7d4f532cc35a4a3d600da4d8dd01e7141a1e7770451ef3d31165defb2c37a30"},
"ash": {:git, "https://github.com/ash-project/ash.git", "e975522d1fdb79534ae2857ecd8bc0c6821150a7", [branch: "2.0"]},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"},
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
@ -20,13 +20,14 @@
"hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"libgraph": {:hex, :libgraph, "0.13.3", "20732b7bafb933dcf7351c479e03076ebd14a85fd3202c67a1c197f4f7c2466b", [:mix], [], "hexpm", "78f2576eef615440b46f10060b1de1c86640441422832052686df53dc3c148c6"},
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mime": {:hex, :mime, "2.0.2", "0b9e1a4c840eafb68d820b0e2158ef5c49385d17fb36855ac6e7e087d4b1dcc5", [:mix], [], "hexpm", "e6a3f76b4c277739e36c2e21a2c640778ba4c3846189d5ab19f97f126df5f9b7"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"nimble_options": {:hex, :nimble_options, "0.3.7", "1e52dd7673d36138b1a5dede183b5d86dff175dc46d104a8e98e396b85b04670", [:mix], [], "hexpm", "2086907e6665c6b6579be54ef5001928df5231f355f71ed258f80a55e9f63633"},
"nimble_options": {:hex, :nimble_options, "0.4.0", "c89babbab52221a24b8d1ff9e7d838be70f0d871be823165c94dd3418eea728f", [:mix], [], "hexpm", "e6701c1af326a11eea9634a3b1c62b475339ace9456c1a23ec3bc9a847bca02d"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"phoenix": {:hex, :phoenix, "1.6.9", "648e660040cdc758c5401972e0f592ce622d4ce9cd16d2d9c33dda32d0c9f7fa", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "be2fe497597d6bf297dcbf9f4416b4929dbfbdcc25edc1acf6d4dcaecbe898a6"},
@ -39,6 +40,7 @@
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
"sobelow": {:hex, :sobelow, "0.11.1", "23438964486f8112b41e743bbfd402da3e5b296fdc9eacab29914b79c48916dd", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9897363a7eff96f4809304a90aad819e2ad5e5d24db547af502885146746a53c"},
"sourceror": {:hex, :sourceror, "0.11.2", "549ce48be666421ac60cfb7f59c8752e0d393baa0b14d06271d3f6a8c1b027ab", [:mix], [], "hexpm", "9ab659118896a36be6eec68ff7b0674cba372fc8e210b1e9dc8cf2b55bb70dfb"},
"spark": {:hex, :spark, "0.1.11", "7415e7775d4cc9ed898bf082e60cfa2bdebd71a690c09b5f92b6f8f05d6be992", [:mix], [{:libgraph, "~> 0.13.3", [hex: :libgraph, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "1c4df53d53f952a8f6cb7876b6499032870f0eceb8ef55e48aa0b3bc61a5eba0"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},