hearth 1.0.0.pre2 → 1.0.0.pre3

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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/VERSION +1 -1
  4. data/lib/hearth/anonymous_auth_resolver.rb +11 -0
  5. data/lib/hearth/auth_schemes/anonymous.rb +3 -3
  6. data/lib/hearth/auth_schemes.rb +3 -3
  7. data/lib/hearth/client.rb +66 -0
  8. data/lib/hearth/client_stubs.rb +1 -3
  9. data/lib/hearth/config/resolver.rb +6 -5
  10. data/lib/hearth/context.rb +1 -0
  11. data/lib/hearth/dns/host_address.rb +20 -16
  12. data/lib/hearth/endpoint_rules.rb +154 -0
  13. data/lib/hearth/http/client.rb +5 -7
  14. data/lib/hearth/http/error_inspector.rb +2 -2
  15. data/lib/hearth/http/field.rb +4 -19
  16. data/lib/hearth/http/header_list_builder.rb +42 -0
  17. data/lib/hearth/http/header_list_parser.rb +92 -0
  18. data/lib/hearth/http/middleware/content_length.rb +3 -3
  19. data/lib/hearth/http/middleware/content_md5.rb +0 -1
  20. data/lib/hearth/http/middleware/request_compression.rb +7 -10
  21. data/lib/hearth/http.rb +2 -0
  22. data/lib/hearth/{identity_resolver.rb → identity_provider.rb} +1 -1
  23. data/lib/hearth/interceptor_context.rb +8 -4
  24. data/lib/hearth/interceptors.rb +2 -1
  25. data/lib/hearth/json.rb +4 -4
  26. data/lib/hearth/middleware/auth.rb +9 -6
  27. data/lib/hearth/middleware/build.rb +0 -1
  28. data/lib/hearth/middleware/endpoint.rb +79 -0
  29. data/lib/hearth/middleware/host_prefix.rb +1 -2
  30. data/lib/hearth/middleware/initialize.rb +0 -1
  31. data/lib/hearth/middleware/parse.rb +0 -1
  32. data/lib/hearth/middleware/retry.rb +9 -2
  33. data/lib/hearth/middleware/send.rb +0 -1
  34. data/lib/hearth/middleware.rb +1 -0
  35. data/lib/hearth/middleware_stack.rb +1 -1
  36. data/lib/hearth/number_helper.rb +1 -1
  37. data/lib/hearth/query/param.rb +7 -3
  38. data/lib/hearth/query/param_matcher.rb +5 -6
  39. data/lib/hearth/{refreshing_identity_resolver.rb → refreshing_identity_provider.rb} +2 -2
  40. data/lib/hearth/request.rb +2 -2
  41. data/lib/hearth/response.rb +5 -2
  42. data/lib/hearth/retry/adaptive.rb +2 -2
  43. data/lib/hearth/retry/client_rate_limiter.rb +8 -6
  44. data/lib/hearth/retry/exponential_backoff.rb +1 -1
  45. data/lib/hearth/retry/standard.rb +2 -2
  46. data/lib/hearth/retry.rb +16 -3
  47. data/lib/hearth/structure.rb +7 -3
  48. data/lib/hearth/stubs.rb +12 -4
  49. data/lib/hearth/time_helper.rb +1 -2
  50. data/lib/hearth/validator.rb +37 -21
  51. data/lib/hearth/waiters/poller.rb +4 -2
  52. data/lib/hearth/waiters/waiter.rb +6 -5
  53. data/lib/hearth/xml/node.rb +0 -1
  54. data/lib/hearth/xml/node_matcher.rb +0 -1
  55. data/lib/hearth.rb +8 -4
  56. data/sig/lib/hearth/aliases.rbs +5 -3
  57. data/sig/lib/hearth/anonymous_auth_resolver.rbs +5 -0
  58. data/sig/lib/hearth/auth_schemes.rbs +1 -1
  59. data/sig/lib/hearth/client.rbs +9 -0
  60. data/sig/lib/hearth/configuration.rbs +2 -2
  61. data/sig/lib/hearth/dns/host_address.rbs +1 -3
  62. data/sig/lib/hearth/dns/host_resolver.rbs +3 -3
  63. data/sig/lib/hearth/endpoint_rules.rbs +17 -0
  64. data/sig/lib/hearth/http/field.rbs +1 -1
  65. data/sig/lib/hearth/http/fields.rbs +1 -1
  66. data/sig/lib/hearth/http/header_list_builder.rbs +15 -0
  67. data/sig/lib/hearth/http/header_list_parser.rbs +19 -0
  68. data/sig/lib/hearth/http/networking_error.rbs +6 -0
  69. data/sig/lib/hearth/http/response.rbs +1 -1
  70. data/sig/lib/hearth/identities.rbs +1 -1
  71. data/sig/lib/hearth/{identity_resolver.rbs → identity_provider.rbs} +1 -1
  72. data/sig/lib/hearth/interceptor_context.rbs +4 -2
  73. data/sig/lib/hearth/interfaces.rbs +52 -30
  74. data/sig/lib/hearth/json/parse_error.rbs +9 -0
  75. data/sig/lib/hearth/networking_error.rbs +7 -0
  76. data/sig/lib/hearth/output.rbs +4 -4
  77. data/sig/lib/hearth/plugin_list.rbs +5 -7
  78. data/sig/lib/hearth/query/param.rbs +2 -2
  79. data/sig/lib/hearth/refreshing_identity_provider.rbs +10 -0
  80. data/sig/lib/hearth/request.rbs +2 -2
  81. data/sig/lib/hearth/response.rbs +2 -2
  82. data/sig/lib/hearth/retry/exponential_backoff.rbs +1 -1
  83. data/sig/lib/hearth/retry.rbs +1 -1
  84. data/sig/lib/hearth/structure.rbs +1 -2
  85. data/sig/lib/hearth/stubs.rbs +9 -0
  86. data/sig/lib/hearth/union.rbs +1 -1
  87. data/sig/lib/hearth/xml/parse_error.rbs +9 -0
  88. metadata +26 -10
  89. data/lib/hearth/retry/strategy.rb +0 -20
data/lib/hearth/stubs.rb CHANGED
@@ -3,19 +3,27 @@
3
3
  module Hearth
4
4
  # Provides a thread safe data structure for adding and getting stubs
5
5
  # per operation.
6
- # @api private
7
6
  class Stubs
8
- def initialize
9
- @stubs = {}
7
+ # Initializes the stubs with an optional hash of stubs.
8
+ # For an example of stubs, see {ClientStubs}.
9
+ # @param [Hash<Symbol, Array<Stub>>] stubs
10
+ def initialize(stubs = {})
11
+ @stubs = stubs
10
12
  @stub_mutex = Mutex.new
11
13
  end
12
14
 
13
- def add_stubs(operation_name, stubs)
15
+ # Adds a stub or list of stubs to the given operation name.
16
+ # @param [String] operation_name
17
+ # @param [Array<Stub>] stubs
18
+ def set_stubs(operation_name, stubs)
14
19
  @stub_mutex.synchronize do
15
20
  @stubs[operation_name.to_sym] = stubs
16
21
  end
17
22
  end
18
23
 
24
+ # Returns the next stub for the given operation name.
25
+ # @param [String] operation_name
26
+ # @return [Stub, nil]
19
27
  def next(operation_name)
20
28
  @stub_mutex.synchronize do
21
29
  stubs = @stubs[operation_name] || []
@@ -21,8 +21,7 @@ module Hearth
21
21
  def to_epoch_seconds(time)
22
22
  time = time.utc
23
23
  epoch_seconds = time.to_i
24
- epoch_seconds += (time.nsec / 1_000_000) / 1000.0
25
- epoch_seconds
24
+ epoch_seconds + ((time.nsec / 1_000_000) / 1000.0)
26
25
  end
27
26
 
28
27
  # @param [Time] time
@@ -7,17 +7,34 @@ module Hearth
7
7
  # * Raise errors with context when validation fails.
8
8
  # @api private
9
9
  module Validator
10
- # Validate the given value is of the given type(s).
10
+ # Validate the given value is within the expected range (inclusive).
11
11
  # @param value [Object] The value to validate.
12
- # @param types [Array<Class>] The types to validate against.
12
+ # @param min [Numeric] The minimum that the given value should be.
13
+ # @param max [Numeric] The maximum that the given value should be.
13
14
  # @param context [String] The context of the value being validated.
14
- # @raise [ArgumentError] Raises when the value is not one of given type(s).
15
- def self.validate_types!(value, *types, context:)
16
- return if value.nil? || types.any? { |type| value.is_a?(type) }
15
+ # @raise [ArgumentError] Raises when the value is not within expected range.
16
+ def self.validate_range!(value, min:, max:, context:)
17
+ return if value.nil? || value.between?(min, max)
17
18
 
18
19
  raise ArgumentError,
19
- "Expected #{context} to be in " \
20
- "[#{types.map(&:to_s).join(', ')}], got #{value.class}."
20
+ "Expected #{context} to be between " \
21
+ "#{min} to #{max}, got #{value}."
22
+ end
23
+
24
+ # Validate the given value responds to the given methods.
25
+ # @param value [Object] The value to validate.
26
+ # @param methods [Array<Symbol>] The methods to validate against.
27
+ # @param context [String] The context of the value being validated.
28
+ # @raise [ArgumentError] Raises when the value does not respond to the
29
+ # methods.
30
+ def self.validate_responds_to!(value, *methods, context:)
31
+ if value.nil? || methods.all? { |method| value.respond_to?(method) }
32
+ return
33
+ end
34
+
35
+ raise ArgumentError,
36
+ "Expected #{context} to respond to " \
37
+ "[#{methods.map(&:to_s).join(', ')}], got #{value.class}."
21
38
  end
22
39
 
23
40
  # Validate a value is present and not nil.
@@ -28,6 +45,19 @@ module Hearth
28
45
  raise ArgumentError, "Expected #{context} to be set." if value.nil?
29
46
  end
30
47
 
48
+ # Validate the given value is of the given type(s).
49
+ # @param value [Object] The value to validate.
50
+ # @param types [Array<Class>] The types to validate against.
51
+ # @param context [String] The context of the value being validated.
52
+ # @raise [ArgumentError] Raises when the value is not one of given type(s).
53
+ def self.validate_types!(value, *types, context:)
54
+ return if value.nil? || types.any? { |type| value.is_a?(type) }
55
+
56
+ raise ArgumentError,
57
+ "Expected #{context} to be in " \
58
+ "[#{types.map(&:to_s).join(', ')}], got #{value.class}."
59
+ end
60
+
31
61
  # Validate unknown parameters are not present for a given Struct.
32
62
  # @param struct [Struct] The Struct to validate against.
33
63
  # @param params [Hash] The parameters to validate.
@@ -41,19 +71,5 @@ module Hearth
41
71
  raise ArgumentError,
42
72
  "Unexpected members: [#{unknown.join(', ')}]"
43
73
  end
44
-
45
- # Validate the given value is within the expected range (inclusive).
46
- # @param value [Object] The value to validate.
47
- # @param min [Numeric] The minimum that the given value should be.
48
- # @param max [Numeric] The maximum that the given value should be.
49
- # @param context [String] The context of the value being validated.
50
- # @raise [ArgumentError] Raises when the value is not within expected range.
51
- def self.validate_range!(value, min:, max:, context:)
52
- return if value.nil? || value.between?(min, max)
53
-
54
- raise ArgumentError,
55
- "Expected #{context} to be between " \
56
- "#{min} to #{max}, got #{value}."
57
- end
58
74
  end
59
75
  end
@@ -21,7 +21,7 @@ module Hearth
21
21
  # * `:retry` - The waiter may be retried.
22
22
  # * `:error` - The waiter encountered an un-expected error.
23
23
  #
24
- # @example A trival (bad) example of a waiter that polls indefinetly.
24
+ # @example A trivial (bad) example of a waiter that polls indefinitely.
25
25
  #
26
26
  # loop do
27
27
  #
@@ -39,7 +39,7 @@ module Hearth
39
39
  # @param [Client] client
40
40
  # @param [Hash] params
41
41
  # @param [Hash] options
42
- # @return [Array<Symbol,Response>]
42
+ # @return [Array<Symbol, Response, ApiError>]
43
43
  def call(client, params = {}, options = {})
44
44
  begin
45
45
  options = options.merge(input_output_interceptor)
@@ -81,6 +81,8 @@ module Hearth
81
81
  end
82
82
 
83
83
  def error_type_matcher?(matcher, error)
84
+ return false unless error
85
+
84
86
  # handle shape ID cases
85
87
  matcher = matcher.split('#').last.split('$').first
86
88
  error.class.to_s.include?(matcher) || error.error_code == matcher
@@ -68,11 +68,12 @@ module Hearth
68
68
  end
69
69
 
70
70
  def delay(attempt)
71
- delay = if attempt > attempt_ceiling
72
- max_delay
73
- else
74
- min_delay * (2**(attempt - 1))
75
- end
71
+ delay =
72
+ if attempt > attempt_ceiling
73
+ max_delay
74
+ else
75
+ min_delay * (2**(attempt - 1))
76
+ end
76
77
 
77
78
  delay = Kernel.rand(min_delay..delay)
78
79
 
@@ -5,7 +5,6 @@ module Hearth
5
5
  # A class used to represent an XML node.
6
6
  # @api private
7
7
  class Node
8
- # @api private
9
8
  BOTH_TYPES = 'Nodes may not have both text and child nodes'
10
9
 
11
10
  # @param [String] name
@@ -3,7 +3,6 @@
3
3
  require 'rspec/expectations'
4
4
 
5
5
  # Provides an rspec matcher for Hearth::XML::Node
6
- # @api private
7
6
  RSpec::Matchers.define :match_xml_node do |expected|
8
7
  match do |actual|
9
8
  return true if actual == expected
data/lib/hearth.rb CHANGED
@@ -6,10 +6,11 @@ require_relative 'hearth/auth_option'
6
6
  # must be required before auth_schemes
7
7
  require_relative 'hearth/identities'
8
8
  require_relative 'hearth/auth_schemes'
9
+ require_relative 'hearth/anonymous_auth_resolver'
9
10
 
10
11
  require_relative 'hearth/block_io'
11
12
  require_relative 'hearth/checksums'
12
- require_relative 'hearth/client_stubs'
13
+ require_relative 'hearth/client'
13
14
  require_relative 'hearth/configuration'
14
15
  require_relative 'hearth/config/env_provider'
15
16
  require_relative 'hearth/config/resolver'
@@ -23,8 +24,12 @@ require_relative 'hearth/networking_error'
23
24
  require_relative 'hearth/request'
24
25
  require_relative 'hearth/response'
25
26
 
27
+ # must be required before endpoint rules
28
+ require_relative 'hearth/structure'
29
+
30
+ require_relative 'hearth/endpoint_rules'
26
31
  require_relative 'hearth/http'
27
- require_relative 'hearth/identity_resolver'
32
+ require_relative 'hearth/identity_provider'
28
33
  require_relative 'hearth/interceptor'
29
34
  require_relative 'hearth/interceptors'
30
35
  require_relative 'hearth/interceptor_context'
@@ -36,10 +41,9 @@ require_relative 'hearth/number_helper'
36
41
  require_relative 'hearth/output'
37
42
  require_relative 'hearth/query/param'
38
43
  require_relative 'hearth/query/param_list'
39
- require_relative 'hearth/refreshing_identity_resolver'
44
+ require_relative 'hearth/refreshing_identity_provider'
40
45
  require_relative 'hearth/retry'
41
46
  require_relative 'hearth/signers'
42
- require_relative 'hearth/structure'
43
47
  require_relative 'hearth/stubs'
44
48
  require_relative 'hearth/time_helper'
45
49
  require_relative 'hearth/union'
@@ -1,4 +1,6 @@
1
- type document = Hash[Symbol,document] | Array[document] | String | bool | Numeric
1
+ module Hearth
2
+ type document = Hash[Symbol, document] | Array[document] | String | bool | Numeric
2
3
 
3
- type stub = Hearth::Structure | Hearth::Response | { data: Hash[Symbol, untyped] } |
4
- { error: { class: Class, data: Hash[Symbol, untyped] } } | Hearth::ApiError | Proc
4
+ type stub = Structure | Response | { data: Hash[Symbol, untyped] } |
5
+ { error: { class: Class, data: Hash[Symbol, untyped] } } | ApiError | Proc
6
+ end
@@ -0,0 +1,5 @@
1
+ module Hearth
2
+ class AnonymousAuthResolver
3
+ def resolve: -> ::Array[AuthOption]
4
+ end
5
+ end
@@ -5,7 +5,7 @@ module Hearth
5
5
 
6
6
  attr_reader scheme_id: String
7
7
 
8
- def identity_resolver: (?Hash[Symbol, IdentityResolver] identity_resolvers) -> IdentityResolver
8
+ def identity_provider: (?Hash[Symbol, IdentityProvider] identity_providers) -> IdentityProvider
9
9
 
10
10
  attr_reader signer: Signers::Base
11
11
  end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ class Client
3
+ def initialize: (Hash[Symbol, untyped], Class) -> void
4
+
5
+ attr_reader config: untyped
6
+
7
+ def self.plugins: () -> PluginList[untyped]
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  module Hearth
2
- module Configuration
2
+ module Configuration[ServiceConfig]
3
3
  def initialize: (**Hash[Symbol, untyped] options) -> void
4
4
 
5
- def dup: () -> Hearth::Configuration
5
+ def merge: (Hash[Symbol, untyped] configuration) -> ServiceConfig
6
6
  end
7
7
  end
@@ -1,8 +1,6 @@
1
1
  module Hearth
2
2
  module DNS
3
- class HostAddress
4
- def initialize: (address_type: Symbol, address: String, hostname: String) -> void
5
-
3
+ class HostAddress < Struct[untyped]
6
4
  attr_reader address_type: Symbol
7
5
 
8
6
  attr_reader address: String
@@ -5,13 +5,13 @@ module Hearth
5
5
 
6
6
  attr_reader service: Integer
7
7
 
8
- attr_reader family: Integer
8
+ attr_reader family: Integer?
9
9
 
10
10
  attr_reader socktype: Symbol
11
11
 
12
- attr_reader protocol: Integer
12
+ attr_reader protocol: Integer?
13
13
 
14
- attr_reader flags: Integer
14
+ attr_reader flags: Integer?
15
15
 
16
16
  def resolve_address: (nodename: String, ?service: Integer, ?family: Integer?, ?socktype: Symbol, ?protocol: Integer?, ?flags: Integer?) -> Array[HostAddress]
17
17
  end
@@ -0,0 +1,17 @@
1
+ module Hearth
2
+ module EndpointRules
3
+ class AuthScheme < Struct[untyped]
4
+ attr_accessor scheme_id: String
5
+
6
+ attr_accessor properties: Hash[String, untyped]
7
+ end
8
+
9
+ class Endpoint < Struct[untyped]
10
+ attr_accessor uri: String
11
+
12
+ attr_accessor auth_schemes: Array[AuthScheme]
13
+
14
+ attr_accessor headers: Hash[String, String | Array[String]]
15
+ end
16
+ end
17
+ end
@@ -1,7 +1,7 @@
1
1
  module Hearth
2
2
  module HTTP
3
3
  class Field
4
- def initialize: (String name, ?(Array[String] | _ToS)? value, ?kind: Symbol) -> void
4
+ def initialize: (String name, ?(_ToS)? value, ?kind: Symbol) -> void
5
5
 
6
6
  attr_reader name: String
7
7
 
@@ -28,7 +28,7 @@ module Hearth
28
28
 
29
29
  def []: (String key) -> (String | nil)
30
30
 
31
- def []=: (String, String) -> String
31
+ def []=: (String, String) -> Field
32
32
 
33
33
  def key?: (String) -> bool
34
34
 
@@ -0,0 +1,15 @@
1
+ module Hearth
2
+ module HTTP
3
+ module HeaderListBuilder
4
+ def self.build_list: (Array[untyped] value) -> String
5
+
6
+ def self.build_string_list: (Array[String] value ) -> String
7
+
8
+ def self.build_http_date_list: (Array[Time] value) -> String
9
+
10
+ def self.build_date_time_list: (Array[Time] value) -> String
11
+
12
+ def self.build_epoch_seconds_list: (Array[Time] value) -> String
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module Hearth
2
+ module HTTP
3
+ module HeaderListParser
4
+ def self.parse_boolean_list: (String value) -> Array[bool]
5
+
6
+ def self.parse_integer_list: (String value) -> Array[Integer]
7
+
8
+ def self.parse_float_list: (String value) -> Array[Float]
9
+
10
+ def self.build_string_list: (String value ) -> Array[String]
11
+
12
+ def self.build_http_date_list: (String value ) -> Array[Time]
13
+
14
+ def self.build_date_time_list: (String value ) -> Array[Time]
15
+
16
+ def self.build_epoch_seconds_list: (String value ) -> Array[Time]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ module Hearth
2
+ module HTTP
3
+ class NetworkingError < Hearth::NetworkingError
4
+ end
5
+ end
6
+ end
@@ -1,7 +1,7 @@
1
1
  module Hearth
2
2
  module HTTP
3
3
  class Response < Hearth::Response
4
- def initialize: (?status: Integer, ?reason: String?, ?fields: Fields, ?body: IO) -> void
4
+ def initialize: (?status: Integer, ?reason: String?, ?fields: Fields, ?body: _WritableIO) -> void
5
5
 
6
6
  attr_accessor status: Integer
7
7
 
@@ -3,7 +3,7 @@ module Hearth
3
3
  class Base
4
4
  def initialize: (?expiration: Time?) -> void
5
5
 
6
- attr_reader expiration: Time
6
+ attr_reader expiration: Time?
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module Hearth
2
- class IdentityResolver
2
+ class IdentityProvider
3
3
  def initialize: (Proc) -> void
4
4
 
5
5
  def identity: (?Hash[Symbol, untyped] properties) -> Identities::Base
@@ -1,6 +1,6 @@
1
1
  module Hearth
2
2
  class InterceptorContext
3
- def initialize: (input: Structure, request: Request, response: Response, output: Structure, ?attributes: Hash[Symbol, untyped]) -> void
3
+ def initialize: (input: Structure, request: Request, response: Response, output: Output[Structure], logger: Logger) -> void
4
4
 
5
5
  attr_reader input: Structure
6
6
 
@@ -8,7 +8,9 @@ module Hearth
8
8
 
9
9
  attr_reader response: Response
10
10
 
11
- attr_reader output: Structure
11
+ attr_reader output: Output[Structure]
12
+
13
+ attr_reader logger: Logger
12
14
 
13
15
  attr_reader attributes: Hash[Symbol, untyped]
14
16
  end
@@ -10,56 +10,78 @@ end
10
10
  class Logger
11
11
  end
12
12
 
13
- interface _Plugin
14
- def call: (Hearth::Configuration) -> void
15
- end
13
+ module Hearth
14
+ interface _Plugin[ServiceConfig]
15
+ def call: (ServiceConfig) -> void
16
+ end
16
17
 
17
- interface _Interceptor
18
- def read_before_execution: (Hearth::InterceptorContext) -> void
18
+ interface _Interceptor
19
+ def read_before_execution: (InterceptorContext) -> void
19
20
 
20
- def modify_before_serialization: (Hearth::InterceptorContext) -> void
21
+ def modify_before_serialization: (InterceptorContext) -> void
21
22
 
22
- def read_before_serialization: (Hearth::InterceptorContext) -> void
23
+ def read_before_serialization: (InterceptorContext) -> void
23
24
 
24
- def read_after_serialization: (Hearth::InterceptorContext) -> void
25
+ def read_after_serialization: (InterceptorContext) -> void
25
26
 
26
- def modify_before_retry_loop: (Hearth::InterceptorContext) -> void
27
+ def modify_before_retry_loop: (InterceptorContext) -> void
27
28
 
28
- def read_before_attempt: (Hearth::InterceptorContext) -> void
29
+ def read_before_attempt: (InterceptorContext) -> void
29
30
 
30
- def modify_before_signing: (Hearth::InterceptorContext) -> void
31
+ def modify_before_signing: (InterceptorContext) -> void
31
32
 
32
- def read_before_signing: (Hearth::InterceptorContext) -> void
33
+ def read_before_signing: (InterceptorContext) -> void
33
34
 
34
- def read_after_signing: (Hearth::InterceptorContext) -> void
35
+ def read_after_signing: (InterceptorContext) -> void
35
36
 
36
- def modify_before_transmit: (Hearth::InterceptorContext) -> void
37
+ def modify_before_transmit: (InterceptorContext) -> void
37
38
 
38
- def read_before_transmit: (Hearth::InterceptorContext) -> void
39
+ def read_before_transmit: (InterceptorContext) -> void
39
40
 
40
- def read_after_transmit: (Hearth::InterceptorContext) -> void
41
+ def read_after_transmit: (InterceptorContext) -> void
41
42
 
42
- def modify_before_deserialization: (Hearth::InterceptorContext) -> void
43
+ def modify_before_deserialization: (InterceptorContext) -> void
43
44
 
44
- def read_before_deserialization: (Hearth::InterceptorContext) -> void
45
+ def read_before_deserialization: (InterceptorContext) -> void
45
46
 
46
- def read_after_deserialization: (Hearth::InterceptorContext) -> void
47
+ def read_after_deserialization: (InterceptorContext) -> void
47
48
 
48
- def modify_before_attempt_completion: (Hearth::InterceptorContext) -> void
49
+ def modify_before_attempt_completion: (InterceptorContext) -> void
49
50
 
50
- def read_after_attempt: (Hearth::InterceptorContext) -> void
51
+ def read_after_attempt: (InterceptorContext) -> void
51
52
 
52
- def modify_before_completion: (Hearth::InterceptorContext) -> void
53
+ def modify_before_completion: (InterceptorContext) -> void
53
54
 
54
- def read_after_execution: (Hearth::InterceptorContext) -> void
55
- end
55
+ def read_after_execution: (InterceptorContext) -> void
56
+ end
57
+
58
+ interface _ErrorInspector
59
+ def initialize: (ApiError, Response) -> void
60
+
61
+ def retryable?: () -> bool
62
+
63
+ def error_type: () -> String
56
64
 
57
- interface _ErrorInspector
58
- def initialize: (Hearth::ApiError, Hearth::Response) -> void
65
+ def hints: () -> Hash[Symbol, untyped]
66
+ end
59
67
 
60
- def retryable?: () -> bool
68
+ interface _RetryStrategy
69
+ def acquire_initial_retry_token: (?String? _token_scope) -> Retry::Token
61
70
 
62
- def error_type: () -> String
71
+ def refresh_retry_token: (Retry::Token _retry_token, _ErrorInspector _error_info) -> Retry::Token?
63
72
 
64
- def hints: () -> Hash[Symbol, untyped]
65
- end
73
+ def record_success: (Retry::Token _retry_token) -> Retry::Token
74
+ end
75
+
76
+ interface _AuthResolver[Params]
77
+ def resolve: (Params) -> AuthSchemes::Base
78
+ end
79
+
80
+ interface _EndpointResolver[Params]
81
+ def resolve: (Params) -> EndpointRules::Endpoint
82
+ end
83
+
84
+ interface _WritableIO
85
+ def write: (*_ToS) -> Integer
86
+ end
87
+ end
@@ -0,0 +1,9 @@
1
+ module Hearth
2
+ module JSON
3
+ class ParseError < StandardError
4
+ def initialize: (StandardError original_error) -> void
5
+
6
+ attr_reader original_error: StandardError
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Hearth
2
+ class NetworkingError < StandardError
3
+ def initialize: (StandardError original_error) -> void
4
+
5
+ attr_reader original_error: StandardError
6
+ end
7
+ end
@@ -1,10 +1,10 @@
1
1
  module Hearth
2
- class Output
3
- def initialize: (?error: (ApiError)?, ?data: (Structure)?, ?metadata: Hash[Symbol, untyped]) -> void
2
+ class Output[DATA]
3
+ def initialize: (?error: ApiError?, ?data: Structure?, ?metadata: Hash[Symbol, untyped]) -> void
4
4
 
5
- attr_accessor error: (ApiError | nil)
5
+ attr_accessor error: ApiError?
6
6
 
7
- attr_accessor data: (Structure | nil)
7
+ attr_accessor data: DATA?
8
8
 
9
9
  attr_accessor metadata: Hash[Symbol, untyped]
10
10
  end
@@ -1,15 +1,13 @@
1
1
  module Hearth
2
- class PluginList
3
- def initialize: (?Array[_Plugin] plugins) -> void
2
+ class PluginList[ServiceConfig]
3
+ def initialize: (?Array[_Plugin[ServiceConfig]] plugins) -> void
4
4
 
5
- def add: (_Plugin plugin) -> void
5
+ def add: (_Plugin[ServiceConfig] plugin) -> void
6
6
 
7
7
  alias << add
8
8
 
9
- def apply: (Hearth::Configuration) -> void
9
+ def apply: (ServiceConfig) -> void
10
10
 
11
- def dup: () -> PluginList
12
-
13
- def each: () ?{ (_Plugin) -> void } -> void
11
+ def each: () ?{ (_Plugin[ServiceConfig]) -> void } -> void
14
12
  end
15
13
  end
@@ -5,13 +5,13 @@ module Hearth
5
5
 
6
6
  attr_reader name: String
7
7
 
8
- attr_reader value: (String | Array[String])
8
+ attr_reader value: (String | Array[String])?
9
9
 
10
10
  def to_s: () -> String
11
11
 
12
12
  def ==: (Param other) -> bool
13
13
 
14
- def <=>: (Param other) -> bool
14
+ def <=>: (Param other) -> Integer
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,10 @@
1
+ module Hearth
2
+ module RefreshingIdentityProvider
3
+ ASYNC_EXPIRATION_LENGTH: Integer
4
+ SYNC_EXPIRATION_LENGTH: Integer
5
+
6
+ def initialize: -> void
7
+
8
+ def identity: (?Hash[Symbol, untyped] properties) -> Identities::Base
9
+ end
10
+ end
@@ -1,9 +1,9 @@
1
1
  module Hearth
2
2
  class Request
3
- def initialize: (?uri: URI, ?body: IO) -> void
3
+ def initialize: (?uri: URI, ?body: (IO | StringIO)) -> void
4
4
 
5
5
  attr_accessor uri: URI
6
6
 
7
- attr_accessor body: IO
7
+ attr_accessor body: (IO | StringIO)
8
8
  end
9
9
  end