sorbet-baml 0.4.0 → 0.5.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: 4de7b80da4ee748d5c22196c22f78ca92e855f9b4983437d4ea6ad02a5201fba
4
- data.tar.gz: 22a81719e5d2021b52945d913e3134482ff999e917d655f67ec894a35fa2a40b
3
+ metadata.gz: 2a0de97bc6e10d1383d8d272524bb7b619e536083d8137076aa85a77250d1d23
4
+ data.tar.gz: 0244bc07270a1aa98f0b6acede92780ad517023957666a7cbf49c669c152210f
5
5
  SHA512:
6
- metadata.gz: d64e1cef217666030c2f34cacd48333d6ce46d5fac40e2a2855c0f73fe43dadf39a620ad01b37df904ca5aa792a7d46cd3a1bdaf45ce797b34f3010ce4a2be12
7
- data.tar.gz: 6131b255163a544f2ef7591f58e173ab0436c44426003513888b51ea4d3a35a5ff90d186b491d867035b9d0c86929b176c6ff8bfeb6de7106b87662546ea0c3e
6
+ metadata.gz: dfc35021be2be674ab71c34d2d412ca88d569dae829a0da679dd4089370cac92bf4b4c026675b1b56a8539155c5fe46739c32091dc1ab0bbcf807232ab3af3f7
7
+ data.tar.gz: da4957e2ddd7a1cb38af6f143294f1a2090b005449c59dcd0fcac8bdb497282e263fd08e0862af0dcd9c4c8a7be3f987eaa99e6b55cc014def6975a10ac83b3b
@@ -19,6 +19,9 @@ module SorbetBaml
19
19
  map_array_type(type_object)
20
20
  when T::Types::TypedHash
21
21
  map_hash_type(type_object)
22
+ when T::Types::Untyped
23
+ # T.untyped maps to BAML's json type for dynamic values
24
+ 'json'
22
25
  else
23
26
  # Check if it's a union type (T.nilable or T.any)
24
27
  if type_object.respond_to?(:types)
@@ -61,8 +64,10 @@ module SorbetBaml
61
64
  sig { params(type_object: T.untyped).returns(String) }
62
65
  def self.map_union_type(type_object)
63
66
  types = type_object.types
64
- nil_type = types.find { |t| t.raw_type == NilClass }
65
- non_nil_types = types.reject { |t| t.raw_type == NilClass }
67
+
68
+ # Only T::Types::Simple has raw_type - check type class before accessing
69
+ nil_type = types.find { |t| nil_type?(t) }
70
+ non_nil_types = types.reject { |t| nil_type?(t) }
66
71
 
67
72
  return 'null' if non_nil_types.empty?
68
73
 
@@ -91,6 +96,13 @@ module SorbetBaml
91
96
  end
92
97
  end
93
98
 
99
+ # Check if a type represents NilClass safely
100
+ # Only T::Types::Simple has raw_type; other type classes (TypedHash, TypedArray, Untyped) do not
101
+ sig { params(type_obj: T.untyped).returns(T::Boolean) }
102
+ def self.nil_type?(type_obj)
103
+ type_obj.is_a?(T::Types::Simple) && type_obj.raw_type == NilClass
104
+ end
105
+
94
106
  sig { params(type_object: T.untyped).returns(String) }
95
107
  def self.map_array_type(type_object)
96
108
  element_type = map_type(type_object.type)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SorbetBaml
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-baml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicente Reig Rincon de Arellano
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-10-14 00:00:00.000000000 Z
10
+ date: 2025-12-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: sorbet-runtime