Skip to content

Commit 4625bce

Browse files
committed
Update deps, Remove typed_struct
1 parent 135be69 commit 4625bce

File tree

7 files changed

+89
-66
lines changed

7 files changed

+89
-66
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- `fn`: Support multiple clauses
2424
- Consolidate and document extension API (`Dx.Defd_`)
2525

26+
### Other changes
27+
- Removed dependency `typed_struct`
28+
2629
## [0.3.4] - 2024-10-12
2730

2831
### Features

lib/dx/ecto/query/builder.ex

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,31 @@ defmodule Dx.Ecto.Query.Builder do
2323

2424
@moduledoc false
2525

26-
use TypedStruct
27-
2826
@type mapped_alias() :: {atom(), module(), %{atom() => mapped_alias()}}
2927

30-
typedstruct do
31-
field(:query, Ecto.Query.t(), required: true)
32-
field(:root_query, Ecto.Query.t())
33-
field(:aliases, mapped_alias())
34-
field(:path, list(atom()), default: [])
35-
field(:types, list(atom()), default: [])
36-
field(:next_alias_index, non_neg_integer(), default: 0)
37-
field(:negate?, boolean(), default: false)
38-
field(:in_subquery?, boolean(), default: false)
39-
field(:eval, Dx.Evaluation.t())
40-
end
28+
defstruct [
29+
:query,
30+
:root_query,
31+
:aliases,
32+
:eval,
33+
path: [],
34+
types: [],
35+
next_alias_index: 0,
36+
negate?: false,
37+
in_subquery?: false
38+
]
39+
40+
@type t() :: %__MODULE__{
41+
query: Ecto.Query.t(),
42+
root_query: Ecto.Query.t(),
43+
aliases: mapped_alias(),
44+
path: list(atom()),
45+
types: list(atom()),
46+
next_alias_index: non_neg_integer(),
47+
negate?: boolean(),
48+
in_subquery?: boolean(),
49+
eval: Dx.Evaluation.t()
50+
}
4151

4252
alias __MODULE__, as: Builder
4353

lib/dx/evaluation.ex

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,37 @@ defmodule Dx.Evaluation do
77
This is also used in the now deprecated `infer` approach of Dx.
88
"""
99

10-
use TypedStruct
11-
12-
typedstruct do
13-
field(:root_subject, map())
14-
field(:cache, any())
15-
field(:return_cache?, boolean(), default: false)
16-
field(:finalize?, boolean(), default: true)
17-
field(:binds, map())
18-
field(:negate?, boolean(), default: false)
19-
field(:resolve_predicates?, boolean(), default: true)
10+
defstruct [
11+
:root_subject,
12+
:cache,
13+
:binds,
14+
return_cache?: false,
15+
finalize?: true,
16+
negate?: false,
17+
resolve_predicates?: true,
2018

2119
# Options
22-
field(:loader, module(), default: Dx.Loaders.Dataloader)
23-
field(:loader_options, Keyword.t(), default: [])
24-
field(:args, map(), default: %{})
25-
field(:debug?, boolean(), default: false)
26-
field(:extra_rules, list(module()), default: [])
27-
field(:select, any())
28-
end
20+
loader: Dx.Loaders.Dataloader,
21+
loader_options: [],
22+
args: %{},
23+
debug?: false,
24+
extra_rules: []
25+
]
26+
27+
@type t() :: %__MODULE__{
28+
root_subject: map(),
29+
cache: any(),
30+
return_cache?: boolean(),
31+
finalize?: boolean(),
32+
binds: map(),
33+
negate?: boolean(),
34+
resolve_predicates?: boolean(),
35+
loader: module(),
36+
loader_options: Keyword.t(),
37+
args: map(),
38+
debug?: boolean(),
39+
extra_rules: list(module())
40+
}
2941

3042
def from_options(opts) do
3143
%__MODULE__{}

lib/dx/parser.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ defmodule Dx.Parser do
99

1010
@moduledoc false
1111

12-
use TypedStruct
12+
defstruct [:type, aliases: %{}, opts: %{}]
1313

14-
typedstruct do
15-
field(:type, module())
16-
field(:aliases, %{atom() => any()}, default: %{})
17-
field(:opts, map(), default: %{})
18-
end
14+
@type t() :: %__MODULE__{
15+
type: module(),
16+
aliases: %{atom() => any()},
17+
opts: map()
18+
}
1919

2020
def with_opts(token, opts), do: %{token | opts: Map.new(opts)}
2121

lib/dx/rule.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ defmodule Dx.Rule do
1010

1111
@moduledoc false
1212

13-
use TypedStruct
13+
defstruct [:type, :key, :val, when: %{}]
1414

15-
typedstruct do
16-
field(:type, module() | nil)
17-
field(:when, map(), default: %{})
18-
field(:key, atom())
19-
field(:val, term())
20-
end
15+
@type t() :: %__MODULE__{
16+
type: module() | nil,
17+
when: map(),
18+
key: atom(),
19+
val: term()
20+
}
2121
end

mix.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ defmodule Dx.MixProject do
4949
defp deps do
5050
[
5151
# util
52-
{:typed_struct, ">= 0.0.0"},
5352
{:dataloader, "~> 2.0"},
5453

5554
# adapters

0 commit comments

Comments
 (0)