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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.prism.log
*.gem
.idea/
.prism.log
.ruby-lsp/
.yardoc/
doc/
sorbet/
Brewfile.lock.json
bin/tapioca
*.gem
doc/
sorbet/*
!/sorbet/config
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.28"
".": "0.1.0-alpha.29"
}
31 changes: 31 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ AllCops:
SuggestExtensions: false
TargetRubyVersion: 3.1.0

# Whether MFA is required or not should be left to the token configuration.
Gemspec/RequireMFA:
Enabled: false

# Don't require this extra line break, it can be excessive.
Layout/EmptyLineAfterGuardClause:
Enabled: false
Expand Down Expand Up @@ -68,6 +72,10 @@ Lint/EmptyInPattern:
Exclude:
- "test/**/*"

Lint/MissingCopEnableDirective:
Exclude:
- "examples/**/*.rb"

Lint/MissingSuper:
Exclude:
- "**/*.rbi"
Expand All @@ -79,6 +87,12 @@ Lint/UnusedMethodArgument:
Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
AllowedPatterns:
- assert_pattern
Exclude:
- "**/*.rbi"

Metrics/ClassLength:
Enabled: false

Expand All @@ -88,6 +102,10 @@ Metrics/CyclomaticComplexity:
Metrics/MethodLength:
Enabled: false

Metrics/ModuleLength:
Exclude:
- "**/*.rbi"

Metrics/ParameterLists:
Enabled: false

Expand All @@ -98,10 +116,18 @@ Naming/BlockForwarding:
Exclude:
- "**/*.rbi"

Naming/ClassAndModuleCamelCase:
Exclude:
- "**/*.rbi"

Naming/MethodParameterName:
Exclude:
- "**/*.rbi"

Naming/PredicateName:
Exclude:
- "**/*.rbi"

Naming/VariableNumber:
Enabled: false

Expand Down Expand Up @@ -215,3 +241,8 @@ Style/StringLiterals:
# Prefer explicit symbols for clarity; you can search for `:the_symbol`.
Style/SymbolArray:
EnforcedStyle: brackets

# This option makes examples harder to read for ruby novices.
Style/SymbolProc:
Exclude:
- "examples/**/*.rb"
10 changes: 10 additions & 0 deletions .solargraph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
max_files: 0
include:
- '*.gemspec'
- 'Rakefile'
- 'examples/**/*.rb'
- 'lib/**/*.rb'
- 'test/orb/test_helper.rb'
exclude:
- 'rbi/**/*'
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 103
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-aeb94d91af916dbff0132ee7c4501df9223609b19fef0398a1a495e7a432ee36.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-36a6db97756e8658369c9af3c0ac532ecacb032e5b8f6211094dcb4052943ff3.yml
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## 0.1.0-alpha.29 (2025-03-21)

Full Changelog: [v0.1.0-alpha.28...v0.1.0-alpha.29](https://github.com/orbcorp/orb-ruby/compare/v0.1.0-alpha.28...v0.1.0-alpha.29)

### ⚠ BREAKING CHANGES

* support `for item in stream` style iteration on `Stream`s ([#173](https://github.com/orbcorp/orb-ruby/issues/173))

### Features

* support `for item in stream` style iteration on `Stream`s ([#173](https://github.com/orbcorp/orb-ruby/issues/173)) ([588fd1d](https://github.com/orbcorp/orb-ruby/commit/588fd1de378ca262b9db8b368386a7aab7b2a36f))


### Bug Fixes

* pages should be able to accept non-converter models ([#176](https://github.com/orbcorp/orb-ruby/issues/176)) ([99b36e2](https://github.com/orbcorp/orb-ruby/commit/99b36e212b42bcc173fb6b37991f4d82731ef507))


### Chores

* add `[@yieldparam](https://github.com/yieldparam)` to yard doc ([#170](https://github.com/orbcorp/orb-ruby/issues/170)) ([b6918c1](https://github.com/orbcorp/orb-ruby/commit/b6918c1152a904e29ce040c5dd2cd5e5cb056191))
* disable overloads in `*.rbs` definitions for readable LSP errors ([#172](https://github.com/orbcorp/orb-ruby/issues/172)) ([44a5b19](https://github.com/orbcorp/orb-ruby/commit/44a5b194dfcbea531ee4bdf63a34008304f9c878))
* document Client's concurrency capability ([#169](https://github.com/orbcorp/orb-ruby/issues/169)) ([99f36ef](https://github.com/orbcorp/orb-ruby/commit/99f36efba8586dae3cde19d103254335142e8341))
* ignore some spurious linter warnings and formatting changes ([#168](https://github.com/orbcorp/orb-ruby/issues/168)) ([0925835](https://github.com/orbcorp/orb-ruby/commit/0925835eceda886f027946a4368ddc534f5c3ce0))
* **internal:** codegen related update ([#174](https://github.com/orbcorp/orb-ruby/issues/174)) ([4b4ddd6](https://github.com/orbcorp/orb-ruby/commit/4b4ddd67f9c8f51e786dd6cd902f0e4677942945))
* **internal:** version bump ([#166](https://github.com/orbcorp/orb-ruby/issues/166)) ([421c2f7](https://github.com/orbcorp/orb-ruby/commit/421c2f770dcb42147266c5630f0919f247d21b9c))
* switch to prettier looking sorbet annotations ([#175](https://github.com/orbcorp/orb-ruby/issues/175)) ([19ab2d6](https://github.com/orbcorp/orb-ruby/commit/19ab2d6ba75461fd1f96598b480932e152407157))
* use multi-line formatting style for really long lines ([#171](https://github.com/orbcorp/orb-ruby/issues/171)) ([7b3ad6e](https://github.com/orbcorp/orb-ruby/commit/7b3ad6e5dbee813dfc0a7f1ea04e01a48e31dd11))

## 0.1.0-alpha.28 (2025-03-18)

Full Changelog: [v0.1.0-alpha.27...v0.1.0-alpha.28](https://github.com/orbcorp/orb-ruby/compare/v0.1.0-alpha.27...v0.1.0-alpha.28)
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:
orb (0.1.0.pre.alpha.28)
orb (0.1.0.pre.alpha.29)
connection_pool

GEM
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ orb.customers.create(

## Sorbet Support

**This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.

This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.

What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet itself.
Expand All @@ -150,6 +152,18 @@ model = CustomerCreateParams.new(email: "example-customer@withorb.com", name: "M
orb.customers.create(**model)
```

## Advanced

### Concurrency & Connection Pooling

The `Orb::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count.

When the maximum number of connections has been checked out from the connection pool, the `Client` will wait for an in use connection to become available. The queue time for this mechanism is accounted for by the per-request timeout.

Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.

Currently, `Orb::Client` instances are only fork-safe if there are no in-flight HTTP requests.

## Versioning

This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
Expand Down
23 changes: 12 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ multitask(:syntax_tree) do
inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? %w[-i''] : %w[-i]
uuid = SecureRandom.uuid

# `syntax_tree` has trouble with `rbs`'s class aliases
# `syntax_tree` has trouble with `rbs`'s class & module aliases

sed = xargs + %w[sed -E] + inplace + %w[-e]
# annotate class aliases with a unique comment
pre = sed + ["s/class ([^ ]+) = (.+$)/# #{uuid}\\n\\1: \\2/", "--"]
# annotate unprocessable aliases with a unique comment
pre = sed + ["s/(class|module) ([^ ]+) = (.+$)/# \\1 #{uuid}\\n\\2: \\3/", "--"]
fmt = xargs + %w[stree write --plugin=rbs --]
# remove the unique comment and transform class aliases to type aliases
# remove the unique comment and unprocessable aliases to type aliases
subst = <<~SED
s/# #{uuid}//
s/# (class|module) #{uuid}/\\1/
t l1
b

: l1
n
s/([^ :]+): (.+$)/class \\1 = \\2/
N
s/\\n *([^:]+): (.+)$/ \\1 = \\2/
SED
# 1. delete the unique comment
# 2. if deletion happened, branch to label `l1`, else continue
# 3. transform the class alias to a type alias at label `l1`
# for each line:
# 1. try transform the unique comment into `class | module`, if successful, branch to label `l1`.
# 2. at label `l1`, join previously annotated line with `class | module` information.
pst = sed + [subst, "--"]

# transform class aliases to type aliases, which syntax tree has no trouble with
Expand All @@ -70,7 +71,7 @@ multitask(:steep) do
end

multitask(:sorbet) do
sh(*%w[srb typecheck -- .], chdir: "./rbi")
sh(*%w[srb typecheck])
end

file("sorbet/tapioca") do
Expand Down
4 changes: 4 additions & 0 deletions examples/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
File generated from our OpenAPI spec by Stainless.

This directory can be used to store example files demonstrating usage of this SDK.
It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
15 changes: 15 additions & 0 deletions lib/orb.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# frozen_string_literal: true

# We already ship the preferred sorbet manifests in the package itself.
# `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
if defined?(:Tapioca) && caller_locations.any? { _1.path.end_with?("tapioca/cli.rb") }

Check warning on line 5 in lib/orb.rb

View workflow job for this annotation

GitHub Actions / lint

Lint/UselessDefined: Calling `defined?` with a symbol argument will always return a truthy value.
Warning.warn(
<<~WARN
\n
⚠️ skipped loading of "orb" gem under `tapioca`.

This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation.
\n
WARN
)
return
end

# Standard libraries.
require "cgi"
require "date"
Expand Down
21 changes: 11 additions & 10 deletions lib/orb/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ class BaseClient
MAX_REDIRECTS = 20

# rubocop:disable Style/MutableConstant
PLATFORM_HEADERS = {
"x-stainless-arch" => Orb::Util.arch,
"x-stainless-lang" => "ruby",
"x-stainless-os" => Orb::Util.os,
"x-stainless-package-version" => Orb::VERSION,
"x-stainless-runtime" => ::RUBY_ENGINE,
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
}
PLATFORM_HEADERS =
{
"x-stainless-arch" => Orb::Util.arch,
"x-stainless-lang" => "ruby",
"x-stainless-os" => Orb::Util.os,
"x-stainless-package-version" => Orb::VERSION,
"x-stainless-runtime" => ::RUBY_ENGINE,
"x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
}
# rubocop:enable Style/MutableConstant

class << self
Expand Down Expand Up @@ -219,7 +220,7 @@ def initialize(
#
# @option opts [Hash{String=>String, nil}, nil] :extra_headers
#
# @option opts [Hash{Symbol=>Object}, nil] :extra_body
# @option opts [Object, nil] :extra_body
#
# @option opts [Integer, nil] :max_retries
#
Expand Down Expand Up @@ -436,7 +437,7 @@ def request(req)
decoded = Orb::Util.decode_content(response, stream: stream)
case req
in { stream: Class => st }
st.new(model: model, url: url, status: status, response: response, messages: decoded)
st.new(model: model, url: url, status: status, response: response, stream: decoded)
in { page: Class => page }
page.new(client: self, req: req, headers: response, page_data: decoded)
else
Expand Down
Loading
Loading