improvement: update spark to fix deeply nested DSLs

This commit is contained in:
Zach Daniel 2023-03-31 11:53:41 -04:00
parent b8484710bb
commit 7f1ee67dde
5 changed files with 38 additions and 20 deletions

View file

@ -1727,8 +1727,6 @@ defmodule Ash.Actions.Read do
end
true ->
IO.i()
raise Ash.Error.Framework.AssumptionFailed,
message:
"Only attribute & aggregate deps should remain at this point. Got #{inspect(other)} on #{inspect(query.resource)}"

View file

@ -210,8 +210,6 @@ defmodule Ash.Flow.Dsl do
]
}
@step_entities [@create, @debug, @update, @destroy, @validate, @read, @run_flow, @custom]
@transaction %Spark.Dsl.Entity{
name: :transaction,
describe: """
@ -222,7 +220,7 @@ defmodule Ash.Flow.Dsl do
args: [:name, :resource],
recursive_as: :steps,
entities: [
steps: @step_entities
steps: []
],
no_depend_modules: [:touches_resources],
examples: [
@ -257,7 +255,7 @@ defmodule Ash.Flow.Dsl do
recursive_as: :steps,
no_depend_modules: [:touches_resources],
entities: [
steps: @step_entities
steps: []
],
examples: [
"""
@ -286,7 +284,7 @@ defmodule Ash.Flow.Dsl do
recursive_as: :steps,
no_depend_modules: [:touches_resources],
entities: [
steps: @step_entities
steps: []
],
examples: [
"""
@ -304,14 +302,6 @@ defmodule Ash.Flow.Dsl do
]
}
transaction = %{@transaction | entities: [steps: [@branch | [@map | @step_entities]]]}
map = %{@map | entities: [steps: [@branch | [@transaction | @step_entities]]]}
branch = %{@branch | entities: [steps: [@map | [@transaction | @step_entities]]]}
@transaction transaction
@map map
@branch branch
@steps %Spark.Dsl.Section{
name: :steps,
describe: """
@ -326,7 +316,19 @@ defmodule Ash.Flow.Dsl do
"""
],
imports: [Ash.Flow.StepHelpers],
entities: [@map, @transaction, @branch] ++ @step_entities
entities: [
@map,
@branch,
@transaction,
@create,
@debug,
@update,
@destroy,
@validate,
@read,
@run_flow,
@custom
]
}
@transformers [

View file

@ -273,7 +273,7 @@ defmodule Ash.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:spark, "~> 0.3 and >= 0.3.12"},
{:spark, "~> 1.0"},
{:ecto, "~> 3.7"},
{:ets, "~> 0.8.0"},
{:decimal, "~> 2.0"},

View file

@ -24,15 +24,15 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"mime": {:hex, :mime, "2.0.3", "3676436d3d1f7b81b5a2d2bd8405f412c677558c81b1c92be58c00562bb59095", [:mix], [], "hexpm", "27a30bf0db44d25eecba73755acf4068cbfe26a4372f9eb3e4ea3a45956bff6b"},
"mix_test_watch": {:hex, :mix_test_watch, "1.1.0", "330bb91c8ed271fe408c42d07e0773340a7938d8a0d281d57a14243eae9dc8c3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "52b6b1c476cbb70fd899ca5394506482f12e5f6b0d6acff9df95c7f1e0812ec3"},
"nimble_options": {:hex, :nimble_options, "0.5.2", "42703307b924880f8c08d97719da7472673391905f528259915782bb346e0a1b", [:mix], [], "hexpm", "4da7f904b915fd71db549bcdc25f8d56f378ef7ae07dc1d372cbe72ba950dce0"},
"nimble_options": {:hex, :nimble_options, "1.0.1", "b448018287b22584e91b5fd9c6c0ad717cb4bcdaa457957c8d57770f56625c43", [:mix], [], "hexpm", "078b2927cd9f84555be6386d56e849b0c555025ecccf7afee00ab6a9e6f63837"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
"picosat_elixir": {:hex, :picosat_elixir, "0.2.0", "1c9d2d65b32039c9e3eb600bff903579e5916f559dbf0013b3c4ca617c93ac64", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "7900c6d58d65a9d8a2899f53019fb70e9b9678161bbb53f646e28e146aca138c"},
"plug": {:hex, :plug, "1.13.6", "187beb6b67c6cec50503e940f0434ea4692b19384d47e5fdfd701e93cadb4cc2", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02b9c6b9955bce92c829f31d6284bf53c591ca63c4fb9ff81dfd0418667a34ff"},
"plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
"sobelow": {:hex, :sobelow, "0.11.1", "23438964486f8112b41e743bbfd402da3e5b296fdc9eacab29914b79c48916dd", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "9897363a7eff96f4809304a90aad819e2ad5e5d24db547af502885146746a53c"},
"sourceror": {:hex, :sourceror, "0.12.0", "b0a43f9b91d69fead8ffa307e203fadaf30001d8c2643f597518dd9508d6b32d", [:mix], [], "hexpm", "67dcc48a4d4bb8c397ad0b86cf0d4667e1b50ffdf31cda585524640d1caded85"},
"spark": {:hex, :spark, "0.3.12", "6754698b5aa27358365fff88e3c5c3abc138e165fbc394cf482e39779ee92cd6", [:mix], [{:nimble_options, "~> 0.5", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "27f13b604ddaf1d2b3b6ce5b3a21ed170e2f1235e167ab6fb8c2c33c8165d545"},
"sourceror": {:hex, :sourceror, "0.12.2", "2ae55efd149193572e0eb723df7c7a1bda9ab33c43373c82642931dbb2f4e428", [:mix], [], "hexpm", "7ad74ade6fb079c71f29fae10c34bcf2323542d8c51ee1bcd77a546cfa89d59c"},
"spark": {:hex, :spark, "1.0.0", "83ad8862178198deaab902f93c63e9e9a9f69ec966ca1c089a552070db815267", [:mix], [{:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "81d77b16186688a8c92e16211c63bc02e4da9a52dcdcd4b6586b0bde50f14890"},
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
"stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"},
"telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"},

View file

@ -0,0 +1,18 @@
defmodule Ash.Test.Flow.Flows.DeeplyNested do
@moduledoc false
use Ash.Flow
steps do
transaction :foo do
branch :bar, true do
custom :baz, fn _, _ -> {:ok, true} end
end
map :biz, [1, 2, 3] do
branch :beef, true do
custom :belt, fn _, _ -> {:ok, true} end
end
end
end
end
end