jsonapi-resources-anchor 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7705f2e1f8acafaccc8736065acbd8fd57ab8c3611f3bcc918181c88f5373440
4
- data.tar.gz: 07b6f3e0be8553503fd50a502cb69b64aa6a8713e497380450c9ac8dddf4243e
3
+ metadata.gz: 8bbb91066034b7aecb90bd6c7a686b4cc7d183c4dbd188cb972d51ef1e4f2a82
4
+ data.tar.gz: 3adb33a6252da68c2117a1fc3aa394d752e753e75ffc58ac5b8b906d3f6adefe
5
5
  SHA512:
6
- metadata.gz: ea87194a6711d851e59557d52a551d7173f409f1a8fc4f595b30580963554fe6a7669249a7e17c70c31abe70d3309a739f37b4af796f29ce4ec2c8419951eb07
7
- data.tar.gz: a8bc795a3ed08c50806403c4273264c4ecac4ebab38eea26b4c5568cbeed412d97a4f6d73d3a68b8f1215c46f6fbdb5ba798d02041f6f044b879762599f79df1
6
+ metadata.gz: 3a3e8bce509f345e491494bf0abe46f20bd011a00c4d380603e1c8553e9c899f673dbd48fec8d14d0286ab68115c7683ec76cc7a1a1e5372203e5e3a3bbe5834
7
+ data.tar.gz: 54bd4102d201a62e8d2a6ab3888a523779ecb4f3aa30cb89005c07ac442da9b0755368830742df20eaff530fe62dd47486496733d6358f203eebb174c4824937
data/lib/anchor/config.rb CHANGED
@@ -6,7 +6,9 @@ module Anchor
6
6
  :use_active_record_comment,
7
7
  :infer_nullable_relationships_as_optional,
8
8
  :empty_relationship_type,
9
- :use_type_as_schema_name
9
+ :use_type_as_schema_name,
10
+ :maybe_as_union,
11
+ :array_bracket_notation
10
12
 
11
13
  def initialize
12
14
  @ar_column_to_type = nil
@@ -16,6 +18,8 @@ module Anchor
16
18
  @infer_nullable_relationships_as_optional = nil
17
19
  @empty_relationship_type = nil
18
20
  @use_type_as_schema_name = nil
21
+ @maybe_as_union = nil
22
+ @array_bracket_notation = nil
19
23
  end
20
24
  end
21
25
  end
@@ -85,6 +85,7 @@ module Anchor::TypeScript
85
85
  end
86
86
 
87
87
  def utils_to_import
88
+ return [] if Anchor.config.maybe_as_union
88
89
  maybe_type = has_maybe?(@object).presence && Anchor::Types::Reference.new("Maybe")
89
90
  [maybe_type].compact
90
91
  end
@@ -11,8 +11,8 @@ module Anchor::TypeScript
11
11
  when Anchor::Types::Null.singleton_class then "null"
12
12
  when Anchor::Types::Record, Anchor::Types::Record.singleton_class then "Record<string, #{type_string(type.try(:value_type) || Anchor::Types::Unknown)}>"
13
13
  when Anchor::Types::Union then type.types.map { |type| type_string(type, depth) }.join(" | ")
14
- when Anchor::Types::Maybe then "Maybe<#{type_string(type.type, depth)}>"
15
- when Anchor::Types::Array then "Array<#{type_string(type.type, depth)}>"
14
+ when Anchor::Types::Maybe then Anchor.config.maybe_as_union ? type_string(Anchor::Types::Union.new([type.type, Anchor::Types::Null]), depth) : "Maybe<#{type_string(type.type, depth)}>"
15
+ when Anchor::Types::Array then Anchor.config.array_bracket_notation ? "#{type_string(type.type, depth)}[]" : "Array<#{type_string(type.type, depth)}>"
16
16
  when Anchor::Types::Literal then serialize_literal(type.value)
17
17
  when Anchor::Types::Reference then type.name
18
18
  when Anchor::Types::Object, Anchor::Types::Object.singleton_class then serialize_object(type, depth)
@@ -1,3 +1,3 @@
1
1
  module Anchor
2
- VERSION = "2.4.0"
2
+ VERSION = "2.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-resources-anchor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-12 00:00:00.000000000 Z
11
+ date: 2025-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-resources