turbopuffer-ruby 0.2.4 → 0.2.5

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: 4cdba184c47706f13e46349844edd154024ecb50b0cd898b1e472bee7122595f
4
- data.tar.gz: d2a2652222e2e672c9069bc965ece1bac43351804670331410aa91462eaa1f7c
3
+ metadata.gz: 26c8d39f36226c564b9378cfe4b392aeb400b6276c5fbfe7d60613b6fc33bd39
4
+ data.tar.gz: 9b246312e930c3d27c136e31fc211b8043c4e5547324bd5ba1a7e8c5f8609c35
5
5
  SHA512:
6
- metadata.gz: 0c42de89acf1dc7246fb9ef1ad915bb0e5d0c1bdb74b1d842851d3eeb576ed8ed3cc2047d6d255053b7a21bd7561dbf6a757620ff2ec9099ada4c9a98ddfc487
7
- data.tar.gz: 25b6fdfc5c41998e5bb415ecebd39f6b8c6583047bf44a27714363044ffa7c70d86d53ae7e17379514885e8c4ac2191c1e7e292ea0d9aecb8e6b273ded29452d
6
+ metadata.gz: 8c39ed7f28513d70e15b7f1d270272a2fe880ef22b2a79e2b48c2bfad34bf50d59c972a94afb0fe71527618e7bd793cdc764178ccd2dc88fd184103a0085b8d1
7
+ data.tar.gz: bb6a174358d9416ecba3ad7add3ca805cbc6ae929183a4bbfa79e96b8dc01c4a2ec4e7287bab35b89b68c36622bdc25e154bc165f2e13aa8a39ac19125c6be49
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5 (2025-08-11)
4
+
5
+ Full Changelog: [v0.2.4...v0.2.5](https://github.com/turbopuffer/turbopuffer-ruby/compare/v0.2.4...v0.2.5)
6
+
7
+ ### Chores
8
+
9
+ * collect metadata from type DSL ([79bb9bd](https://github.com/turbopuffer/turbopuffer-ruby/commit/79bb9bd39297006af6693580f09d35c1c801500f))
10
+ * **internal:** update comment in script ([0b151c0](https://github.com/turbopuffer/turbopuffer-ruby/commit/0b151c035ce5ba8785c3499247843428ba8267bd))
11
+ * update @stainless-api/prism-cli to v5.15.0 ([bb9a4b1](https://github.com/turbopuffer/turbopuffer-ruby/commit/bb9a4b1de0ac931671b2abeefa9c4cf8a67bae63))
12
+
3
13
  ## 0.2.4 (2025-08-01)
4
14
 
5
15
  Full Changelog: [v0.2.3...v0.2.4](https://github.com/turbopuffer/turbopuffer-ruby/compare/v0.2.3...v0.2.4)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "turbopuffer-ruby", "~> 0.2.4"
20
+ gem "turbopuffer-ruby", "~> 0.2.5"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -148,6 +148,7 @@ module Turbopuffer
148
148
  # @option spec [Boolean] :"nil?"
149
149
  def initialize(type_info, spec = {})
150
150
  @item_type_fn = Turbopuffer::Internal::Type::Converter.type_info(type_info || spec)
151
+ @meta = Turbopuffer::Internal::Type::Converter.meta_info(type_info, spec)
151
152
  @nilable = spec.fetch(:nil?, false)
152
153
  end
153
154
 
@@ -52,6 +52,7 @@ module Turbopuffer
52
52
  #
53
53
  # @option spec [Boolean] :"nil?"
54
54
  private def add_field(name_sym, required:, type_info:, spec:)
55
+ meta = Turbopuffer::Internal::Type::Converter.meta_info(type_info, spec)
55
56
  type_fn, info =
56
57
  case type_info
57
58
  in Proc | Turbopuffer::Internal::Type::Converter | Class
@@ -81,7 +82,8 @@ module Turbopuffer
81
82
  required: required,
82
83
  nilable: nilable,
83
84
  const: const,
84
- type_fn: type_fn
85
+ type_fn: type_fn,
86
+ meta: meta
85
87
  }
86
88
 
87
89
  define_method(setter) do |value|
@@ -98,6 +98,33 @@ module Turbopuffer
98
98
  end
99
99
  end
100
100
 
101
+ # @api private
102
+ #
103
+ # @param type_info [Hash{Symbol=>Object}, Proc, Turbopuffer::Internal::Type::Converter, Class] .
104
+ #
105
+ # @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
106
+ #
107
+ # @option type_info [Proc] :enum
108
+ #
109
+ # @option type_info [Proc] :union
110
+ #
111
+ # @option type_info [Boolean] :"nil?"
112
+ #
113
+ # @param spec [Hash{Symbol=>Object}, Proc, Turbopuffer::Internal::Type::Converter, Class] .
114
+ #
115
+ # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
116
+ #
117
+ # @option spec [Proc] :enum
118
+ #
119
+ # @option spec [Proc] :union
120
+ #
121
+ # @option spec [Boolean] :"nil?"
122
+ #
123
+ # @return [Hash{Symbol=>Object}]
124
+ def meta_info(type_info, spec)
125
+ [spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
126
+ end
127
+
101
128
  # @api private
102
129
  #
103
130
  # @param translate_names [Boolean]
@@ -168,6 +168,7 @@ module Turbopuffer
168
168
  # @option spec [Boolean] :"nil?"
169
169
  def initialize(type_info, spec = {})
170
170
  @item_type_fn = Turbopuffer::Internal::Type::Converter.type_info(type_info || spec)
171
+ @meta = Turbopuffer::Internal::Type::Converter.meta_info(type_info, spec)
171
172
  @nilable = spec.fetch(:nil?, false)
172
173
  end
173
174
 
@@ -23,20 +23,20 @@ module Turbopuffer
23
23
  #
24
24
  # All of the specified variant info for this union.
25
25
  #
26
- # @return [Array<Array(Symbol, Proc)>]
26
+ # @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
27
27
  private def known_variants = (@known_variants ||= [])
28
28
 
29
29
  # @api private
30
30
  #
31
- # @return [Array<Array(Symbol, Object)>]
31
+ # @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
32
32
  protected def derefed_variants
33
- known_variants.map { |key, variant_fn| [key, variant_fn.call] }
33
+ known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
34
34
  end
35
35
 
36
36
  # All of the specified variants for this union.
37
37
  #
38
38
  # @return [Array<Object>]
39
- def variants = derefed_variants.map(&:last)
39
+ def variants = derefed_variants.map { _2 }
40
40
 
41
41
  # @api private
42
42
  #
@@ -62,12 +62,13 @@ module Turbopuffer
62
62
  #
63
63
  # @option spec [Boolean] :"nil?"
64
64
  private def variant(key, spec = nil)
65
+ meta = Turbopuffer::Internal::Type::Converter.meta_info(nil, spec)
65
66
  variant_info =
66
67
  case key
67
68
  in Symbol
68
- [key, Turbopuffer::Internal::Type::Converter.type_info(spec)]
69
+ [key, Turbopuffer::Internal::Type::Converter.type_info(spec), meta]
69
70
  in Proc | Turbopuffer::Internal::Type::Converter | Class | Hash
70
- [nil, Turbopuffer::Internal::Type::Converter.type_info(key)]
71
+ [nil, Turbopuffer::Internal::Type::Converter.type_info(key), meta]
71
72
  end
72
73
 
73
74
  known_variants << variant_info
@@ -90,7 +91,8 @@ module Turbopuffer
90
91
  return nil if key == Turbopuffer::Internal::OMIT
91
92
 
92
93
  key = key.to_sym if key.is_a?(String)
93
- known_variants.find { |k,| k == key }&.last&.call
94
+ _, found = known_variants.find { |k,| k == key }
95
+ found&.call
94
96
  else
95
97
  nil
96
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Turbopuffer
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -90,6 +90,60 @@ module Turbopuffer
90
90
  def self.type_info(spec)
91
91
  end
92
92
 
93
+ # @api private
94
+ sig do
95
+ params(
96
+ type_info:
97
+ T.any(
98
+ {
99
+ const:
100
+ T.nilable(
101
+ T.any(NilClass, T::Boolean, Integer, Float, Symbol)
102
+ ),
103
+ enum:
104
+ T.nilable(
105
+ T.proc.returns(
106
+ Turbopuffer::Internal::Type::Converter::Input
107
+ )
108
+ ),
109
+ union:
110
+ T.nilable(
111
+ T.proc.returns(
112
+ Turbopuffer::Internal::Type::Converter::Input
113
+ )
114
+ )
115
+ },
116
+ T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
117
+ Turbopuffer::Internal::Type::Converter::Input
118
+ ),
119
+ spec:
120
+ T.any(
121
+ {
122
+ const:
123
+ T.nilable(
124
+ T.any(NilClass, T::Boolean, Integer, Float, Symbol)
125
+ ),
126
+ enum:
127
+ T.nilable(
128
+ T.proc.returns(
129
+ Turbopuffer::Internal::Type::Converter::Input
130
+ )
131
+ ),
132
+ union:
133
+ T.nilable(
134
+ T.proc.returns(
135
+ Turbopuffer::Internal::Type::Converter::Input
136
+ )
137
+ )
138
+ },
139
+ T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
140
+ Turbopuffer::Internal::Type::Converter::Input
141
+ )
142
+ ).returns(Turbopuffer::Internal::AnyHash)
143
+ end
144
+ def self.meta_info(type_info, spec)
145
+ end
146
+
93
147
  # @api private
94
148
  sig do
95
149
  params(translate_names: T::Boolean).returns(
@@ -16,7 +16,8 @@ module Turbopuffer
16
16
  T::Array[
17
17
  [
18
18
  T.nilable(Symbol),
19
- T.proc.returns(Turbopuffer::Internal::Type::Converter::Input)
19
+ T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
20
+ Turbopuffer::Internal::AnyHash
20
21
  ]
21
22
  ]
22
23
  )
@@ -25,7 +26,13 @@ module Turbopuffer
25
26
  end
26
27
 
27
28
  # @api private
28
- sig { returns(T::Array[[T.nilable(Symbol), T.anything]]) }
29
+ sig do
30
+ returns(
31
+ T::Array[
32
+ [T.nilable(Symbol), T.anything, Turbopuffer::Internal::AnyHash]
33
+ ]
34
+ )
35
+ end
29
36
  protected def derefed_variants
30
37
  end
31
38
 
@@ -39,6 +39,23 @@ module Turbopuffer
39
39
  | Turbopuffer::Internal::Type::Converter::input spec
40
40
  ) -> (^-> top)
41
41
 
42
+ def self.meta_info: (
43
+ {
44
+ const: (nil | bool | Integer | Float | Symbol)?,
45
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
46
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?
47
+ }
48
+ | ^-> Turbopuffer::Internal::Type::Converter::input
49
+ | Turbopuffer::Internal::Type::Converter::input type_info,
50
+ {
51
+ const: (nil | bool | Integer | Float | Symbol)?,
52
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
53
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?
54
+ }
55
+ | ^-> Turbopuffer::Internal::Type::Converter::input
56
+ | Turbopuffer::Internal::Type::Converter::input spec
57
+ ) -> ::Hash[Symbol, top]
58
+
42
59
  def self.new_coerce_state: (
43
60
  ?translate_names: bool
44
61
  ) -> Turbopuffer::Internal::Type::Converter::coerce_state
@@ -5,9 +5,9 @@ module Turbopuffer
5
5
  include Turbopuffer::Internal::Type::Converter
6
6
  include Turbopuffer::Internal::Util::SorbetRuntimeSupport
7
7
 
8
- private def self.known_variants: -> ::Array[[Symbol?, (^-> Turbopuffer::Internal::Type::Converter::input)]]
8
+ private def self.known_variants: -> ::Array[[Symbol?, (^-> Turbopuffer::Internal::Type::Converter::input), ::Hash[Symbol, top]]]
9
9
 
10
- def self.derefed_variants: -> ::Array[[Symbol?, top]]
10
+ def self.derefed_variants: -> ::Array[[Symbol?, top, ::Hash[Symbol, top]]]
11
11
 
12
12
  def self.variants: -> ::Array[top]
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbopuffer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Turbopuffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-08 00:00:00.000000000 Z
11
+ date: 2025-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool