context.dev 1.2.0 → 1.4.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +1 -1
  4. data/lib/context_dev/internal/util.rb +3 -1
  5. data/lib/context_dev/models/brand_identify_from_transaction_params.rb +65 -0
  6. data/lib/context_dev/models/brand_identify_from_transaction_response.rb +190 -5
  7. data/lib/context_dev/models/brand_retrieve_by_email_params.rb +65 -0
  8. data/lib/context_dev/models/brand_retrieve_by_email_response.rb +190 -5
  9. data/lib/context_dev/models/brand_retrieve_by_isin_params.rb +65 -0
  10. data/lib/context_dev/models/brand_retrieve_by_isin_response.rb +190 -5
  11. data/lib/context_dev/models/brand_retrieve_by_name_params.rb +65 -0
  12. data/lib/context_dev/models/brand_retrieve_by_name_response.rb +190 -5
  13. data/lib/context_dev/models/brand_retrieve_by_ticker_params.rb +65 -0
  14. data/lib/context_dev/models/brand_retrieve_by_ticker_response.rb +190 -5
  15. data/lib/context_dev/models/brand_retrieve_params.rb +68 -5
  16. data/lib/context_dev/models/brand_retrieve_response.rb +190 -5
  17. data/lib/context_dev/models/web_screenshot_params.rb +17 -5
  18. data/lib/context_dev/models/web_web_crawl_md_params.rb +92 -0
  19. data/lib/context_dev/models/web_web_crawl_md_response.rb +121 -0
  20. data/lib/context_dev/models.rb +2 -0
  21. data/lib/context_dev/resources/brand.rb +1 -1
  22. data/lib/context_dev/resources/web.rb +51 -5
  23. data/lib/context_dev/version.rb +1 -1
  24. data/lib/context_dev.rb +2 -0
  25. data/rbi/context_dev/models/brand_identify_from_transaction_params.rbi +325 -0
  26. data/rbi/context_dev/models/brand_identify_from_transaction_response.rbi +859 -6
  27. data/rbi/context_dev/models/brand_retrieve_by_email_params.rbi +325 -0
  28. data/rbi/context_dev/models/brand_retrieve_by_email_response.rbi +859 -6
  29. data/rbi/context_dev/models/brand_retrieve_by_isin_params.rbi +325 -0
  30. data/rbi/context_dev/models/brand_retrieve_by_isin_response.rbi +859 -6
  31. data/rbi/context_dev/models/brand_retrieve_by_name_params.rbi +325 -0
  32. data/rbi/context_dev/models/brand_retrieve_by_name_response.rbi +859 -6
  33. data/rbi/context_dev/models/brand_retrieve_by_ticker_params.rbi +325 -0
  34. data/rbi/context_dev/models/brand_retrieve_by_ticker_response.rbi +859 -6
  35. data/rbi/context_dev/models/brand_retrieve_params.rbi +328 -6
  36. data/rbi/context_dev/models/brand_retrieve_response.rbi +859 -6
  37. data/rbi/context_dev/models/web_screenshot_params.rbi +27 -6
  38. data/rbi/context_dev/models/web_web_crawl_md_params.rbi +137 -0
  39. data/rbi/context_dev/models/web_web_crawl_md_response.rbi +230 -0
  40. data/rbi/context_dev/models.rbi +2 -0
  41. data/rbi/context_dev/resources/brand.rbi +1 -2
  42. data/rbi/context_dev/resources/web.rbi +54 -4
  43. data/sig/context_dev/models/brand_identify_from_transaction_params.rbs +131 -1
  44. data/sig/context_dev/models/brand_identify_from_transaction_response.rbs +342 -5
  45. data/sig/context_dev/models/brand_retrieve_by_email_params.rbs +131 -1
  46. data/sig/context_dev/models/brand_retrieve_by_email_response.rbs +342 -5
  47. data/sig/context_dev/models/brand_retrieve_by_isin_params.rbs +131 -1
  48. data/sig/context_dev/models/brand_retrieve_by_isin_response.rbs +342 -5
  49. data/sig/context_dev/models/brand_retrieve_by_name_params.rbs +131 -1
  50. data/sig/context_dev/models/brand_retrieve_by_name_response.rbs +342 -5
  51. data/sig/context_dev/models/brand_retrieve_by_ticker_params.rbs +131 -1
  52. data/sig/context_dev/models/brand_retrieve_by_ticker_response.rbs +342 -5
  53. data/sig/context_dev/models/brand_retrieve_params.rbs +131 -1
  54. data/sig/context_dev/models/brand_retrieve_response.rbs +342 -5
  55. data/sig/context_dev/models/web_screenshot_params.rbs +11 -2
  56. data/sig/context_dev/models/web_web_crawl_md_params.rbs +82 -0
  57. data/sig/context_dev/models/web_web_crawl_md_response.rbs +116 -0
  58. data/sig/context_dev/models.rbs +2 -0
  59. data/sig/context_dev/resources/web.rbs +15 -1
  60. metadata +8 -2
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ContextDev
4
+ module Models
5
+ # @see ContextDev::Resources::Web#web_crawl_md
6
+ class WebWebCrawlMdParams < ContextDev::Internal::Type::BaseModel
7
+ extend ContextDev::Internal::Type::RequestParameters::Converter
8
+ include ContextDev::Internal::Type::RequestParameters
9
+
10
+ # @!attribute url
11
+ # The starting URL for the crawl (must include http:// or https:// protocol)
12
+ #
13
+ # @return [String]
14
+ required :url, String
15
+
16
+ # @!attribute follow_subdomains
17
+ # When true, follow links on subdomains of the starting URL's domain (e.g.
18
+ # docs.example.com when starting from example.com). www and apex are always
19
+ # treated as equivalent.
20
+ #
21
+ # @return [Boolean, nil]
22
+ optional :follow_subdomains, ContextDev::Internal::Type::Boolean, api_name: :followSubdomains
23
+
24
+ # @!attribute include_images
25
+ # Include image references in the Markdown output
26
+ #
27
+ # @return [Boolean, nil]
28
+ optional :include_images, ContextDev::Internal::Type::Boolean, api_name: :includeImages
29
+
30
+ # @!attribute include_links
31
+ # Preserve hyperlinks in the Markdown output
32
+ #
33
+ # @return [Boolean, nil]
34
+ optional :include_links, ContextDev::Internal::Type::Boolean, api_name: :includeLinks
35
+
36
+ # @!attribute max_depth
37
+ # Maximum link depth from the starting URL (0 = only the starting page)
38
+ #
39
+ # @return [Integer, nil]
40
+ optional :max_depth, Integer, api_name: :maxDepth
41
+
42
+ # @!attribute max_pages
43
+ # Maximum number of pages to crawl. Hard cap: 500.
44
+ #
45
+ # @return [Integer, nil]
46
+ optional :max_pages, Integer, api_name: :maxPages
47
+
48
+ # @!attribute shorten_base64_images
49
+ # Truncate base64-encoded image data in the Markdown output
50
+ #
51
+ # @return [Boolean, nil]
52
+ optional :shorten_base64_images, ContextDev::Internal::Type::Boolean, api_name: :shortenBase64Images
53
+
54
+ # @!attribute url_regex
55
+ # Regex pattern. Only URLs matching this pattern will be followed and scraped.
56
+ #
57
+ # @return [String, nil]
58
+ optional :url_regex, String, api_name: :urlRegex
59
+
60
+ # @!attribute use_main_content_only
61
+ # Extract only the main content, stripping headers, footers, sidebars, and
62
+ # navigation
63
+ #
64
+ # @return [Boolean, nil]
65
+ optional :use_main_content_only, ContextDev::Internal::Type::Boolean, api_name: :useMainContentOnly
66
+
67
+ # @!method initialize(url:, follow_subdomains: nil, include_images: nil, include_links: nil, max_depth: nil, max_pages: nil, shorten_base64_images: nil, url_regex: nil, use_main_content_only: nil, request_options: {})
68
+ # Some parameter documentations has been truncated, see
69
+ # {ContextDev::Models::WebWebCrawlMdParams} for more details.
70
+ #
71
+ # @param url [String] The starting URL for the crawl (must include http:// or https:// protocol)
72
+ #
73
+ # @param follow_subdomains [Boolean] When true, follow links on subdomains of the starting URL's domain (e.g. docs.ex
74
+ #
75
+ # @param include_images [Boolean] Include image references in the Markdown output
76
+ #
77
+ # @param include_links [Boolean] Preserve hyperlinks in the Markdown output
78
+ #
79
+ # @param max_depth [Integer] Maximum link depth from the starting URL (0 = only the starting page)
80
+ #
81
+ # @param max_pages [Integer] Maximum number of pages to crawl. Hard cap: 500.
82
+ #
83
+ # @param shorten_base64_images [Boolean] Truncate base64-encoded image data in the Markdown output
84
+ #
85
+ # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped.
86
+ #
87
+ # @param use_main_content_only [Boolean] Extract only the main content, stripping headers, footers, sidebars, and navigat
88
+ #
89
+ # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}]
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ContextDev
4
+ module Models
5
+ # @see ContextDev::Resources::Web#web_crawl_md
6
+ class WebWebCrawlMdResponse < ContextDev::Internal::Type::BaseModel
7
+ # @!attribute metadata
8
+ #
9
+ # @return [ContextDev::Models::WebWebCrawlMdResponse::Metadata]
10
+ required :metadata, -> { ContextDev::Models::WebWebCrawlMdResponse::Metadata }
11
+
12
+ # @!attribute results
13
+ #
14
+ # @return [Array<ContextDev::Models::WebWebCrawlMdResponse::Result>]
15
+ required :results,
16
+ -> { ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebWebCrawlMdResponse::Result] }
17
+
18
+ # @!method initialize(metadata:, results:)
19
+ # @param metadata [ContextDev::Models::WebWebCrawlMdResponse::Metadata]
20
+ # @param results [Array<ContextDev::Models::WebWebCrawlMdResponse::Result>]
21
+
22
+ # @see ContextDev::Models::WebWebCrawlMdResponse#metadata
23
+ class Metadata < ContextDev::Internal::Type::BaseModel
24
+ # @!attribute max_crawl_depth
25
+ # Maximum crawl depth reached during the crawl
26
+ #
27
+ # @return [Integer]
28
+ required :max_crawl_depth, Integer, api_name: :maxCrawlDepth
29
+
30
+ # @!attribute num_failed
31
+ # Number of pages that failed to crawl
32
+ #
33
+ # @return [Integer]
34
+ required :num_failed, Integer, api_name: :numFailed
35
+
36
+ # @!attribute num_succeeded
37
+ # Number of pages successfully crawled
38
+ #
39
+ # @return [Integer]
40
+ required :num_succeeded, Integer, api_name: :numSucceeded
41
+
42
+ # @!attribute num_urls
43
+ # Total number of URLs crawled
44
+ #
45
+ # @return [Integer]
46
+ required :num_urls, Integer, api_name: :numUrls
47
+
48
+ # @!method initialize(max_crawl_depth:, num_failed:, num_succeeded:, num_urls:)
49
+ # @param max_crawl_depth [Integer] Maximum crawl depth reached during the crawl
50
+ #
51
+ # @param num_failed [Integer] Number of pages that failed to crawl
52
+ #
53
+ # @param num_succeeded [Integer] Number of pages successfully crawled
54
+ #
55
+ # @param num_urls [Integer] Total number of URLs crawled
56
+ end
57
+
58
+ class Result < ContextDev::Internal::Type::BaseModel
59
+ # @!attribute markdown
60
+ # Extracted page content as Markdown (empty string on failure)
61
+ #
62
+ # @return [String]
63
+ required :markdown, String
64
+
65
+ # @!attribute metadata
66
+ #
67
+ # @return [ContextDev::Models::WebWebCrawlMdResponse::Result::Metadata]
68
+ required :metadata, -> { ContextDev::Models::WebWebCrawlMdResponse::Result::Metadata }
69
+
70
+ # @!method initialize(markdown:, metadata:)
71
+ # @param markdown [String] Extracted page content as Markdown (empty string on failure)
72
+ #
73
+ # @param metadata [ContextDev::Models::WebWebCrawlMdResponse::Result::Metadata]
74
+
75
+ # @see ContextDev::Models::WebWebCrawlMdResponse::Result#metadata
76
+ class Metadata < ContextDev::Internal::Type::BaseModel
77
+ # @!attribute crawl_depth
78
+ # Depth relative to the start URL. 0 = start URL, 1 = one link away.
79
+ #
80
+ # @return [Integer]
81
+ required :crawl_depth, Integer, api_name: :crawlDepth
82
+
83
+ # @!attribute status_code
84
+ # HTTP status code of the response
85
+ #
86
+ # @return [Integer]
87
+ required :status_code, Integer, api_name: :statusCode
88
+
89
+ # @!attribute success
90
+ # true if the page was fetched and parsed successfully
91
+ #
92
+ # @return [Boolean]
93
+ required :success, ContextDev::Internal::Type::Boolean
94
+
95
+ # @!attribute title
96
+ # The page's <title> content (empty string if unavailable)
97
+ #
98
+ # @return [String]
99
+ required :title, String
100
+
101
+ # @!attribute url
102
+ # The URL that was fetched
103
+ #
104
+ # @return [String]
105
+ required :url, String
106
+
107
+ # @!method initialize(crawl_depth:, status_code:, success:, title:, url:)
108
+ # @param crawl_depth [Integer] Depth relative to the start URL. 0 = start URL, 1 = one link away.
109
+ #
110
+ # @param status_code [Integer] HTTP status code of the response
111
+ #
112
+ # @param success [Boolean] true if the page was fetched and parsed successfully
113
+ #
114
+ # @param title [String] The page's <title> content (empty string if unavailable)
115
+ #
116
+ # @param url [String] The URL that was fetched
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -71,6 +71,8 @@ module ContextDev
71
71
 
72
72
  WebScreenshotParams = ContextDev::Models::WebScreenshotParams
73
73
 
74
+ WebWebCrawlMdParams = ContextDev::Models::WebWebCrawlMdParams
75
+
74
76
  WebWebScrapeHTMLParams = ContextDev::Models::WebWebScrapeHTMLParams
75
77
 
76
78
  WebWebScrapeImagesParams = ContextDev::Models::WebWebScrapeImagesParams
@@ -13,7 +13,7 @@ module ContextDev
13
13
  #
14
14
  # @param domain [String] Domain name to retrieve brand data for (e.g., 'example.com', 'google.com'). Cann
15
15
  #
16
- # @param force_language [Symbol, ContextDev::Models::BrandRetrieveParams::ForceLanguage] Optional parameter to force the language of the retrieved brand data. Works with
16
+ # @param force_language [Symbol, ContextDev::Models::BrandRetrieveParams::ForceLanguage] Optional parameter to force the language of the retrieved brand data.
17
17
  #
18
18
  # @param max_speed [Boolean] Optional parameter to optimize the API call for maximum speed. When set to true,
19
19
  #
@@ -8,10 +8,13 @@ module ContextDev
8
8
  #
9
9
  # Capture a screenshot of a website. Supports both viewport (standard browser
10
10
  # view) and full-page screenshots. Can also screenshot specific page types (login,
11
- # pricing, etc.) by using heuristics to find the appropriate URL. Returns a URL to
12
- # the uploaded screenshot image hosted on our CDN.
11
+ # pricing, etc.) by using heuristics to find the appropriate URL. Either 'domain'
12
+ # or 'directUrl' must be provided as a query parameter, but not both. Returns a
13
+ # URL to the uploaded screenshot image hosted on our CDN.
13
14
  #
14
- # @overload screenshot(domain:, full_screenshot: nil, page: nil, prioritize: nil, request_options: {})
15
+ # @overload screenshot(direct_url: nil, domain: nil, full_screenshot: nil, page: nil, prioritize: nil, request_options: {})
16
+ #
17
+ # @param direct_url [String] A specific URL to screenshot directly, bypassing domain resolution (e.g., 'https
15
18
  #
16
19
  # @param domain [String] Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domai
17
20
  #
@@ -26,18 +29,61 @@ module ContextDev
26
29
  # @return [ContextDev::Models::WebScreenshotResponse]
27
30
  #
28
31
  # @see ContextDev::Models::WebScreenshotParams
29
- def screenshot(params)
32
+ def screenshot(params = {})
30
33
  parsed, options = ContextDev::WebScreenshotParams.dump_request(params)
31
34
  query = ContextDev::Internal::Util.encode_query_params(parsed)
32
35
  @client.request(
33
36
  method: :get,
34
37
  path: "brand/screenshot",
35
- query: query.transform_keys(full_screenshot: "fullScreenshot"),
38
+ query: query.transform_keys(direct_url: "directUrl", full_screenshot: "fullScreenshot"),
36
39
  model: ContextDev::Models::WebScreenshotResponse,
37
40
  options: options
38
41
  )
39
42
  end
40
43
 
44
+ # Some parameter documentations has been truncated, see
45
+ # {ContextDev::Models::WebWebCrawlMdParams} for more details.
46
+ #
47
+ # Performs a crawl starting from a given URL, extracts page content as Markdown,
48
+ # and returns results for all crawled pages. Only follows links within the same
49
+ # domain as the starting URL. Costs 1 credit per successful page crawled.
50
+ #
51
+ # @overload web_crawl_md(url:, follow_subdomains: nil, include_images: nil, include_links: nil, max_depth: nil, max_pages: nil, shorten_base64_images: nil, url_regex: nil, use_main_content_only: nil, request_options: {})
52
+ #
53
+ # @param url [String] The starting URL for the crawl (must include http:// or https:// protocol)
54
+ #
55
+ # @param follow_subdomains [Boolean] When true, follow links on subdomains of the starting URL's domain (e.g. docs.ex
56
+ #
57
+ # @param include_images [Boolean] Include image references in the Markdown output
58
+ #
59
+ # @param include_links [Boolean] Preserve hyperlinks in the Markdown output
60
+ #
61
+ # @param max_depth [Integer] Maximum link depth from the starting URL (0 = only the starting page)
62
+ #
63
+ # @param max_pages [Integer] Maximum number of pages to crawl. Hard cap: 500.
64
+ #
65
+ # @param shorten_base64_images [Boolean] Truncate base64-encoded image data in the Markdown output
66
+ #
67
+ # @param url_regex [String] Regex pattern. Only URLs matching this pattern will be followed and scraped.
68
+ #
69
+ # @param use_main_content_only [Boolean] Extract only the main content, stripping headers, footers, sidebars, and navigat
70
+ #
71
+ # @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]
72
+ #
73
+ # @return [ContextDev::Models::WebWebCrawlMdResponse]
74
+ #
75
+ # @see ContextDev::Models::WebWebCrawlMdParams
76
+ def web_crawl_md(params)
77
+ parsed, options = ContextDev::WebWebCrawlMdParams.dump_request(params)
78
+ @client.request(
79
+ method: :post,
80
+ path: "web/crawl",
81
+ body: parsed,
82
+ model: ContextDev::Models::WebWebCrawlMdResponse,
83
+ options: options
84
+ )
85
+ end
86
+
41
87
  # Scrapes the given URL and returns the raw HTML content of the page.
42
88
  #
43
89
  # @overload web_scrape_html(url:, request_options: {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextDev
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.0"
5
5
  end
data/lib/context_dev.rb CHANGED
@@ -84,6 +84,8 @@ require_relative "context_dev/models/utility_prefetch_params"
84
84
  require_relative "context_dev/models/utility_prefetch_response"
85
85
  require_relative "context_dev/models/web_screenshot_params"
86
86
  require_relative "context_dev/models/web_screenshot_response"
87
+ require_relative "context_dev/models/web_web_crawl_md_params"
88
+ require_relative "context_dev/models/web_web_crawl_md_response"
87
89
  require_relative "context_dev/models/web_web_scrape_html_params"
88
90
  require_relative "context_dev/models/web_web_scrape_html_response"
89
91
  require_relative "context_dev/models/web_web_scrape_images_params"