diff --git a/documentation/dsls/DSL:-AshStateMachine.cheatmd b/documentation/dsls/DSL:-AshStateMachine.cheatmd index 4e7d34e..6184264 100644 --- a/documentation/dsls/DSL:-AshStateMachine.cheatmd +++ b/documentation/dsls/DSL:-AshStateMachine.cheatmd @@ -6,29 +6,48 @@ Provides tools for defining and working with resource-backed state machines. ## state_machine +### Nested DSLs * [transitions](#state_machine-transitions) * transition + ### Options | Name | Type | Default | Docs | | --- | --- | --- | --- | +| `initial_states`* | `list(atom)` | | The allowed starting states of this state machine. | | `deprecated_states` | `list(atom)` | [] | A list of states that have been deprecated but are still valid. These will still be in the possible list of states, but `:*` will not include them. | | `extra_states` | `list(atom)` | [] | A list of states that may be used by transitions to/from `:*`. See the docs on wildcards for more. | | `state_attribute` | `atom` | :state | The attribute to store the state in. | -| `initial_states`* | `list(atom)` | | The allowed starting states of this state machine. | | `default_initial_state` | `atom` | | The default initial state | ## state_machine.transitions +### Wildcards +Use `:*` to represent "any action" when used in place of an action, or "any state" when used in place of a state. +For example: + +```elixir +transition :*, from: :*, to: :* +``` + +The full list of states is derived at compile time from the transitions. +Use the `extra_states` to express that certain types should be included +in that list even though no transitions go to/from that state explicitly. +This is necessary for cases where there are states that use `:*` and no +transition explicitly leads to that transition. + + +### Nested DSLs * [transition](#state_machine-transitions-transition) + ## state_machine.transitions.transition ```elixir transition action diff --git a/lib/ash_state_machine.ex b/lib/ash_state_machine.ex index 24f75cb..f4b7644 100644 --- a/lib/ash_state_machine.ex +++ b/lib/ash_state_machine.ex @@ -48,6 +48,8 @@ defmodule AshStateMachine do # Wildcards Use `:*` to represent "any action" when used in place of an action, or "any state" when used in place of a state. + For example: + ```elixir transition :*, from: :*, to: :* ``` diff --git a/mix.exs b/mix.exs index 0d6636a..8c4f94b 100644 --- a/mix.exs +++ b/mix.exs @@ -149,8 +149,7 @@ defmodule AshStateMachine.MixProject do defp deps do [ {:ash, "~> 2.7"}, - # {:spark, ">= 1.1.22"}, - {:spark, path: "../spark", override: true}, + {:spark, ">= 1.1.22"}, {:ex_doc, "~> 0.22", only: [:dev, :test], runtime: false}, {:ex_check, "~> 0.12.0", only: [:dev, :test]}, {:credo, ">= 0.0.0", only: [:dev, :test], runtime: false}, diff --git a/mix.lock b/mix.lock index 1533f48..31d2128 100644 --- a/mix.lock +++ b/mix.lock @@ -31,7 +31,7 @@ "picosat_elixir": {:hex, :picosat_elixir, "0.2.3", "bf326d0f179fbb3b706bb2c15fbc367dacfa2517157d090fdfc32edae004c597", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f76c9db2dec9d2561ffaa9be35f65403d53e984e8cd99c832383b7ab78c16c66"}, "sobelow": {:hex, :sobelow, "0.12.2", "45f4d500e09f95fdb5a7b94c2838d6b26625828751d9f1127174055a78542cf5", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "2f0b617dce551db651145662b84c8da4f158e7abe049a76daaaae2282df01c5d"}, "sourceror": {:hex, :sourceror, "0.13.0", "c6ecc96ee3ae0e042e9082a9550a1989ea40182492dc29024a8d9d2b136e5014", [:mix], [], "hexpm", "d0a819491061cd26bfa4450d1c84301a410c19c1782a6577ce15853fc0e7e4e1"}, - "spark": {:hex, :spark, "1.1.34", "c885265224ae0ae6f06415b65eb580589baa4c386f1faa5d07a2c88d80bed74d", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "8e098de94948a5674b5ce9bec6c1674b55d18afb62831fea58f41a99b8d0f328"}, + "spark": {:hex, :spark, "1.1.36", "a4cc1168fe94c24c90fbb3521921c4d3f9ec86642f84adc6da5ae62426189edd", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "ce03b3167f85fdc4416c9c5cee4aac4cc0ca8715d115631b68669be5e2e890f7"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},