Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.21"
".": "0.1.0-alpha.22"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 195
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-983a38b280126eee3cd2a12eb7847bc36551f24cf7fdcdffe20e564e2c0d21c4.yml
openapi_spec_hash: 273aa48b03116314693f8870c4c71f9b
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-99d09de90656238ac57bf6711950f043967548c1c4e2ad31b606dd51e0daa3e9.yml
openapi_spec_hash: 597d3aed886356d053b7c571cab6380b
config_hash: 1619155422217276e2489ae10ce63a25
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.22 (2025-05-12)

Full Changelog: [v0.1.0-alpha.21...v0.1.0-alpha.22](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.21...v0.1.0-alpha.22)

### Features

* **api:** api update ([e9058dd](https://github.com/Increase/increase-ruby/commit/e9058dd6b8bf03cca193810a0973ffb0cd242b51))
* support sorbet aliases at the runtime ([38e39cf](https://github.com/Increase/increase-ruby/commit/38e39cfce387746d743d13133b2d1e17c3b5fa86))

## 0.1.0-alpha.21 (2025-05-09)

Full Changelog: [v0.1.0-alpha.20...v0.1.0-alpha.21](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.20...v0.1.0-alpha.21)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
increase (0.1.0.pre.alpha.21)
increase (0.1.0.pre.alpha.22)
connection_pool

GEM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "increase", "~> 0.1.0.pre.alpha.21"
gem "increase", "~> 0.1.0.pre.alpha.22"
```

<!-- x-release-please-end -->
Expand Down
6 changes: 6 additions & 0 deletions lib/increase/internal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

module Increase
module Internal
extend Increase::Internal::Util::SorbetRuntimeSupport

OMIT =
Object.new.tap do
_1.define_singleton_method(:inspect) { "#<#{Increase::Internal}::OMIT>" }
end
.freeze

define_sorbet_constant!(:AnyHash) do
T.type_alias { T::Hash[Symbol, T.anything] }
end
end
end
47 changes: 47 additions & 0 deletions lib/increase/internal/transport/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#
# @abstract
class BaseClient
extend Increase::Internal::Util::SorbetRuntimeSupport

# from whatwg fetch spec
MAX_REDIRECTS = 20

Expand Down Expand Up @@ -477,6 +479,51 @@
"#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{base_url} max_retries=#{@max_retries} timeout=#{@timeout}>"
# rubocop:enable Layout/LineLength
end

define_sorbet_constant!(:RequestComponents) do

Check warning on line 483 in lib/increase/internal/transport/base_client.rb

View workflow job for this annotation

GitHub Actions / lint

Metrics/BlockLength: Block has too many lines. [30/25]
T.type_alias do

Check warning on line 484 in lib/increase/internal/transport/base_client.rb

View workflow job for this annotation

GitHub Actions / lint

Metrics/BlockLength: Block has too many lines. [28/25]
{
method: Symbol,
path: T.any(String, T::Array[String]),
query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]),
headers: T.nilable(
T::Hash[String,
T.nilable(
T.any(
String,
Integer,
T::Array[T.nilable(T.any(String, Integer))]
)
)]
),
body: T.nilable(T.anything),
unwrap: T.nilable(
T.any(
Symbol,
Integer,
T::Array[T.any(Symbol, Integer)],
T.proc.params(arg0: T.anything).returns(T.anything)
)
),
page: T.nilable(T::Class[Increase::Internal::Type::BasePage[Increase::Internal::Type::BaseModel]]),
stream: T.nilable(T::Class[T.anything]),
model: T.nilable(Increase::Internal::Type::Converter::Input),
options: T.nilable(Increase::RequestOptions::OrHash)
}
end
end
define_sorbet_constant!(:RequestInput) do
T.type_alias do
{
method: Symbol,
url: URI::Generic,
headers: T::Hash[String, String],
body: T.anything,
max_retries: Integer,
timeout: Float
}
end
end
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/increase/internal/transport/pooled_net_requester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Internal
module Transport
# @api private
class PooledNetRequester
extend Increase::Internal::Util::SorbetRuntimeSupport

# from the golang stdlib
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
KEEP_ALIVE_TIMEOUT = 30
Expand Down Expand Up @@ -187,6 +189,18 @@ def initialize(size: Etc.nprocessors)
@size = size
@pools = {}
end

define_sorbet_constant!(:Request) do
T.type_alias do
{
method: Symbol,
url: URI::Generic,
headers: T::Hash[String, String],
body: T.anything,
deadline: Float
}
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/increase/internal/type/array_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ArrayOf
#
# @option spec [Boolean] :"nil?"
#
# @return [Increase::Internal::Type::ArrayOf]
# @return [self]
def self.[](...) = new(...)

# @api public
Expand Down
21 changes: 16 additions & 5 deletions lib/increase/internal/type/base_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ module Type
# @abstract
class BaseModel
extend Increase::Internal::Type::Converter
extend Increase::Internal::Util::SorbetRuntimeSupport

class << self
# @api private
#
# Assumes superclass fields are totally defined before fields are accessed /
# defined on subclasses.
#
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
def known_fields
@known_fields ||= (self < Increase::Internal::Type::BaseModel ? superclass.known_fields.dup : {})
# @param child [Class<Increase::Internal::Type::BaseModel>]
def inherited(child)
super
child.known_fields.replace(known_fields.dup)
end

# @api private
#
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
def known_fields = @known_fields ||= {}

# @api private
#
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
Expand Down Expand Up @@ -206,7 +213,7 @@ class << self
#
# @option state [Integer] :branched
#
# @return [Increase::Internal::Type::BaseModel, Object]
# @return [self, Object]
def coerce(value, state:)
exactness = state.fetch(:exactness)

Expand Down Expand Up @@ -265,7 +272,7 @@ def coerce(value, state:)

# @api private
#
# @param value [Increase::Internal::Type::BaseModel, Object]
# @param value [self, Object]
#
# @param state [Hash{Symbol=>Object}] .
#
Expand Down Expand Up @@ -431,6 +438,10 @@ def to_s = self.class.walk(@data).to_s
#
# @return [String]
def inspect = "#<#{self.class}:0x#{object_id.to_s(16)} #{self}>"

define_sorbet_constant!(:KnownField) do
T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean, nilable: T::Boolean} }
end
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions lib/increase/internal/type/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Internal
module Type
# @api private
module Converter
extend Increase::Internal::Util::SorbetRuntimeSupport

# rubocop:disable Lint/UnusedMethodArgument

# @api private
Expand Down Expand Up @@ -268,6 +270,22 @@ def inspect(target, depth:)
end
end
end

define_sorbet_constant!(:Input) do
T.type_alias { T.any(Increase::Internal::Type::Converter, T::Class[T.anything]) }
end
define_sorbet_constant!(:CoerceState) do
T.type_alias do
{
strictness: T.any(T::Boolean, Symbol),
exactness: {yes: Integer, no: Integer, maybe: Integer},
branched: Integer
}
end
end
define_sorbet_constant!(:DumpState) do
T.type_alias { {can_retry: T::Boolean} }
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/increase/internal/type/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Type
# values safely.
module Enum
include Increase::Internal::Type::Converter
include Increase::Internal::Util::SorbetRuntimeSupport

# All of the valid Symbol values for this enum.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/increase/internal/type/hash_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HashOf
#
# @option spec [Boolean] :"nil?"
#
# @return [Increase::Internal::Type::HashOf]
# @return [self]
def self.[](...) = new(...)

# @api public
Expand Down
1 change: 1 addition & 0 deletions lib/increase/internal/type/union.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Type
# @api private
module Union
include Increase::Internal::Type::Converter
include Increase::Internal::Util::SorbetRuntimeSupport

# @api private
#
Expand Down
56 changes: 56 additions & 0 deletions lib/increase/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,62 @@ def decode_sse(lines)
end
end
end

# @api private
module SorbetRuntimeSupport
class MissingSorbetRuntimeError < ::RuntimeError
end

# @api private
#
# @return [Hash{Symbol=>Object}]
private def sorbet_runtime_constants = @sorbet_runtime_constants ||= {}

# @api private
#
# @param name [Symbol]
def const_missing(name)
super unless sorbet_runtime_constants.key?(name)

unless Object.const_defined?(:T)
message = "Trying to access a Sorbet constant #{name.inspect} without `sorbet-runtime`."
raise MissingSorbetRuntimeError.new(message)
end

sorbet_runtime_constants.fetch(name).call
end

# @api private
#
# @param name [Symbol]
# @param blk [Proc]
def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk)
end

extend Increase::Internal::Util::SorbetRuntimeSupport

define_sorbet_constant!(:ParsedUri) do
T.type_alias do
{
scheme: T.nilable(String),
host: T.nilable(String),
port: T.nilable(Integer),
path: T.nilable(String),
query: T::Hash[String, T::Array[String]]
}
end
end

define_sorbet_constant!(:ServerSentEvent) do
T.type_alias do
{
event: T.nilable(String),
data: T.nilable(String),
id: T.nilable(String),
retry: T.nilable(Integer)
}
end
end
end
end
end
27 changes: 27 additions & 0 deletions lib/increase/models.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
# frozen_string_literal: true

module Increase
[Increase::Internal::Type::BaseModel, *Increase::Internal::Type::BaseModel.subclasses].each do |cls|
cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, Increase::Internal::AnyHash) } }
end

[
*Increase::Internal::Type::Enum.included_modules,
*Increase::Internal::Type::Union.included_modules
].each do |cls|
cls.constants.each do |name|
case cls.const_get(name)
in true | false
cls.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T.all(T::Boolean, cls) } }
cls.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } }
in Integer
cls.define_sorbet_constant!(:TaggedInteger) { T.type_alias { T.all(Integer, cls) } }
cls.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } }
in Float
cls.define_sorbet_constant!(:TaggedFloat) { T.type_alias { T.all(Float, cls) } }
cls.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } }
in Symbol
cls.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { T.all(Symbol, cls) } }
cls.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
else
end
end
end

Account = Increase::Models::Account

AccountBalanceParams = Increase::Models::AccountBalanceParams
Expand Down
10 changes: 9 additions & 1 deletion lib/increase/models/simulations/program_create_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ class ProgramCreateParams < Increase::Internal::Type::BaseModel
# @return [String]
required :name, String

# @!method initialize(name:, request_options: {})
# @!attribute reserve_account_id
# The identifier of the Account the Program should be added to is for.
#
# @return [String, nil]
optional :reserve_account_id, String

# @!method initialize(name:, reserve_account_id: nil, request_options: {})
# @param name [String] The name of the program being added.
#
# @param reserve_account_id [String] The identifier of the Account the Program should be added to is for.
#
# @param request_options [Increase::RequestOptions, Hash{Symbol=>Object}]
end
end
Expand Down
Loading
Loading