vigiles 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -0
  4. data/lib/vigiles/archive/extras.rb +1 -1
  5. data/lib/vigiles/archive/metadata.rb +1 -1
  6. data/lib/vigiles/archive/response.rb +31 -5
  7. data/lib/vigiles/archive.rb +1 -1
  8. data/lib/vigiles/constants.rb +1 -1
  9. data/lib/vigiles/conversation_recorder.rb +3 -0
  10. data/lib/vigiles/conversation_recorders/application_json.rb +11 -6
  11. data/lib/vigiles/conversation_recorders/unknown.rb +3 -0
  12. data/lib/vigiles/middleware/record_conversation.rb +2 -2
  13. data/lib/vigiles/utilities/json.rb +2 -4
  14. data/lib/vigiles/version.rb +1 -1
  15. data/sorbet/rbi/gems/concurrent-ruby@1.3.1.rbi +11627 -0
  16. data/sorbet/rbi/gems/{json@2.7.1.rbi → json@2.7.2.rbi} +73 -72
  17. data/sorbet/rbi/gems/{minitest@5.22.2.rbi → minitest@5.23.1.rbi} +841 -159
  18. data/sorbet/rbi/gems/{parser@3.3.0.5.rbi → parser@3.3.1.0.rbi} +233 -186
  19. data/sorbet/rbi/gems/{prism@0.24.0.rbi → prism@0.29.0.rbi} +19135 -12188
  20. data/sorbet/rbi/gems/{racc@1.7.3.rbi → racc@1.8.0.rbi} +34 -33
  21. data/sorbet/rbi/gems/{rake@13.1.0.rbi → rake@13.2.1.rbi} +77 -55
  22. data/sorbet/rbi/gems/{rbi@0.1.9.rbi → rbi@0.1.13.rbi} +226 -154
  23. data/sorbet/rbi/gems/{rdoc@6.6.3.1.rbi → rdoc@6.7.0.rbi} +333 -327
  24. data/sorbet/rbi/gems/{regexp_parser@2.9.0.rbi → regexp_parser@2.9.2.rbi} +3 -2
  25. data/sorbet/rbi/gems/{reline@0.5.7.rbi → reline@0.5.8.rbi} +1 -0
  26. data/sorbet/rbi/gems/{rexml@3.2.6.rbi → rexml@3.2.8.rbi} +121 -108
  27. data/sorbet/rbi/gems/{rubocop-ast@1.30.0.rbi → rubocop-ast@1.31.3.rbi} +92 -62
  28. data/sorbet/rbi/gems/{rubocop-minitest@0.34.5.rbi → rubocop-minitest@0.35.0.rbi} +35 -0
  29. data/sorbet/rbi/gems/{rubocop-sorbet@0.7.4.rbi → rubocop-sorbet@0.8.3.rbi} +327 -162
  30. data/sorbet/rbi/gems/{rubocop@1.60.2.rbi → rubocop@1.64.0.rbi} +1719 -1065
  31. data/sorbet/rbi/gems/{spoom@1.2.4.rbi → spoom@1.3.2.rbi} +1057 -413
  32. data/sorbet/rbi/gems/strscan@3.1.0.rbi +9 -0
  33. data/sorbet/rbi/gems/{tapioca@0.12.0.rbi → tapioca@0.14.2.rbi} +123 -448
  34. data/sorbet/rbi/gems/{thor@1.3.0.rbi → thor@1.3.1.rbi} +57 -50
  35. data/sorbet/rbi/gems/{yard@0.9.34.rbi → yard@0.9.36.rbi} +230 -37
  36. data/sorbet/rbi/gems/{zeitwerk@2.6.13.rbi → zeitwerk@2.6.15.rbi} +47 -36
  37. data/vigiles.gemspec +1 -1
  38. metadata +27 -27
  39. data/sorbet/rbi/gems/concurrent-ruby@1.2.3.rbi +0 -8
  40. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +0 -951
  41. data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +0 -23136
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c7da56eb222eab7028b219abca2ba0e58d07e6ea839e8cf128e2f06899e8369
4
- data.tar.gz: 5cf3f8e95434d3db95d2fecf235e9887f13418999d67419428714054b5971816
3
+ metadata.gz: '08d13600f7b4174e33a7e521448bf0e4f0ef47558e71a7efb7ce981a116f70da'
4
+ data.tar.gz: cf7c0fa969ae7583ee17ce277446dd1767277b3bb36af16b2fec807c411ef3b8
5
5
  SHA512:
6
- metadata.gz: 0fab3769857951735aa3d586eb6cb1de7793f2687396cac8503d2804f22a75b6e786d96f68ecfff112f15ce7f7e152362c146f9c14f9af77f370d671918848c5
7
- data.tar.gz: 7751d30f849eb16247aa8a23c7c7d07825b10080fa5689954d2493d2a9602fdfd2436c94ba64bacee1d455af9edfd9333a7fe6a11bd17d8dd583f6465cd6c2e8
6
+ metadata.gz: 1a5320beaccd2f32fd8d622e7561a2230f001a7f551561fb01f6eb94bfba092369af3690c0dd5728d5d1118072e9e42c41e50f39f1dace9aafab0af74c1cdc2c
7
+ data.tar.gz: 6cbab6e02ee4513c9b9755779fc935d230989e789a9610dc9a0bd10cd882afd31c7a4f328a7461c123d951df534025d2e8f67f4a769a61bf7a0891a0461de574
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ require:
4
4
  - rubocop-sorbet
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 3.0
7
+ TargetRubyVersion: 3.3
8
8
  Exclude:
9
9
  - "**/generators/**/*"
10
10
  - "**/sorbet/**/*"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.1
@@ -8,7 +8,7 @@ module Vigiles
8
8
 
9
9
  sig { params(request_env: T::Hash[T.untyped, T.untyped]).returns(Extras) }
10
10
  def self.from(request_env)
11
- Extras.new(request_env: request_env)
11
+ Extras.new(request_env:)
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module Vigiles
8
8
 
9
9
  sig { params(request_env: T::Hash[T.untyped, T.untyped]).returns(Metadata) }
10
10
  def self.from(request_env)
11
- Metadata.new(request_env: request_env)
11
+ Metadata.new(request_env:)
12
12
  end
13
13
  end
14
14
  end
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Vigiles
@@ -10,6 +10,33 @@ module Vigiles
10
10
  const :payload, Types::Payload
11
11
  const :status, Integer
12
12
 
13
+ class ResponseBodyTooDeepError < StandardError
14
+ sig { returns(Integer) }
15
+ attr_reader :max_stack_depth
16
+
17
+ sig { returns(Integer) }
18
+ attr_reader :stack_depth
19
+
20
+ sig { params(stack_depth: Integer, max_stack_depth: Integer).void }
21
+ def initialize(stack_depth, max_stack_depth)
22
+ @max_stack_depth = max_stack_depth
23
+ @stack_depth = stack_depth
24
+
25
+ super
26
+ end
27
+ end
28
+
29
+ sig { params(body: Rack::BodyProxy, stack_depth: Integer).returns(String) }
30
+ private_class_method def self.extract_body_from_rack_body_proxy(body, stack_depth = 1)
31
+ raise ResponseBodyTooDeepError.new(stack_depth, 5) unless stack_depth < 5
32
+
33
+ case (inner_body = body.instance_variable_get(:@body))
34
+ when Rack::BodyProxy then extract_body_from_rack_body_proxy(inner_body, stack_depth + 1)
35
+ when Array then inner_body[0] || "null"
36
+ else raise
37
+ end
38
+ end
39
+
13
40
  sig { params(rack_response: Rack::Response).returns(Types::Payload) }
14
41
  private_class_method def self.extract_payload(rack_response)
15
42
  case (body = rack_response.body)
@@ -18,12 +45,11 @@ module Vigiles
18
45
 
19
46
  { __false_body: :not_empty_handle_later }
20
47
  when Rack::BodyProxy
21
- body_proxy = body
22
- body_proxy = body_proxy.instance_variable_get(:@body) until body_proxy.is_a?(Array)
48
+ extracted_body = extract_body_from_rack_body_proxy(body)
23
49
  begin
24
- JSON.parse(body_proxy[0])
50
+ JSON.parse(extracted_body)
25
51
  rescue StandardError
26
- { __false_body: body_proxy[0] }
52
+ { __false_body: extracted_body }
27
53
  end
28
54
  else
29
55
  { __false_body: :unknown_response_payload_type }
@@ -15,7 +15,7 @@ module Vigiles
15
15
  super
16
16
  end
17
17
  end
18
-
18
+
19
19
  sig { params(req: ActionDispatch::Request, res: Rack::Response).returns(T.nilable(Conversation)) }
20
20
  def self.record_conversation(req:, res:)
21
21
  content_type = req.content_type
@@ -8,7 +8,7 @@ module Vigiles
8
8
  %w[
9
9
  application/json
10
10
  ]
11
- ), T::Set[String]
11
+ ).freeze, T::Set[String]
12
12
  )
13
13
 
14
14
  DEFAULT_CONTENT_TYPE_RECORDERS = T.let(
@@ -20,6 +20,9 @@ module Vigiles
20
20
 
21
21
  abstract!
22
22
 
23
+ sig { abstract.params(req: ActionDispatch::Request).void }
24
+ def ensure_content_type_matches!(req); end
25
+
23
26
  sig { abstract.params(req: ActionDispatch::Request, res: Rack::Response).returns(Archive::Conversation) }
24
27
  def record(req:, res:); end
25
28
  end
@@ -14,14 +14,19 @@ module Vigiles
14
14
  Request = Vigiles::Archive::Request
15
15
  Extras = Vigiles::Archive::Extras
16
16
 
17
+ sig { override.params(req: ActionDispatch::Request).void }
18
+ private def ensure_content_type_matches!(req)
19
+ return if req.content_type == ContentType::ApplicationJson.serialize
20
+
21
+ raise ConversationRecorder::MisconfiguredRecorderError.new(
22
+ expected: ContentType::ApplicationJson.serialize,
23
+ actual: req.content_type
24
+ )
25
+ end
26
+
17
27
  sig { override.params(req: ActionDispatch::Request, res: Rack::Response).returns(Archive::Conversation) }
18
28
  def record(req:, res:)
19
- unless req.content_type == ContentType::ApplicationJson.serialize
20
- raise ConversationRecorder::MisconfiguredRecorderError.new(
21
- expected: ContentType::ApplicationJson.serialize,
22
- actual: req.content_type
23
- )
24
- end
29
+ ensure_content_type_matches!(req)
25
30
 
26
31
  response = Response.from(res)
27
32
  request = Request.from(req)
@@ -6,6 +6,9 @@ module Vigiles
6
6
  class Unknown < ConversationRecorder
7
7
  include Singleton
8
8
 
9
+ sig { override.params(req: ActionDispatch::Request).void }
10
+ def ensure_content_type_matches!(req); end
11
+
9
12
  sig { override.params(req: ActionDispatch::Request, res: Rack::Response).returns(Archive::Conversation) }
10
13
  def record(req:, res:) = Archive::Conversation.new
11
14
  end
@@ -13,7 +13,7 @@ module Vigiles
13
13
  to: :options
14
14
 
15
15
  sig { params(app: T.untyped, options: Vigiles::Options).void }
16
- def initialize(app, options=Vigiles::Options.make_default_options)
16
+ def initialize(app, options = Vigiles::Options.make_default_options)
17
17
  @app = app
18
18
  @options = options
19
19
  end
@@ -36,7 +36,7 @@ module Vigiles
36
36
  "[vigiles] conversation recorder: " \
37
37
  "conversation=#{convo.nil? ? "not_recorded" : convo.id} " \
38
38
  "request=#{req.request_id}"
39
- rescue => e
39
+ rescue StandardError => e
40
40
  capture_exception.call(e)
41
41
  logger.warn \
42
42
  "[vigiles] conversation recorder error: " \
@@ -3,14 +3,12 @@
3
3
 
4
4
  require "json"
5
5
 
6
- module Vigies
6
+ module Vigiles
7
7
  module Utilities
8
8
  module JSON
9
9
  extend T::Sig
10
10
 
11
- UntypedHash = Vigiles::Types::UntypedHash
12
-
13
- sig { params(text: String).returns(T.any(String, UntypedHash)) }
11
+ sig { params(text: String).returns(T.any(String, Vigiles::Types::UntypedHash)) }
14
12
  def self.parse_benignly(text)
15
13
  ::JSON.parse(text)
16
14
  rescue StandardError
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Vigiles
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.4"
6
6
  end