Compare commits

...

2 commits

Author SHA1 Message Date
James Harton 076fb4f171
chore: release version v0.5.0-rc.0
Some checks failed
continuous-integration/drone Build is failing
2024-03-28 10:05:43 +13:00
James Harton 82aee71a04
feat!: Ash 3.0 support. (#42) 2024-03-28 10:04:54 +13:00
23 changed files with 105 additions and 77 deletions

View file

@ -1,7 +1,7 @@
spark_locals_without_parens = [
api: 1,
attribute: 2,
attribute: 3,
domain: 1,
factory: 1,
factory: 2,
factory: 3

View file

@ -1,2 +1,2 @@
elixir 1.16.2
elixir 1.16.2-otp-26
erlang 26.2.3

View file

@ -5,6 +5,13 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.5.0-rc.0](https://harton.dev/james/smokestack/compare/v0.4.2...v0.5.0-rc.0) (2024-03-27)
### Breaking Changes:
* Ash 3.0 support. (#42)
## [v0.4.2](https://harton.dev/james/smokestack/compare/v0.4.1...v0.4.2) (2024-03-22)

View file

@ -38,7 +38,7 @@ add it directly to your `mix.exs`:
```elixir
def deps do
[
{:smokestack, "~> 0.4.2"},
{:smokestack, "~> 0.5.0-rc.0"},
]
end
```

View file

@ -30,7 +30,7 @@ The DSL definition for the Smokestack DSL.
---
* `:api` (`t:atom/0`) - The default Ash API to use when evaluating loads
* `:domain` (module that adopts `Ash.Domain`) - The default Ash Domain to use when evaluating loads
@ -42,9 +42,9 @@ Define factories for a resource
* `:api` (`t:atom/0`) - The Ash API to use when evaluating loads
* `:domain` (module that adopts `Ash.Domain`) - The Ash Domain to use when evaluating loads
* `:resource` (`t:atom/0`) - Required. An Ash Resource
* `:resource` (module that adopts `Ash.Resource`) - Required. An Ash Resource
* `:variant` (`t:atom/0`) - The name of a factory variant The default value is `:default`.
@ -89,7 +89,7 @@ Define factories for a resource
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`api`](#smokestack-api){: #smokestack-api } | `module` | | The default Ash API to use when evaluating loads |
| [`domain`](#smokestack-domain){: #smokestack-domain } | `module` | | The default Ash Domain to use when evaluating loads |
@ -117,7 +117,7 @@ Define factories for a resource
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`api`](#smokestack-factory-api){: #smokestack-factory-api } | `module` | | The Ash API to use when evaluating loads |
| [`domain`](#smokestack-factory-domain){: #smokestack-factory-domain } | `module` | | The Ash Domain to use when evaluating loads |
## smokestack.factory.attribute
@ -137,7 +137,7 @@ attribute name, generator
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`name`](#smokestack-factory-attribute-name){: #smokestack-factory-attribute-name .spark-required} | `atom` | | The name of the target attribute |
| [`generator`](#smokestack-factory-attribute-generator){: #smokestack-factory-attribute-generator .spark-required} | `(-> any) \| mfa \| (any -> any) \| mfa \| (any, any -> any) \| mfa` | | A function which can generate an appropriate value for the attribute.œ |
| [`generator`](#smokestack-factory-attribute-generator){: #smokestack-factory-attribute-generator .spark-required} | `(-> any) \| mfa \| (any -> any) \| mfa \| (any, any -> any) \| mfa \| Smokestack.Template.Choose \| Smokestack.Template.Constant \| Smokestack.Template.Cycle \| Smokestack.Template.NTimes \| Smokestack.Template.Sequence` | | A function which can generate an appropriate value for the attribute.œ |

View file

@ -4,7 +4,7 @@ defmodule Smokestack.Builder do
"""
alias Smokestack.Dsl.Factory
alias Spark.OptionsHelpers
alias Spark.Options
@type result :: any
@type error :: any
@ -18,7 +18,7 @@ defmodule Smokestack.Builder do
@doc """
Provide a schema for validating options.
"""
@callback option_schema(nil | Factory.t()) :: {:ok, OptionsHelpers.schema()} | {:error, any}
@callback option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, any}
@doc """
Given a builder and a factory, validate it's options and call the builder.
@ -26,7 +26,7 @@ defmodule Smokestack.Builder do
@spec build(t, Factory.t(), Keyword.t()) :: {:ok, result} | {:error, error}
def build(builder, factory, options) do
with {:ok, schema} <- builder.option_schema(factory),
{:ok, options} <- OptionsHelpers.validate(options, schema) do
{:ok, options} <- Options.validate(options, schema) do
builder.build(factory, options)
end
end
@ -37,6 +37,6 @@ defmodule Smokestack.Builder do
@spec docs(t, nil | Factory.t()) :: String.t()
def docs(builder, factory) do
{:ok, schema} = builder.option_schema(factory)
OptionsHelpers.docs(schema)
Options.docs(schema)
end
end

View file

@ -5,7 +5,7 @@ defmodule Smokestack.FactoryBuilder do
alias Ash.Resource
alias Smokestack.{Builder, Dsl.Attribute, Dsl.Factory, Template}
alias Spark.OptionsHelpers
alias Spark.Options
@behaviour Builder
@type option :: attrs_option
@ -42,8 +42,7 @@ defmodule Smokestack.FactoryBuilder do
@doc false
@impl true
@spec option_schema(nil | Factory.t()) ::
{:ok, OptionsHelpers.schema()} | {:error, error}
@spec option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, error}
def option_schema(factory) do
attr_keys =
if factory do

View file

@ -4,7 +4,7 @@ defmodule Smokestack.ManyBuilder do
"""
alias Smokestack.{Builder, Dsl.Factory, RelatedBuilder}
alias Spark.OptionsHelpers
alias Spark.Options
@behaviour Builder
@type option :: count_option | RelatedBuilder.option()
@ -30,7 +30,7 @@ defmodule Smokestack.ManyBuilder do
@doc false
@impl true
@spec option_schema(nil | Factory.t()) :: {:ok, OptionsHelpers.schema()} | {:error, error}
@spec option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, error}
def option_schema(factory) do
with {:ok, related_schema} <- RelatedBuilder.option_schema(factory) do
schema =
@ -53,7 +53,7 @@ defmodule Smokestack.ManyBuilder do
"""
]
]
|> OptionsHelpers.merge_schemas(related_schema, "Options for building relationships")
|> Options.merge(related_schema, "Options for building relationships")
{:ok, schema}
end

View file

@ -4,7 +4,7 @@ defmodule Smokestack.ParamBuilder do
"""
alias Smokestack.{Builder, Dsl.Factory, ManyBuilder, RelatedBuilder}
alias Spark.OptionsHelpers
alias Spark.Options
@behaviour Builder
@type option ::
@ -69,7 +69,7 @@ defmodule Smokestack.ParamBuilder do
@doc false
@impl true
@spec option_schema(nil | Factory.t()) :: {:ok, OptionsHelpers.schema()} | {:error, error}
@spec option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, error}
def option_schema(factory) do
with {:ok, related_schema} <- RelatedBuilder.option_schema(factory),
{:ok, many_schema} <- ManyBuilder.option_schema(factory) do
@ -178,8 +178,8 @@ defmodule Smokestack.ParamBuilder do
schema =
our_schema
|> OptionsHelpers.merge_schemas(many_schema, "Options for building multiple instances")
|> OptionsHelpers.merge_schemas(related_schema, "Options for building relationships")
|> Options.merge(many_schema, "Options for building multiple instances")
|> Options.merge(related_schema, "Options for building relationships")
{:ok, schema}
end

View file

@ -5,7 +5,7 @@ defmodule Smokestack.RecordBuilder do
alias Ash.{Resource, Seed}
alias Smokestack.{Builder, Dsl.Factory, ManyBuilder, RelatedBuilder}
alias Spark.OptionsHelpers
alias Spark.Options
@behaviour Builder
@type option :: load_option | ManyBuilder.option() | RelatedBuilder.option()
@ -31,7 +31,7 @@ defmodule Smokestack.RecordBuilder do
@doc false
@impl true
@spec option_schema(nil | Factory.t()) :: {:ok, OptionsHelpers.schema()} | {:error, error}
@spec option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, error}
def option_schema(factory) do
with {:ok, related_schema} <- RelatedBuilder.option_schema(factory),
{:ok, many_schema} <- ManyBuilder.option_schema(factory) do
@ -87,8 +87,8 @@ defmodule Smokestack.RecordBuilder do
"""
]
]
|> OptionsHelpers.merge_schemas(many_schema, "Options for building multiple instances")
|> OptionsHelpers.merge_schemas(related_schema, "Options for building relationships")
|> Options.merge(many_schema, "Options for building multiple instances")
|> Options.merge(related_schema, "Options for building relationships")
{:ok, schema}
end
@ -143,9 +143,9 @@ defmodule Smokestack.RecordBuilder do
defp maybe_load(record_or_records, _factory, []), do: {:ok, record_or_records}
defp maybe_load(_record_or_records, factory, _load) when is_nil(factory.api),
do: {:error, "Unable to perform `load` operation without an API."}
defp maybe_load(_record_or_records, factory, _load) when is_nil(factory.domain),
do: {:error, "Unable to perform `load` operation without an Domain."}
defp maybe_load(record_or_records, factory, load),
do: factory.api.load(record_or_records, load, [])
do: Ash.load(record_or_records, load, domain: factory.domain)
end

View file

@ -6,7 +6,7 @@ defmodule Smokestack.RelatedBuilder do
alias Ash.Resource
alias Smokestack.{Builder, Dsl.Factory, Dsl.Info, FactoryBuilder}
alias Spark.OptionsHelpers
alias Spark.Options
@behaviour Builder
@type option :: build_option | FactoryBuilder.option()
@ -32,7 +32,7 @@ defmodule Smokestack.RelatedBuilder do
@doc false
@impl true
@spec option_schema(nil | Factory.t()) :: {:ok, OptionsHelpers.schema()} | {:error, error}
@spec option_schema(nil | Factory.t()) :: {:ok, Options.schema()} | {:error, error}
def option_schema(factory) do
with {:ok, factory_schema} <- FactoryBuilder.option_schema(factory) do
build_type =
@ -95,7 +95,7 @@ defmodule Smokestack.RelatedBuilder do
"""
]
]
|> OptionsHelpers.merge_schemas(factory_schema, "Options for building instances")
|> Options.merge(factory_schema, "Options for building instances")
{:ok, schema}
end

View file

@ -7,10 +7,10 @@ defmodule Smokestack.Dsl do
top_level?: true,
entities: Factory.__entities__(),
schema: [
api: [
type: {:behaviour, Ash.Api},
domain: [
type: {:behaviour, Ash.Domain},
required: false,
doc: "The default Ash API to use when evaluating loads"
doc: "The default Ash Domain to use when evaluating loads"
]
]
}

View file

@ -33,7 +33,19 @@ defmodule Smokestack.Dsl.Attribute do
doc: "The name of the target attribute"
],
generator: [
type: {:or, [{:mfa_or_fun, 0}, {:mfa_or_fun, 1}, {:mfa_or_fun, 2}]},
type:
{:or,
[
{:mfa_or_fun, 0},
{:mfa_or_fun, 1},
{:mfa_or_fun, 2},
# {:protocol, Smokestack.Template}
{:struct, Smokestack.Template.Choose},
{:struct, Smokestack.Template.Constant},
{:struct, Smokestack.Template.Cycle},
{:struct, Smokestack.Template.NTimes},
{:struct, Smokestack.Template.Sequence}
]},
required: true,
doc: """
A function which can generate an appropriate value for the attribute.œ

View file

@ -6,8 +6,8 @@ defmodule Smokestack.Dsl.Factory do
"""
defstruct __identifier__: nil,
api: nil,
attributes: [],
domain: nil,
module: nil,
resource: nil,
variant: :default
@ -18,10 +18,10 @@ defmodule Smokestack.Dsl.Factory do
@type t :: %__MODULE__{
__identifier__: any,
api: nil,
attributes: [Attribute.t()],
resource: Resource.t(),
domain: nil,
module: module,
resource: Resource.t(),
variant: atom
}
@ -37,10 +37,10 @@ defmodule Smokestack.Dsl.Factory do
imports: [Template],
identifier: {:auto, :unique_integer},
schema: [
api: [
type: {:behaviour, Ash.Api},
domain: [
type: {:behaviour, Ash.Domain},
required: false,
doc: "The Ash API to use when evaluating loads"
doc: "The Ash Domain to use when evaluating loads"
],
resource: [
type: {:behaviour, Ash.Resource},

View file

@ -1,6 +1,7 @@
defmodule Smokestack.Dsl.Transformer do
@moduledoc false
alias Ash.Resource.Info
alias Smokestack.Dsl.Factory
alias Spark.{Dsl, Dsl.Transformer, Error.DslError}
use Transformer
@ -9,20 +10,20 @@ defmodule Smokestack.Dsl.Transformer do
@spec transform(Dsl.t()) :: {:ok, Dsl.t()} | {:error, DslError.t()}
def transform(dsl_state) do
module = Transformer.get_persisted(dsl_state, :module)
api = Transformer.get_option(dsl_state, [:smokestack], :api)
default_domain = Transformer.get_option(dsl_state, [:smokestack], :domain)
dsl_state =
dsl_state
|> Transformer.get_entities([:smokestack])
|> Enum.reduce(dsl_state, fn
entity, dsl_state when is_struct(entity, Factory) ->
entity =
resource_domain = Info.domain(entity.resource)
entity = %{
entity
|> Map.put(:module, module)
|> Map.update(:api, api, fn
nil -> api
api -> api
end)
| module: module,
domain: entity.domain || resource_domain || default_domain
}
Transformer.replace_entity(dsl_state, [:smokestack], entity)

View file

@ -1,7 +1,7 @@
defmodule Smokestack.MixProject do
use Mix.Project
@version "0.4.2"
@version "0.5.0-rc.0"
@moduledoc """
Test factories for Ash resources.
@ -93,7 +93,7 @@ defmodule Smokestack.MixProject do
opts = [only: ~w[dev test]a, runtime: false]
[
{:ash, "~> 2.13"},
{:ash, "== 3.0.0-rc.0"},
{:credo, "~> 1.7", opts},
{:dialyxir, "~> 1.3", opts},
{:doctor, "~> 0.21", opts},
@ -104,7 +104,7 @@ defmodule Smokestack.MixProject do
{:git_ops, "~> 2.6", opts},
{:mix_audit, "~> 2.1", opts},
{:recase, "~> 0.7"},
{:spark, "< 3.0.0"}
{:spark, "~> 2.1"}
]
end

View file

@ -1,5 +1,5 @@
%{
"ash": {:hex, :ash, "2.14.1", "6155726db368b7e3d13087a5178fd3b3464a5db8fe52bc9b1c1be79bd5366c15", [: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]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: false]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:spark, ">= 1.1.20 and < 2.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.5.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6f43e19c53a6239d474ae813842b613405d477f29d2aef2d24d3ae2f5711b392"},
"ash": {:hex, :ash, "3.0.0-rc.0", "5acbfff801258624320dad950b07ea20ac6d8fe06a197d96c806d0bc5567c1b1", [:mix], [{:comparable, "~> 1.0", [hex: :comparable, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.8", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.1.7 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 0.6", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e0ff1ba71b7096480da0a1472b95de7b73b88971eeb78a20779ed2bbba532df8"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"comparable": {:hex, :comparable, "1.0.0", "bb669e91cedd14ae9937053e5bcbc3c52bb2f22422611f43b6e38367d94a495f", [:mix], [{:typable, "~> 0.1", [hex: :typable, repo: "hexpm", optional: false]}], "hexpm", "277c11eeb1cd726e7cd41c6c199e7e52fa16ee6830b45ad4cdc62e51f62eb60c"},
"credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"},
@ -8,10 +8,9 @@
"doctor": {:hex, :doctor, "0.21.0", "20ef89355c67778e206225fe74913e96141c4d001cb04efdeba1a2a9704f1ab5", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "a227831daa79784eb24cdeedfa403c46a4cb7d0eab0e31232ec654314447e4e0"},
"earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"},
"elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"},
"ecto": {:hex, :ecto, "3.11.2", "e1d26be989db350a633667c5cda9c3d115ae779b66da567c68c80cfb26a8c9ee", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c38bca2c6f8d8023f2145326cc8a80100c3ffe4dcbd9842ff867f7fc6156c65"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ets": {:hex, :ets, "0.8.1", "8ff9bcda5682b98493f8878fc9dbd990e48d566cba8cce59f7c2a78130da29ea", [:mix], [], "hexpm", "6be41b50adb5bc5c43626f25ea2d0af1f4a242fb3fad8d53f0c67c20b78915cc"},
"ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"},
"ex_check": {:hex, :ex_check, "0.16.0", "07615bef493c5b8d12d5119de3914274277299c6483989e52b0f6b8358a26b5f", [:mix], [], "hexpm", "4d809b72a18d405514dda4809257d8e665ae7cf37a7aee3be6b74a34dec310f5"},
"ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"},
"faker": {:hex, :faker, "0.18.0", "943e479319a22ea4e8e39e8e076b81c02827d9302f3d32726c5bf82f430e6e14", [:mix], [], "hexpm", "bfbdd83958d78e2788e99ec9317c4816e651ad05e24cfd1196ce5db5b3e81797"},
@ -19,17 +18,18 @@
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
"git_ops": {:hex, :git_ops, "2.6.0", "e0791ee1cf5db03f2c61b7ebd70e2e95cba2bb9b9793011f26609f22c0900087", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "b98fca849b18aaf490f4ac7d1dd8c6c469b0cc3e6632562d366cab095e666ffe"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},
"makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.5", "e0ff5a7c708dda34311f7522a8758e23bfcd7d8d8068dc312b5eb41c6fd76eba", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "94d2e986428585a21516d7d7149781480013c56e30c6a233534bedf38867a59a"},
"mix_audit": {:hex, :mix_audit, "2.1.3", "c70983d5cab5dca923f9a6efe559abfb4ec3f8e87762f02bab00fa4106d17eda", [:make, :mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "8c3987100b23099aea2f2df0af4d296701efd031affb08d0746b2be9e35988ec"},
"nimble_options": {:hex, :nimble_options, "1.1.0", "3b31a57ede9cb1502071fade751ab0c7b8dbe75a9a4c2b5bbb0943a690b63172", [:mix], [], "hexpm", "8bbbb3941af3ca9acc7835f5655ea062111c9c27bcac53e004460dfd19008a99"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"picosat_elixir": {:hex, :picosat_elixir, "0.2.3", "bf326d0f179fbb3b706bb2c15fbc367dacfa2517157d090fdfc32edae004c597", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f76c9db2dec9d2561ffaa9be35f65403d53e984e8cd99c832383b7ab78c16c66"},
"reactor": {:hex, :reactor, "0.8.1", "1aec71d16083901277727c8162f6dd0f07e80f5ca98911b6ef4f2c95e6e62758", [:mix], [{:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ae3936d97a3e4a316744f70c77b85345b08b70da334024c26e6b5eb8ede1246b"},
"recase": {:hex, :recase, "0.7.0", "3f2f719f0886c7a3b7fe469058ec539cb7bbe0023604ae3bce920e186305e5ae", [:mix], [], "hexpm", "36f5756a9f552f4a94b54a695870e32f4e72d5fad9c25e61bc4a3151c08a4e0c"},
"sourceror": {:hex, :sourceror, "1.0.2", "c5e86fdc14881f797749d1fe5df017ca66727a8146e7ee3e736605a3df78f3e6", [:mix], [], "hexpm", "832335e87d0913658f129d58b2a7dc0490ddd4487b02de6d85bca0169ec2bd79"},
"spark": {:hex, :spark, "1.1.55", "d20c3f899b23d841add29edc912ffab4463d3bb801bc73448738631389291d2e", [: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, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "bbc15a4223d8e610c81ceca825d5d0bae3738d1c4ac4dbb1061749966776c3f1"},
"stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"},
"spark": {:hex, :spark, "2.1.7", "72a199e905badb7b43ab6931df1d2c75bc12641fae02ff5e6374033886b07c9b", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "0e4c6879f3f4a6c76fbaae51bc31efb90c48c3267c1f6159b4418df8442c8200"},
"splode": {:hex, :splode, "0.2.0", "a1f3b5a8e7c957be495bf0f22dd9e0567a87ec63559963a0ce0c3f0e8dfacedc", [:mix], [], "hexpm", "7cfecc5913ff7feeb04f143e2494cfa7bc6d5bb5bec70f7ffac94c18ea97f303"},
"stream_data": {:hex, :stream_data, "0.6.0", "e87a9a79d7ec23d10ff83eb025141ef4915eeb09d4491f79e52f2562b73e5f47", [:mix], [], "hexpm", "b92b5031b650ca480ced047578f1d57ea6dd563f5b57464ad274718c9c29501c"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"typable": {:hex, :typable, "0.3.0", "0431e121d124cd26f312123e313d2689b9a5322b15add65d424c07779eaa3ca1", [:mix], [], "hexpm", "880a0797752da1a4c508ac48f94711e04c86156f498065a83d160eef945858f8"},
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},

View file

@ -6,7 +6,8 @@ defmodule Smokestack.DslTest do
@moduledoc false
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
validate_api_inclusion?: false
validate_domain_inclusion?: false,
domain: nil
ets do
private? true

View file

@ -1,8 +0,0 @@
defmodule Support.Api do
@moduledoc false
use Ash.Api, validate_config_inclusion?: false
resources do
allow_unregistered? true
end
end

View file

@ -3,7 +3,8 @@ defmodule Support.Author do
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
validate_api_inclusion?: false
validate_domain_inclusion?: false,
domain: nil
ets do
private? true
@ -12,8 +13,8 @@ defmodule Support.Author do
attributes do
uuid_primary_key :id
attribute :name, :string
attribute :email, :ci_string
attribute :name, :string, public?: true
attribute :email, :ci_string, public?: true
timestamps()
end
@ -24,6 +25,7 @@ defmodule Support.Author do
actions do
defaults [:create, :read, :update, :destroy]
default_accept :*
end
aggregates do

8
test/support/domain.ex Normal file
View file

@ -0,0 +1,8 @@
defmodule Support.Domain do
@moduledoc false
use Ash.Domain, validate_config_inclusion?: false
resources do
allow_unregistered? true
end
end

View file

@ -9,7 +9,7 @@ defmodule Support.Factory do
end
factory Support.Author, :trek do
attribute :name, choose(["JL", "Doc Holoday", "BLT", "Cal Hudson"])
attribute :name, choose(["JL", "Dr Mark", "BLT", "Cal Hudson"])
attribute :email, fn
%{name: "JL"} -> "captain@entrepreneur.starfleet"
@ -20,7 +20,7 @@ defmodule Support.Factory do
end
factory Support.Post do
api Support.Api
domain Support.Domain
attribute :title, &Faker.Commerce.product_name/0
attribute :tags, n_times(3..20, &Faker.Lorem.word/0)

View file

@ -3,7 +3,8 @@ defmodule Support.Post do
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
validate_api_inclusion?: false
validate_domain_inclusion?: false,
domain: nil
ets do
private? true
@ -14,19 +15,23 @@ defmodule Support.Post do
attribute :title, :string do
allow_nil? false
public? true
end
attribute :sub_title, :string
attribute :sub_title, :string, public?: true
attribute :tags, {:array, :ci_string} do
constraints items: [
match: ~r/^[a-zA-Z]+$/,
casing: :lower
]
public? true
end
attribute :body, :string do
allow_nil? false
public? true
end
timestamps()
@ -38,6 +43,7 @@ defmodule Support.Post do
actions do
defaults [:create, :read, :update, :destroy]
default_accept :*
end
calculations do