context.dev 2.19.0 → 2.21.0

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +219 -0
  3. data/README.md +1 -1
  4. data/lib/context_dev/client.rb +6 -0
  5. data/lib/context_dev/models/feedback_submit_params.rb +73 -0
  6. data/lib/context_dev/models/feedback_submit_response.rb +68 -0
  7. data/lib/context_dev/models/news_search_params.rb +13 -6
  8. data/lib/context_dev/models/web_scrape_params.rb +149 -14
  9. data/lib/context_dev/models/web_scrape_response.rb +404 -12
  10. data/lib/context_dev/models.rb +2 -0
  11. data/lib/context_dev/resources/feedback.rb +50 -0
  12. data/lib/context_dev/resources/news.rb +8 -4
  13. data/lib/context_dev/resources/web.rb +26 -8
  14. data/lib/context_dev/version.rb +1 -1
  15. data/lib/context_dev.rb +3 -0
  16. data/rbi/context_dev/client.rbi +5 -0
  17. data/rbi/context_dev/models/feedback_submit_params.rbi +133 -0
  18. data/rbi/context_dev/models/feedback_submit_response.rbi +122 -0
  19. data/rbi/context_dev/models/news_search_params.rbi +12 -6
  20. data/rbi/context_dev/models/web_scrape_params.rbi +248 -18
  21. data/rbi/context_dev/models/web_scrape_response.rbi +702 -30
  22. data/rbi/context_dev/models.rbi +2 -0
  23. data/rbi/context_dev/resources/feedback.rbi +42 -0
  24. data/rbi/context_dev/resources/news.rbi +7 -4
  25. data/rbi/context_dev/resources/web.rbi +38 -12
  26. data/sig/context_dev/client.rbs +2 -0
  27. data/sig/context_dev/models/feedback_submit_params.rbs +73 -0
  28. data/sig/context_dev/models/feedback_submit_response.rbs +58 -0
  29. data/sig/context_dev/models/web_scrape_params.rbs +91 -0
  30. data/sig/context_dev/models/web_scrape_response.rbs +302 -18
  31. data/sig/context_dev/models.rbs +2 -0
  32. data/sig/context_dev/resources/feedback.rbs +16 -0
  33. data/sig/context_dev/resources/web.rbs +3 -0
  34. metadata +11 -2
@@ -183,27 +183,45 @@ module ContextDev
183
183
  #
184
184
  # Reuse cached outputs independently and capture missing formats in one page
185
185
  # visit. Each cache key includes only the settings that affect that output. HTML
186
- # is shared with Markdown and parsed fields. Cached outputs can come from
187
- # different visits within maxAgeMs; use 0 for a fresh capture. HTML-only requests
188
- # use the existing fast acquisition path. One credit per request, including cache
189
- # hits, or two with browser actions; PDF OCR adds one credit per recovered page on
190
- # fresh extraction. Original response bytes and screenshots are limited to 20 MiB
191
- # each, screenshots to 40 megapixels, and the combined browser capture to 60 MiB.
192
- #
193
- # @overload scrape(formats:, url:, image_params: nil, markdown_params: nil, max_age_ms: nil, parse_params: nil, screenshot_params: nil, shared_params: nil, tags: nil, timeout_opts: nil, zdr: nil, request_options: {})
186
+ # is shared with Markdown, parsed fields, product data, highlights, and JSON
187
+ # extraction. Cached outputs can come from different visits within maxAgeMs; use 0
188
+ # for a fresh capture. HTML-only requests use the existing fast acquisition path.
189
+ # Highlights return Markdown excerpts most relevant to highlightsParams.query.
190
+ # Requests with at least one successful output cost one base credit, including
191
+ # cache hits, or two with browser actions. All-failed responses are unbilled
192
+ # except missing pages, which retain the base price and the one-credit product
193
+ # charge when product was requested. Highlights add 3 credits when passages are
194
+ # returned. JSON extraction runs an LLM over nonempty page Markdown and adds four
195
+ # credits only when its result is returned successfully. PDF OCR adds one credit
196
+ # per recovered page on fresh extraction. Product adds one credit when its
197
+ # successful result is returned, plus six if that result used the specialized
198
+ # model. Original response bytes and screenshots are limited to 20 MiB each,
199
+ # screenshots to 40 megapixels, and the combined response to 60 MiB. An oversized
200
+ # output has success: false and data: null. If the combined response exceeds its
201
+ # limit, the largest outputs are marked failed until the remaining outputs fit.
202
+ # Valid captured pieces may still be cached when omitted to meet the response size
203
+ # limit.
204
+ #
205
+ # @overload scrape(formats:, url:, highlights_params: nil, image_params: nil, json_params: nil, markdown_params: nil, max_age_ms: nil, parse_params: nil, product_params: nil, screenshot_params: nil, shared_params: nil, tags: nil, timeout_opts: nil, zdr: nil, request_options: {})
194
206
  #
195
207
  # @param formats [ContextDev::Models::WebScrapeParams::Formats] Outputs to return. Enable at least one; omitted formats are false.
196
208
  #
197
209
  # @param url [String] The URL to scrape.
198
210
  #
211
+ # @param highlights_params [ContextDev::Models::WebScrapeParams::HighlightsParams] Highlight options. Requires formats.highlights: true.
212
+ #
199
213
  # @param image_params [ContextDev::Models::WebScrapeParams::ImageParams] Image options. Requires formats.images: true.
200
214
  #
215
+ # @param json_params [ContextDev::Models::WebScrapeParams::JsonParams] Required when formats.json is true.
216
+ #
201
217
  # @param markdown_params [ContextDev::Models::WebScrapeParams::MarkdownParams] Markdown options. Requires formats.markdown: true.
202
218
  #
203
219
  # @param max_age_ms [Integer] Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and update
204
220
  #
205
221
  # @param parse_params [ContextDev::Models::WebScrapeParams::ParseParams] Required when formats.parse is true.
206
222
  #
223
+ # @param product_params [ContextDev::Models::WebScrapeParams::ProductParams] Product options. Requires formats.product: true.
224
+ #
207
225
  # @param screenshot_params [ContextDev::Models::WebScrapeParams::ScreenshotParams] Screenshot options. Requires formats.screenshot: true.
208
226
  #
209
227
  # @param shared_params [ContextDev::Models::WebScrapeParams::SharedParams] Shared browser and content settings. Content filters leave screenshots and origi
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextDev
4
- VERSION = "2.19.0"
4
+ VERSION = "2.21.0"
5
5
  end
data/lib/context_dev.rb CHANGED
@@ -71,6 +71,8 @@ require_relative "context_dev/models/brand_search_params"
71
71
  require_relative "context_dev/models/brand_search_response"
72
72
  require_relative "context_dev/models/crawl_controls"
73
73
  require_relative "context_dev/models/failure"
74
+ require_relative "context_dev/models/feedback_submit_params"
75
+ require_relative "context_dev/models/feedback_submit_response"
74
76
  require_relative "context_dev/models/industry_retrieve_naics_params"
75
77
  require_relative "context_dev/models/industry_retrieve_naics_response"
76
78
  require_relative "context_dev/models/industry_retrieve_sic_params"
@@ -150,6 +152,7 @@ require_relative "context_dev/models/web_web_crawl_md_response"
150
152
  require_relative "context_dev/models"
151
153
  require_relative "context_dev/resources/batch"
152
154
  require_relative "context_dev/resources/brand"
155
+ require_relative "context_dev/resources/feedback"
153
156
  require_relative "context_dev/resources/industry"
154
157
  require_relative "context_dev/resources/logs"
155
158
  require_relative "context_dev/resources/monitors"
@@ -54,6 +54,11 @@ module ContextDev
54
54
  sig { returns(ContextDev::Resources::Logs) }
55
55
  attr_reader :logs
56
56
 
57
+ # Report bugs, docs mismatches, and friction with any Context.dev API. Submissions
58
+ # cost no credits and use a separate rate limit.
59
+ sig { returns(ContextDev::Resources::Feedback) }
60
+ attr_reader :feedback
61
+
57
62
  # @api private
58
63
  sig { override.returns(T::Hash[String, String]) }
59
64
  private def auth_headers
@@ -0,0 +1,133 @@
1
+ # typed: strong
2
+
3
+ module ContextDev
4
+ module Models
5
+ class FeedbackSubmitParams < ContextDev::Internal::Type::BaseModel
6
+ extend ContextDev::Internal::Type::RequestParameters::Converter
7
+ include ContextDev::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias do
11
+ T.any(ContextDev::FeedbackSubmitParams, ContextDev::Internal::AnyHash)
12
+ end
13
+
14
+ # Kind of issue.
15
+ sig { returns(ContextDev::FeedbackSubmitParams::Category::OrSymbol) }
16
+ attr_accessor :category
17
+
18
+ # What went wrong and what you expected instead.
19
+ sig { returns(String) }
20
+ attr_accessor :note
21
+
22
+ # The request_id of the API call the feedback is about, from its response body or
23
+ # X-Request-Id header.
24
+ sig { returns(T.nilable(String)) }
25
+ attr_reader :request_id
26
+
27
+ sig { params(request_id: String).void }
28
+ attr_writer :request_id
29
+
30
+ # Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
31
+ sig { returns(T.nilable(T::Array[String])) }
32
+ attr_reader :tags
33
+
34
+ sig { params(tags: T::Array[String]).void }
35
+ attr_writer :tags
36
+
37
+ # The page the feedback is about, such as one page of a crawl or a docs page.
38
+ sig { returns(T.nilable(String)) }
39
+ attr_reader :url
40
+
41
+ sig { params(url: String).void }
42
+ attr_writer :url
43
+
44
+ sig do
45
+ params(
46
+ category: ContextDev::FeedbackSubmitParams::Category::OrSymbol,
47
+ note: String,
48
+ request_id: String,
49
+ tags: T::Array[String],
50
+ url: String,
51
+ request_options: ContextDev::RequestOptions::OrHash
52
+ ).returns(T.attached_class)
53
+ end
54
+ def self.new(
55
+ # Kind of issue.
56
+ category:,
57
+ # What went wrong and what you expected instead.
58
+ note:,
59
+ # The request_id of the API call the feedback is about, from its response body or
60
+ # X-Request-Id header.
61
+ request_id: nil,
62
+ # Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
63
+ tags: nil,
64
+ # The page the feedback is about, such as one page of a crawl or a docs page.
65
+ url: nil,
66
+ request_options: {}
67
+ )
68
+ end
69
+
70
+ sig do
71
+ override.returns(
72
+ {
73
+ category: ContextDev::FeedbackSubmitParams::Category::OrSymbol,
74
+ note: String,
75
+ request_id: String,
76
+ tags: T::Array[String],
77
+ url: String,
78
+ request_options: ContextDev::RequestOptions
79
+ }
80
+ )
81
+ end
82
+ def to_hash
83
+ end
84
+
85
+ # Kind of issue.
86
+ module Category
87
+ extend ContextDev::Internal::Type::Enum
88
+
89
+ TaggedSymbol =
90
+ T.type_alias do
91
+ T.all(Symbol, ContextDev::FeedbackSubmitParams::Category)
92
+ end
93
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
94
+
95
+ BUG =
96
+ T.let(:bug, ContextDev::FeedbackSubmitParams::Category::TaggedSymbol)
97
+ DOCS_MISMATCH =
98
+ T.let(
99
+ :docs_mismatch,
100
+ ContextDev::FeedbackSubmitParams::Category::TaggedSymbol
101
+ )
102
+ FRICTION =
103
+ T.let(
104
+ :friction,
105
+ ContextDev::FeedbackSubmitParams::Category::TaggedSymbol
106
+ )
107
+ FEATURE_GAP =
108
+ T.let(
109
+ :feature_gap,
110
+ ContextDev::FeedbackSubmitParams::Category::TaggedSymbol
111
+ )
112
+ QUALITY_DEGRADATION =
113
+ T.let(
114
+ :quality_degradation,
115
+ ContextDev::FeedbackSubmitParams::Category::TaggedSymbol
116
+ )
117
+ OTHER =
118
+ T.let(
119
+ :other,
120
+ ContextDev::FeedbackSubmitParams::Category::TaggedSymbol
121
+ )
122
+
123
+ sig do
124
+ override.returns(
125
+ T::Array[ContextDev::FeedbackSubmitParams::Category::TaggedSymbol]
126
+ )
127
+ end
128
+ def self.values
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,122 @@
1
+ # typed: strong
2
+
3
+ module ContextDev
4
+ module Models
5
+ class FeedbackSubmitResponse < ContextDev::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(
9
+ ContextDev::Models::FeedbackSubmitResponse,
10
+ ContextDev::Internal::AnyHash
11
+ )
12
+ end
13
+
14
+ # True when feedback for this request_id was already recorded; the original
15
+ # feedback_id is returned.
16
+ sig { returns(T::Boolean) }
17
+ attr_accessor :already_submitted
18
+
19
+ # ID of the stored feedback.
20
+ sig { returns(String) }
21
+ attr_accessor :feedback_id
22
+
23
+ # Unique id of this API call, also sent in the X-Request-Id response header. Quote
24
+ # it when contacting support about a failed request.
25
+ sig { returns(String) }
26
+ attr_accessor :request_id
27
+
28
+ # Credit usage, included whenever a valid API key is provided.
29
+ sig do
30
+ returns(
31
+ T.nilable(ContextDev::Models::FeedbackSubmitResponse::KeyMetadata)
32
+ )
33
+ end
34
+ attr_reader :key_metadata
35
+
36
+ sig do
37
+ params(
38
+ key_metadata:
39
+ ContextDev::Models::FeedbackSubmitResponse::KeyMetadata::OrHash
40
+ ).void
41
+ end
42
+ attr_writer :key_metadata
43
+
44
+ sig do
45
+ params(
46
+ already_submitted: T::Boolean,
47
+ feedback_id: String,
48
+ request_id: String,
49
+ key_metadata:
50
+ ContextDev::Models::FeedbackSubmitResponse::KeyMetadata::OrHash
51
+ ).returns(T.attached_class)
52
+ end
53
+ def self.new(
54
+ # True when feedback for this request_id was already recorded; the original
55
+ # feedback_id is returned.
56
+ already_submitted:,
57
+ # ID of the stored feedback.
58
+ feedback_id:,
59
+ # Unique id of this API call, also sent in the X-Request-Id response header. Quote
60
+ # it when contacting support about a failed request.
61
+ request_id:,
62
+ # Credit usage, included whenever a valid API key is provided.
63
+ key_metadata: nil
64
+ )
65
+ end
66
+
67
+ sig do
68
+ override.returns(
69
+ {
70
+ already_submitted: T::Boolean,
71
+ feedback_id: String,
72
+ request_id: String,
73
+ key_metadata:
74
+ ContextDev::Models::FeedbackSubmitResponse::KeyMetadata
75
+ }
76
+ )
77
+ end
78
+ def to_hash
79
+ end
80
+
81
+ class KeyMetadata < ContextDev::Internal::Type::BaseModel
82
+ OrHash =
83
+ T.type_alias do
84
+ T.any(
85
+ ContextDev::Models::FeedbackSubmitResponse::KeyMetadata,
86
+ ContextDev::Internal::AnyHash
87
+ )
88
+ end
89
+
90
+ # Credits used by this request.
91
+ sig { returns(Integer) }
92
+ attr_accessor :credits_consumed
93
+
94
+ # Credits remaining for your organization.
95
+ sig { returns(Integer) }
96
+ attr_accessor :credits_remaining
97
+
98
+ # Credit usage, included whenever a valid API key is provided.
99
+ sig do
100
+ params(credits_consumed: Integer, credits_remaining: Integer).returns(
101
+ T.attached_class
102
+ )
103
+ end
104
+ def self.new(
105
+ # Credits used by this request.
106
+ credits_consumed:,
107
+ # Credits remaining for your organization.
108
+ credits_remaining:
109
+ )
110
+ end
111
+
112
+ sig do
113
+ override.returns(
114
+ { credits_consumed: Integer, credits_remaining: Integer }
115
+ )
116
+ end
117
+ def to_hash
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -24,7 +24,9 @@ module ContextDev
24
24
  sig { returns(T.nilable(String)) }
25
25
  attr_accessor :cursor
26
26
 
27
- # Optional result filters.
27
+ # Optional result filters. Use at most one of sourceDomain, sourceCountry,
28
+ # articleLanguage, or articleType. A date range may accompany that category;
29
+ # date.from must not exceed date.to.
28
30
  sig { returns(T.nilable(ContextDev::NewsSearchParams::FilterBy)) }
29
31
  attr_reader :filter_by
30
32
 
@@ -70,7 +72,9 @@ module ContextDev
70
72
  search_by:,
71
73
  # Opaque next_cursor from the previous response, or null for the first page.
72
74
  cursor: nil,
73
- # Optional result filters.
75
+ # Optional result filters. Use at most one of sourceDomain, sourceCountry,
76
+ # articleLanguage, or articleType. A date range may accompany that category;
77
+ # date.from must not exceed date.to.
74
78
  filter_by: nil,
75
79
  # Maximum results to return. Defaults to 10.
76
80
  limit: nil,
@@ -812,7 +816,7 @@ module ContextDev
812
816
  end
813
817
  attr_writer :article_type
814
818
 
815
- # Published-at window in epoch milliseconds.
819
+ # Published-at window in epoch milliseconds. from must be before or equal to to.
816
820
  sig { returns(T.nilable(ContextDev::NewsSearchParams::FilterBy::Date)) }
817
821
  attr_reader :date
818
822
 
@@ -852,7 +856,9 @@ module ContextDev
852
856
  sig { params(source_domain: T::Array[String]).void }
853
857
  attr_writer :source_domain
854
858
 
855
- # Optional result filters.
859
+ # Optional result filters. Use at most one of sourceDomain, sourceCountry,
860
+ # articleLanguage, or articleType. A date range may accompany that category;
861
+ # date.from must not exceed date.to.
856
862
  sig do
857
863
  params(
858
864
  article_language:
@@ -876,7 +882,7 @@ module ContextDev
876
882
  article_language: nil,
877
883
  # Article types to include. Up to 3.
878
884
  article_type: nil,
879
- # Published-at window in epoch milliseconds.
885
+ # Published-at window in epoch milliseconds. from must be before or equal to to.
880
886
  date: nil,
881
887
  # Publisher countries to include, as lowercase ISO 3166-1 alpha-2 codes. Up to 3.
882
888
  source_country: nil,
@@ -1061,7 +1067,7 @@ module ContextDev
1061
1067
  sig { params(to: Integer).void }
1062
1068
  attr_writer :to
1063
1069
 
1064
- # Published-at window in epoch milliseconds.
1070
+ # Published-at window in epoch milliseconds. from must be before or equal to to.
1065
1071
  sig { params(from: Integer, to: Integer).returns(T.attached_class) }
1066
1072
  def self.new(
1067
1073
  # Inclusive start of the published-at window, in epoch milliseconds.