Skip to content

Commit 5d327ef

Browse files
chore(internal): codegen related update
1 parent 6f8bca5 commit 5d327ef

38 files changed

+252
-190
lines changed

.rubocop.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://www.rubyschema.org/rubocop.json
12
---
23
# Explicitly disable pending cops for now. This is the default behaviour but
34
# this avoids a large warning every time we run it.
@@ -8,7 +9,7 @@ AllCops:
89
- "bin/*"
910
NewCops: enable
1011
SuggestExtensions: false
11-
TargetRubyVersion: 3.2.0
12+
TargetRubyVersion: 3.2
1213

1314
# Whether MFA is required or not should be left to the token configuration.
1415
Gemspec/RequireMFA:
@@ -149,7 +150,7 @@ Naming/ClassAndModuleCamelCase:
149150
Naming/MethodParameterName:
150151
Enabled: false
151152

152-
Naming/PredicateName:
153+
Naming/PredicatePrefix:
153154
Exclude:
154155
- "**/*.rbi"
155156

Gemfile.lock

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PATH
1717
GEM
1818
remote: https://rubygems.org/
1919
specs:
20-
activesupport (8.0.2)
20+
activesupport (8.0.2.1)
2121
base64
2222
benchmark (>= 0.3)
2323
bigdecimal
@@ -33,45 +33,50 @@ GEM
3333
addressable (2.8.7)
3434
public_suffix (>= 2.0.2, < 7.0)
3535
ast (2.4.3)
36-
async (2.24.0)
36+
async (2.27.3)
3737
console (~> 1.29)
3838
fiber-annotation
39-
io-event (~> 1.9)
39+
io-event (~> 1.11)
4040
metrics (~> 0.12)
4141
traces (~> 0.15)
42-
base64 (0.2.0)
43-
benchmark (0.4.0)
44-
bigdecimal (3.1.9)
42+
base64 (0.3.0)
43+
benchmark (0.4.1)
44+
bigdecimal (3.2.2)
4545
concurrent-ruby (1.3.5)
4646
connection_pool (2.5.3)
47-
console (1.30.2)
47+
console (1.33.0)
4848
fiber-annotation
4949
fiber-local (~> 1.1)
5050
json
5151
crack (1.0.0)
5252
bigdecimal
5353
rexml
54-
csv (3.3.4)
55-
drb (2.2.1)
54+
csv (3.3.5)
55+
drb (2.2.3)
5656
erubi (1.13.1)
57+
ffi (1.17.2-aarch64-linux-gnu)
58+
ffi (1.17.2-aarch64-linux-musl)
59+
ffi (1.17.2-arm64-darwin)
60+
ffi (1.17.2-x86_64-darwin)
5761
ffi (1.17.2-x86_64-linux-gnu)
62+
ffi (1.17.2-x86_64-linux-musl)
5863
fiber-annotation (0.2.0)
5964
fiber-local (1.1.0)
6065
fiber-storage
6166
fiber-storage (1.0.1)
6267
fileutils (1.7.3)
63-
hashdiff (1.1.2)
68+
hashdiff (1.2.0)
6469
i18n (1.14.7)
6570
concurrent-ruby (~> 1.0)
66-
io-event (1.10.0)
67-
json (2.11.3)
68-
language_server-protocol (3.17.0.4)
71+
io-event (1.11.2)
72+
json (2.13.2)
73+
language_server-protocol (3.17.0.5)
6974
lint_roller (1.1.0)
7075
listen (3.9.0)
7176
rb-fsevent (~> 0.10, >= 0.10.3)
7277
rb-inotify (~> 0.9, >= 0.9.10)
7378
logger (1.7.0)
74-
metrics (0.12.2)
79+
metrics (0.13.0)
7580
minitest (5.25.5)
7681
minitest-focus (1.4.0)
7782
minitest (>= 4, < 6)
@@ -84,54 +89,56 @@ GEM
8489
mutex_m (0.3.0)
8590
netrc (0.11.0)
8691
parallel (1.27.0)
87-
parser (3.3.8.0)
92+
parser (3.3.9.0)
8893
ast (~> 2.4.1)
8994
racc
9095
prettier_print (1.2.1)
9196
prism (1.4.0)
9297
public_suffix (6.0.2)
9398
racc (1.8.1)
9499
rainbow (3.1.1)
95-
rake (13.2.1)
100+
rake (13.3.0)
96101
rb-fsevent (0.11.2)
97102
rb-inotify (0.11.1)
98103
ffi (~> 1.0)
99-
rbi (0.3.2)
104+
rbi (0.3.6)
100105
prism (~> 1.0)
101106
rbs (>= 3.4.4)
102-
sorbet-runtime (>= 0.5.9204)
103-
rbs (3.9.2)
107+
rbs (3.9.4)
104108
logger
105109
redcarpet (3.6.1)
106-
regexp_parser (2.10.0)
110+
regexp_parser (2.11.2)
107111
rexml (3.4.1)
108-
rubocop (1.75.5)
112+
rubocop (1.79.2)
109113
json (~> 2.3)
110114
language_server-protocol (~> 3.17.0.2)
111115
lint_roller (~> 1.1.0)
112116
parallel (~> 1.10)
113117
parser (>= 3.3.0.2)
114118
rainbow (>= 2.2.2, < 4.0)
115119
regexp_parser (>= 2.9.3, < 3.0)
116-
rubocop-ast (>= 1.44.0, < 2.0)
120+
rubocop-ast (>= 1.46.0, < 2.0)
117121
ruby-progressbar (~> 1.7)
118122
unicode-display_width (>= 2.4.0, < 4.0)
119-
rubocop-ast (1.44.1)
123+
rubocop-ast (1.46.0)
120124
parser (>= 3.3.7.2)
121125
prism (~> 1.4)
122126
ruby-progressbar (1.13.0)
123127
securerandom (0.4.1)
124-
sorbet (0.5.12067)
125-
sorbet-static (= 0.5.12067)
126-
sorbet-runtime (0.5.12067)
127-
sorbet-static (0.5.12067-x86_64-linux)
128-
sorbet-static-and-runtime (0.5.12067)
129-
sorbet (= 0.5.12067)
130-
sorbet-runtime (= 0.5.12067)
131-
spoom (1.6.1)
128+
sorbet (0.5.12424)
129+
sorbet-static (= 0.5.12424)
130+
sorbet-runtime (0.5.12424)
131+
sorbet-static (0.5.12424-aarch64-linux)
132+
sorbet-static (0.5.12424-universal-darwin)
133+
sorbet-static (0.5.12424-x86_64-linux)
134+
sorbet-static-and-runtime (0.5.12424)
135+
sorbet (= 0.5.12424)
136+
sorbet-runtime (= 0.5.12424)
137+
spoom (1.6.3)
132138
erubi (>= 1.10.0)
133139
prism (>= 0.28.0)
134-
rbi (>= 0.2.3)
140+
rbi (>= 0.3.3)
141+
rexml (>= 3.2.6)
135142
sorbet-static-and-runtime (>= 0.5.10187)
136143
thor (>= 0.19.2)
137144
steep (1.10.0)
@@ -152,7 +159,7 @@ GEM
152159
terminal-table (>= 2, < 5)
153160
uri (>= 0.12.0)
154161
strscan (3.1.5)
155-
syntax_tree (6.2.0)
162+
syntax_tree (6.3.0)
156163
prettier_print (>= 1.2.0)
157164
tapioca (0.16.11)
158165
benchmark
@@ -166,11 +173,11 @@ GEM
166173
yard-sorbet
167174
terminal-table (4.0.0)
168175
unicode-display_width (>= 1.1.1, < 4)
169-
thor (1.3.2)
170-
traces (0.15.2)
176+
thor (1.4.0)
177+
traces (0.17.0)
171178
tzinfo (2.0.6)
172179
concurrent-ruby (~> 1.0)
173-
unicode-display_width (3.1.4)
180+
unicode-display_width (3.1.5)
174181
unicode-emoji (~> 4.0, >= 4.0.4)
175182
unicode-emoji (4.0.4)
176183
uri (1.0.3)
@@ -185,7 +192,14 @@ GEM
185192
yard
186193

187194
PLATFORMS
188-
x86_64-linux
195+
aarch64-linux
196+
aarch64-linux-gnu
197+
aarch64-linux-musl
198+
arm64-darwin
199+
universal-darwin
200+
x86_64-darwin
201+
x86_64-linux-gnu
202+
x86_64-linux-musl
189203

190204
DEPENDENCIES
191205
async

lib/orb/internal/transport/pooled_net_requester.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,7 @@ def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
193193
end
194194

195195
define_sorbet_constant!(:Request) do
196-
T.type_alias do
197-
{
198-
method: Symbol,
199-
url: URI::Generic,
200-
headers: T::Hash[String, String],
201-
body: T.anything,
202-
deadline: Float
203-
}
204-
end
196+
T.type_alias { {method: Symbol, url: URI::Generic, headers: T::Hash[String, String], body: T.anything, deadline: Float} }
205197
end
206198
end
207199
end

lib/orb/internal/type/array_of.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def to_sorbet_type
148148
# @option spec [Boolean] :"nil?"
149149
def initialize(type_info, spec = {})
150150
@item_type_fn = Orb::Internal::Type::Converter.type_info(type_info || spec)
151+
@meta = Orb::Internal::Type::Converter.meta_info(type_info, spec)
151152
@nilable = spec.fetch(:nil?, false)
152153
end
153154

lib/orb/internal/type/base_model.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def fields
5252
#
5353
# @option spec [Boolean] :"nil?"
5454
private def add_field(name_sym, required:, type_info:, spec:)
55+
meta = Orb::Internal::Type::Converter.meta_info(type_info, spec)
5556
type_fn, info =
5657
case type_info
5758
in Proc | Orb::Internal::Type::Converter | Class
@@ -74,7 +75,8 @@ def fields
7475
required: required,
7576
nilable: nilable,
7677
const: const,
77-
type_fn: type_fn
78+
type_fn: type_fn,
79+
meta: meta
7880
}
7981

8082
define_method(setter) do |value|

lib/orb/internal/type/converter.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,33 @@ def type_info(spec)
9898
end
9999
end
100100

101+
# @api private
102+
#
103+
# @param type_info [Hash{Symbol=>Object}, Proc, Orb::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, Orb::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+
101128
# @api private
102129
#
103130
# @param translate_names [Boolean]

lib/orb/internal/type/hash_of.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def to_sorbet_type
168168
# @option spec [Boolean] :"nil?"
169169
def initialize(type_info, spec = {})
170170
@item_type_fn = Orb::Internal::Type::Converter.type_info(type_info || spec)
171+
@meta = Orb::Internal::Type::Converter.meta_info(type_info, spec)
171172
@nilable = spec.fetch(:nil?, false)
172173
end
173174

lib/orb/internal/type/union.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ module Union
4747
#
4848
# All of the specified variant info for this union.
4949
#
50-
# @return [Array<Array(Symbol, Proc)>]
50+
# @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
5151
private def known_variants = (@known_variants ||= [])
5252

5353
# @api private
5454
#
55-
# @return [Array<Array(Symbol, Object)>]
55+
# @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
5656
protected def derefed_variants
57-
known_variants.map { |key, variant_fn| [key, variant_fn.call] }
57+
known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
5858
end
5959

6060
# All of the specified variants for this union.
6161
#
6262
# @return [Array<Object>]
63-
def variants = derefed_variants.map(&:last)
63+
def variants = derefed_variants.map { _2 }
6464

6565
# @api private
6666
#
@@ -86,12 +86,13 @@ def variants = derefed_variants.map(&:last)
8686
#
8787
# @option spec [Boolean] :"nil?"
8888
private def variant(key, spec = nil)
89+
meta = Orb::Internal::Type::Converter.meta_info(nil, spec)
8990
variant_info =
9091
case key
9192
in Symbol
92-
[key, Orb::Internal::Type::Converter.type_info(spec)]
93+
[key, Orb::Internal::Type::Converter.type_info(spec), meta]
9394
in Proc | Orb::Internal::Type::Converter | Class | Hash
94-
[nil, Orb::Internal::Type::Converter.type_info(key)]
95+
[nil, Orb::Internal::Type::Converter.type_info(key), meta]
9596
end
9697

9798
known_variants << variant_info
@@ -114,7 +115,8 @@ def variants = derefed_variants.map(&:last)
114115
return nil if key == Orb::Internal::OMIT
115116

116117
key = key.to_sym if key.is_a?(String)
117-
known_variants.find { |k,| k == key }&.last&.call
118+
_, found = known_variants.find { |k,| k == key }
119+
found&.call
118120
else
119121
nil
120122
end

lib/orb/internal/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class << self
244244
#
245245
# @return [String]
246246
def uri_origin(uri)
247-
"#{uri.scheme}://#{uri.host}#{uri.port == uri.default_port ? '' : ":#{uri.port}"}"
247+
"#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
248248
end
249249

250250
# @api private

lib/orb/models/beta/external_plan_id_create_plan_version_params.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ module Price
223223

224224
variant :scalable_matrix_with_unit_pricing, -> { Orb::NewPlanScalableMatrixWithUnitPricingPrice }
225225

226-
variant :scalable_matrix_with_tiered_pricing,
227-
-> {
228-
Orb::NewPlanScalableMatrixWithTieredPricingPrice
229-
}
226+
variant :scalable_matrix_with_tiered_pricing, -> { Orb::NewPlanScalableMatrixWithTieredPricingPrice }
230227

231228
variant :cumulative_grouped_bulk, -> { Orb::NewPlanCumulativeGroupedBulkPrice }
232229

@@ -285,9 +282,7 @@ class ReplaceAdjustment < Orb::Internal::Type::BaseModel
285282
#
286283
# @return [Orb::Models::NewPercentageDiscount, Orb::Models::NewUsageDiscount, Orb::Models::NewAmountDiscount, Orb::Models::NewMinimum, Orb::Models::NewMaximum]
287284
required :adjustment,
288-
union: -> {
289-
Orb::Beta::ExternalPlanIDCreatePlanVersionParams::ReplaceAdjustment::Adjustment
290-
}
285+
union: -> { Orb::Beta::ExternalPlanIDCreatePlanVersionParams::ReplaceAdjustment::Adjustment }
291286

292287
# @!attribute replaces_adjustment_id
293288
# The id of the adjustment on the plan to replace in the plan.
@@ -421,10 +416,7 @@ module Price
421416

422417
variant :scalable_matrix_with_unit_pricing, -> { Orb::NewPlanScalableMatrixWithUnitPricingPrice }
423418

424-
variant :scalable_matrix_with_tiered_pricing,
425-
-> {
426-
Orb::NewPlanScalableMatrixWithTieredPricingPrice
427-
}
419+
variant :scalable_matrix_with_tiered_pricing, -> { Orb::NewPlanScalableMatrixWithTieredPricingPrice }
428420

429421
variant :cumulative_grouped_bulk, -> { Orb::NewPlanCumulativeGroupedBulkPrice }
430422

0 commit comments

Comments
 (0)