context.dev 1.32.0 → 1.35.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +1 -1
- data/lib/context_dev/internal/transport/base_client.rb +4 -1
- data/lib/context_dev/models/web_screenshot_params.rb +14 -1
- data/lib/context_dev/models/web_web_crawl_md_response.rb +238 -5
- data/lib/context_dev/models/web_web_scrape_html_response.rb +258 -1
- data/lib/context_dev/models/web_web_scrape_md_response.rb +256 -1
- data/lib/context_dev/resources/web.rb +4 -1
- data/lib/context_dev/version.rb +1 -1
- data/rbi/context_dev/models/web_screenshot_params.rbi +21 -0
- data/rbi/context_dev/models/web_web_crawl_md_response.rbi +426 -7
- data/rbi/context_dev/models/web_web_scrape_html_response.rbi +485 -0
- data/rbi/context_dev/models/web_web_scrape_md_response.rbi +474 -0
- data/rbi/context_dev/resources/web.rbi +8 -0
- data/sig/context_dev/models/web_screenshot_params.rbs +7 -0
- data/sig/context_dev/models/web_web_crawl_md_response.rbs +198 -3
- data/sig/context_dev/models/web_web_scrape_html_response.rbs +232 -1
- data/sig/context_dev/models/web_web_scrape_md_response.rbs +219 -0
- data/sig/context_dev/resources/web.rbs +1 -0
- metadata +2 -2
|
@@ -10,6 +10,12 @@ module ContextDev
|
|
|
10
10
|
# @return [String]
|
|
11
11
|
required :markdown, String
|
|
12
12
|
|
|
13
|
+
# @!attribute metadata
|
|
14
|
+
# Metadata extracted from the scraped page HTML.
|
|
15
|
+
#
|
|
16
|
+
# @return [ContextDev::Models::WebWebScrapeMdResponse::Metadata]
|
|
17
|
+
required :metadata, -> { ContextDev::Models::WebWebScrapeMdResponse::Metadata }
|
|
18
|
+
|
|
13
19
|
# @!attribute success
|
|
14
20
|
# Indicates success
|
|
15
21
|
#
|
|
@@ -29,18 +35,267 @@ module ContextDev
|
|
|
29
35
|
# @return [ContextDev::Models::WebWebScrapeMdResponse::KeyMetadata, nil]
|
|
30
36
|
optional :key_metadata, -> { ContextDev::Models::WebWebScrapeMdResponse::KeyMetadata }
|
|
31
37
|
|
|
32
|
-
# @!method initialize(markdown:, success:, url:, key_metadata: nil)
|
|
38
|
+
# @!method initialize(markdown:, metadata:, success:, url:, key_metadata: nil)
|
|
33
39
|
# Some parameter documentations has been truncated, see
|
|
34
40
|
# {ContextDev::Models::WebWebScrapeMdResponse} for more details.
|
|
35
41
|
#
|
|
36
42
|
# @param markdown [String] Page content converted to GitHub Flavored Markdown
|
|
37
43
|
#
|
|
44
|
+
# @param metadata [ContextDev::Models::WebWebScrapeMdResponse::Metadata] Metadata extracted from the scraped page HTML.
|
|
45
|
+
#
|
|
38
46
|
# @param success [Boolean, ContextDev::Models::WebWebScrapeMdResponse::Success] Indicates success
|
|
39
47
|
#
|
|
40
48
|
# @param url [String] The URL that was scraped
|
|
41
49
|
#
|
|
42
50
|
# @param key_metadata [ContextDev::Models::WebWebScrapeMdResponse::KeyMetadata] Metadata about the API key used for the request. Included in every response when
|
|
43
51
|
|
|
52
|
+
# @see ContextDev::Models::WebWebScrapeMdResponse#metadata
|
|
53
|
+
class Metadata < ContextDev::Internal::Type::BaseModel
|
|
54
|
+
# @!attribute final_url
|
|
55
|
+
# Final URL scraped after redirects or scraper fallback, when known. Falls back to
|
|
56
|
+
# sourceUrl when unavailable.
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
required :final_url, String, api_name: :finalUrl
|
|
60
|
+
|
|
61
|
+
# @!attribute source_url
|
|
62
|
+
# Original URL requested by the caller.
|
|
63
|
+
#
|
|
64
|
+
# @return [String]
|
|
65
|
+
required :source_url, String, api_name: :sourceUrl
|
|
66
|
+
|
|
67
|
+
# @!attribute additional_meta
|
|
68
|
+
# Additional non-social meta tags not promoted to top-level metadata fields.
|
|
69
|
+
#
|
|
70
|
+
# @return [Hash{Symbol=>String, Array<String>}, nil]
|
|
71
|
+
optional :additional_meta,
|
|
72
|
+
-> { ContextDev::Internal::Type::HashOf[union: ContextDev::Models::WebWebScrapeMdResponse::Metadata::AdditionalMeta] },
|
|
73
|
+
api_name: :additionalMeta
|
|
74
|
+
|
|
75
|
+
# @!attribute alternates
|
|
76
|
+
# Resolved alternate links from link rel=alternate tags.
|
|
77
|
+
#
|
|
78
|
+
# @return [Array<ContextDev::Models::WebWebScrapeMdResponse::Metadata::Alternate>, nil]
|
|
79
|
+
optional :alternates,
|
|
80
|
+
-> { ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebWebScrapeMdResponse::Metadata::Alternate] }
|
|
81
|
+
|
|
82
|
+
# @!attribute author
|
|
83
|
+
# Author metadata, when present.
|
|
84
|
+
#
|
|
85
|
+
# @return [String, nil]
|
|
86
|
+
optional :author, String
|
|
87
|
+
|
|
88
|
+
# @!attribute canonical_url
|
|
89
|
+
# Resolved canonical URL, when present.
|
|
90
|
+
#
|
|
91
|
+
# @return [String, nil]
|
|
92
|
+
optional :canonical_url, String, api_name: :canonicalUrl
|
|
93
|
+
|
|
94
|
+
# @!attribute description
|
|
95
|
+
# Best description extracted from standard, Open Graph, or Twitter metadata.
|
|
96
|
+
#
|
|
97
|
+
# @return [String, nil]
|
|
98
|
+
optional :description, String
|
|
99
|
+
|
|
100
|
+
# @!attribute favicon
|
|
101
|
+
# Resolved favicon URL, when present.
|
|
102
|
+
#
|
|
103
|
+
# @return [String, nil]
|
|
104
|
+
optional :favicon, String
|
|
105
|
+
|
|
106
|
+
# @!attribute image
|
|
107
|
+
# Primary resolved preview image from Open Graph, Twitter, or image metadata.
|
|
108
|
+
#
|
|
109
|
+
# @return [String, nil]
|
|
110
|
+
optional :image, String
|
|
111
|
+
|
|
112
|
+
# @!attribute json_ld
|
|
113
|
+
# JSON-LD structured data blocks parsed from the page.
|
|
114
|
+
#
|
|
115
|
+
# @return [Array<Hash{Symbol=>Object}>, nil]
|
|
116
|
+
optional :json_ld,
|
|
117
|
+
ContextDev::Internal::Type::ArrayOf[ContextDev::Internal::Type::HashOf[ContextDev::Internal::Type::Unknown]],
|
|
118
|
+
api_name: :jsonLd
|
|
119
|
+
|
|
120
|
+
# @!attribute keywords
|
|
121
|
+
# Keywords extracted from the page's keywords meta tag.
|
|
122
|
+
#
|
|
123
|
+
# @return [Array<String>, nil]
|
|
124
|
+
optional :keywords, ContextDev::Internal::Type::ArrayOf[String]
|
|
125
|
+
|
|
126
|
+
# @!attribute language
|
|
127
|
+
# Language extracted from html lang or language meta tags.
|
|
128
|
+
#
|
|
129
|
+
# @return [String, nil]
|
|
130
|
+
optional :language, String
|
|
131
|
+
|
|
132
|
+
# @!attribute modified_time
|
|
133
|
+
# Modified timestamp/date from page metadata, when present.
|
|
134
|
+
#
|
|
135
|
+
# @return [String, nil]
|
|
136
|
+
optional :modified_time, String, api_name: :modifiedTime
|
|
137
|
+
|
|
138
|
+
# @!attribute open_graph
|
|
139
|
+
# Open Graph metadata with the og: prefix removed and keys camel-cased.
|
|
140
|
+
#
|
|
141
|
+
# @return [Hash{Symbol=>String, Array<String>}, nil]
|
|
142
|
+
optional :open_graph,
|
|
143
|
+
-> { ContextDev::Internal::Type::HashOf[union: ContextDev::Models::WebWebScrapeMdResponse::Metadata::OpenGraph] },
|
|
144
|
+
api_name: :openGraph
|
|
145
|
+
|
|
146
|
+
# @!attribute published_time
|
|
147
|
+
# Published timestamp/date from page metadata, when present.
|
|
148
|
+
#
|
|
149
|
+
# @return [String, nil]
|
|
150
|
+
optional :published_time, String, api_name: :publishedTime
|
|
151
|
+
|
|
152
|
+
# @!attribute robots
|
|
153
|
+
# Robots meta directive, when present.
|
|
154
|
+
#
|
|
155
|
+
# @return [String, nil]
|
|
156
|
+
optional :robots, String
|
|
157
|
+
|
|
158
|
+
# @!attribute site_name
|
|
159
|
+
# Site or application name from page metadata.
|
|
160
|
+
#
|
|
161
|
+
# @return [String, nil]
|
|
162
|
+
optional :site_name, String, api_name: :siteName
|
|
163
|
+
|
|
164
|
+
# @!attribute title
|
|
165
|
+
# Best title extracted from the page.
|
|
166
|
+
#
|
|
167
|
+
# @return [String, nil]
|
|
168
|
+
optional :title, String
|
|
169
|
+
|
|
170
|
+
# @!attribute twitter
|
|
171
|
+
# Twitter card metadata with the twitter: prefix removed and keys camel-cased.
|
|
172
|
+
#
|
|
173
|
+
# @return [Hash{Symbol=>String, Array<String>}, nil]
|
|
174
|
+
optional :twitter,
|
|
175
|
+
-> { ContextDev::Internal::Type::HashOf[union: ContextDev::Models::WebWebScrapeMdResponse::Metadata::Twitter] }
|
|
176
|
+
|
|
177
|
+
# @!method initialize(final_url:, source_url:, additional_meta: nil, alternates: nil, author: nil, canonical_url: nil, description: nil, favicon: nil, image: nil, json_ld: nil, keywords: nil, language: nil, modified_time: nil, open_graph: nil, published_time: nil, robots: nil, site_name: nil, title: nil, twitter: nil)
|
|
178
|
+
# Some parameter documentations has been truncated, see
|
|
179
|
+
# {ContextDev::Models::WebWebScrapeMdResponse::Metadata} for more details.
|
|
180
|
+
#
|
|
181
|
+
# Metadata extracted from the scraped page HTML.
|
|
182
|
+
#
|
|
183
|
+
# @param final_url [String] Final URL scraped after redirects or scraper fallback, when known. Falls back to
|
|
184
|
+
#
|
|
185
|
+
# @param source_url [String] Original URL requested by the caller.
|
|
186
|
+
#
|
|
187
|
+
# @param additional_meta [Hash{Symbol=>String, Array<String>}] Additional non-social meta tags not promoted to top-level metadata fields.
|
|
188
|
+
#
|
|
189
|
+
# @param alternates [Array<ContextDev::Models::WebWebScrapeMdResponse::Metadata::Alternate>] Resolved alternate links from link rel=alternate tags.
|
|
190
|
+
#
|
|
191
|
+
# @param author [String] Author metadata, when present.
|
|
192
|
+
#
|
|
193
|
+
# @param canonical_url [String] Resolved canonical URL, when present.
|
|
194
|
+
#
|
|
195
|
+
# @param description [String] Best description extracted from standard, Open Graph, or Twitter metadata.
|
|
196
|
+
#
|
|
197
|
+
# @param favicon [String] Resolved favicon URL, when present.
|
|
198
|
+
#
|
|
199
|
+
# @param image [String] Primary resolved preview image from Open Graph, Twitter, or image metadata.
|
|
200
|
+
#
|
|
201
|
+
# @param json_ld [Array<Hash{Symbol=>Object}>] JSON-LD structured data blocks parsed from the page.
|
|
202
|
+
#
|
|
203
|
+
# @param keywords [Array<String>] Keywords extracted from the page's keywords meta tag.
|
|
204
|
+
#
|
|
205
|
+
# @param language [String] Language extracted from html lang or language meta tags.
|
|
206
|
+
#
|
|
207
|
+
# @param modified_time [String] Modified timestamp/date from page metadata, when present.
|
|
208
|
+
#
|
|
209
|
+
# @param open_graph [Hash{Symbol=>String, Array<String>}] Open Graph metadata with the og: prefix removed and keys camel-cased.
|
|
210
|
+
#
|
|
211
|
+
# @param published_time [String] Published timestamp/date from page metadata, when present.
|
|
212
|
+
#
|
|
213
|
+
# @param robots [String] Robots meta directive, when present.
|
|
214
|
+
#
|
|
215
|
+
# @param site_name [String] Site or application name from page metadata.
|
|
216
|
+
#
|
|
217
|
+
# @param title [String] Best title extracted from the page.
|
|
218
|
+
#
|
|
219
|
+
# @param twitter [Hash{Symbol=>String, Array<String>}] Twitter card metadata with the twitter: prefix removed and keys camel-cased.
|
|
220
|
+
|
|
221
|
+
module AdditionalMeta
|
|
222
|
+
extend ContextDev::Internal::Type::Union
|
|
223
|
+
|
|
224
|
+
variant String
|
|
225
|
+
|
|
226
|
+
variant -> { ContextDev::Models::WebWebScrapeMdResponse::Metadata::AdditionalMeta::StringArray }
|
|
227
|
+
|
|
228
|
+
# @!method self.variants
|
|
229
|
+
# @return [Array(String, Array<String>)]
|
|
230
|
+
|
|
231
|
+
# @type [ContextDev::Internal::Type::Converter]
|
|
232
|
+
StringArray = ContextDev::Internal::Type::ArrayOf[String]
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
class Alternate < ContextDev::Internal::Type::BaseModel
|
|
236
|
+
# @!attribute href
|
|
237
|
+
# Resolved alternate URL.
|
|
238
|
+
#
|
|
239
|
+
# @return [String]
|
|
240
|
+
required :href, String
|
|
241
|
+
|
|
242
|
+
# @!attribute hreflang
|
|
243
|
+
# Language or locale for the alternate URL, when present.
|
|
244
|
+
#
|
|
245
|
+
# @return [String, nil]
|
|
246
|
+
optional :hreflang, String
|
|
247
|
+
|
|
248
|
+
# @!attribute title
|
|
249
|
+
# Alternate resource title, when present.
|
|
250
|
+
#
|
|
251
|
+
# @return [String, nil]
|
|
252
|
+
optional :title, String
|
|
253
|
+
|
|
254
|
+
# @!attribute type
|
|
255
|
+
# Alternate resource MIME type, when present.
|
|
256
|
+
#
|
|
257
|
+
# @return [String, nil]
|
|
258
|
+
optional :type, String
|
|
259
|
+
|
|
260
|
+
# @!method initialize(href:, hreflang: nil, title: nil, type: nil)
|
|
261
|
+
# @param href [String] Resolved alternate URL.
|
|
262
|
+
#
|
|
263
|
+
# @param hreflang [String] Language or locale for the alternate URL, when present.
|
|
264
|
+
#
|
|
265
|
+
# @param title [String] Alternate resource title, when present.
|
|
266
|
+
#
|
|
267
|
+
# @param type [String] Alternate resource MIME type, when present.
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
module OpenGraph
|
|
271
|
+
extend ContextDev::Internal::Type::Union
|
|
272
|
+
|
|
273
|
+
variant String
|
|
274
|
+
|
|
275
|
+
variant -> { ContextDev::Models::WebWebScrapeMdResponse::Metadata::OpenGraph::StringArray }
|
|
276
|
+
|
|
277
|
+
# @!method self.variants
|
|
278
|
+
# @return [Array(String, Array<String>)]
|
|
279
|
+
|
|
280
|
+
# @type [ContextDev::Internal::Type::Converter]
|
|
281
|
+
StringArray = ContextDev::Internal::Type::ArrayOf[String]
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
module Twitter
|
|
285
|
+
extend ContextDev::Internal::Type::Union
|
|
286
|
+
|
|
287
|
+
variant String
|
|
288
|
+
|
|
289
|
+
variant -> { ContextDev::Models::WebWebScrapeMdResponse::Metadata::Twitter::StringArray }
|
|
290
|
+
|
|
291
|
+
# @!method self.variants
|
|
292
|
+
# @return [Array(String, Array<String>)]
|
|
293
|
+
|
|
294
|
+
# @type [ContextDev::Internal::Type::Converter]
|
|
295
|
+
StringArray = ContextDev::Internal::Type::ArrayOf[String]
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
44
299
|
# Indicates success
|
|
45
300
|
#
|
|
46
301
|
# @see ContextDev::Models::WebWebScrapeMdResponse#success
|
|
@@ -163,7 +163,7 @@ module ContextDev
|
|
|
163
163
|
#
|
|
164
164
|
# Capture a screenshot of a website.
|
|
165
165
|
#
|
|
166
|
-
# @overload screenshot(direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: nil, timeout_ms: nil, viewport: nil, wait_for_ms: nil, request_options: {})
|
|
166
|
+
# @overload screenshot(direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: nil, scroll_offset: nil, timeout_ms: nil, viewport: nil, wait_for_ms: nil, request_options: {})
|
|
167
167
|
#
|
|
168
168
|
# @param direct_url [String] A specific URL to screenshot directly, bypassing domain resolution (e.g., 'https
|
|
169
169
|
#
|
|
@@ -177,6 +177,8 @@ module ContextDev
|
|
|
177
177
|
#
|
|
178
178
|
# @param page [Symbol, ContextDev::Models::WebScreenshotParams::Page] Optional parameter to specify which page type to screenshot. If provided, the sy
|
|
179
179
|
#
|
|
180
|
+
# @param scroll_offset [Integer] Optional vertical scroll offset in pixels for capturing a long page in viewport-
|
|
181
|
+
#
|
|
180
182
|
# @param timeout_ms [Integer] Optional timeout in milliseconds for the request. If the request takes longer th
|
|
181
183
|
#
|
|
182
184
|
# @param viewport [ContextDev::Models::WebScreenshotParams::Viewport] Optional browser viewport dimensions for the screenshot. Defaults to 1920x1080.
|
|
@@ -199,6 +201,7 @@ module ContextDev
|
|
|
199
201
|
full_screenshot: "fullScreenshot",
|
|
200
202
|
handle_cookie_popup: "handleCookiePopup",
|
|
201
203
|
max_age_ms: "maxAgeMs",
|
|
204
|
+
scroll_offset: "scrollOffset",
|
|
202
205
|
timeout_ms: "timeoutMS",
|
|
203
206
|
wait_for_ms: "waitForMs"
|
|
204
207
|
),
|
data/lib/context_dev/version.rb
CHANGED
|
@@ -89,6 +89,18 @@ module ContextDev
|
|
|
89
89
|
sig { params(page: ContextDev::WebScreenshotParams::Page::OrSymbol).void }
|
|
90
90
|
attr_writer :page
|
|
91
91
|
|
|
92
|
+
# Optional vertical scroll offset in pixels for capturing a long page in
|
|
93
|
+
# viewport-sized chunks. When provided, the full page is captured once and the
|
|
94
|
+
# returned image is the viewport-sized slice that begins at this Y offset (e.g.
|
|
95
|
+
# request scrollOffset=0, then 1080, then 2160 to walk a 1920x1080 landing page
|
|
96
|
+
# top to bottom). The final slice may be shorter than the viewport height. Takes
|
|
97
|
+
# precedence over fullScreenshot. Max: 100000.
|
|
98
|
+
sig { returns(T.nilable(Integer)) }
|
|
99
|
+
attr_reader :scroll_offset
|
|
100
|
+
|
|
101
|
+
sig { params(scroll_offset: Integer).void }
|
|
102
|
+
attr_writer :scroll_offset
|
|
103
|
+
|
|
92
104
|
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
93
105
|
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
94
106
|
# value is 300000ms (5 minutes).
|
|
@@ -126,6 +138,7 @@ module ContextDev
|
|
|
126
138
|
ContextDev::WebScreenshotParams::HandleCookiePopup::OrSymbol,
|
|
127
139
|
max_age_ms: Integer,
|
|
128
140
|
page: ContextDev::WebScreenshotParams::Page::OrSymbol,
|
|
141
|
+
scroll_offset: Integer,
|
|
129
142
|
timeout_ms: Integer,
|
|
130
143
|
viewport: ContextDev::WebScreenshotParams::Viewport::OrHash,
|
|
131
144
|
wait_for_ms: Integer,
|
|
@@ -159,6 +172,13 @@ module ContextDev
|
|
|
159
172
|
# provided, screenshots the main domain landing page. Only applicable when using
|
|
160
173
|
# 'domain', not 'directUrl'.
|
|
161
174
|
page: nil,
|
|
175
|
+
# Optional vertical scroll offset in pixels for capturing a long page in
|
|
176
|
+
# viewport-sized chunks. When provided, the full page is captured once and the
|
|
177
|
+
# returned image is the viewport-sized slice that begins at this Y offset (e.g.
|
|
178
|
+
# request scrollOffset=0, then 1080, then 2160 to walk a 1920x1080 landing page
|
|
179
|
+
# top to bottom). The final slice may be shorter than the viewport height. Takes
|
|
180
|
+
# precedence over fullScreenshot. Max: 100000.
|
|
181
|
+
scroll_offset: nil,
|
|
162
182
|
# Optional timeout in milliseconds for the request. If the request takes longer
|
|
163
183
|
# than this value, it will be aborted with a 408 status code. Maximum allowed
|
|
164
184
|
# value is 300000ms (5 minutes).
|
|
@@ -184,6 +204,7 @@ module ContextDev
|
|
|
184
204
|
ContextDev::WebScreenshotParams::HandleCookiePopup::OrSymbol,
|
|
185
205
|
max_age_ms: Integer,
|
|
186
206
|
page: ContextDev::WebScreenshotParams::Page::OrSymbol,
|
|
207
|
+
scroll_offset: Integer,
|
|
187
208
|
timeout_ms: Integer,
|
|
188
209
|
viewport: ContextDev::WebScreenshotParams::Viewport,
|
|
189
210
|
wait_for_ms: Integer,
|