context.dev 2.19.0 → 2.20.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.
@@ -19,6 +19,14 @@ module ContextDev
19
19
  # @return [ContextDev::Models::WebScrapeResponse::CacheMetadata]
20
20
  required :cache_metadata, -> { ContextDev::Models::WebScrapeResponse::CacheMetadata }
21
21
 
22
+ # @!attribute highlights
23
+ # Plain-text passages relevant to highlightsParams.query, in page order, each
24
+ # prefixed with its section heading in square brackets. Empty when the page has no
25
+ # text.
26
+ #
27
+ # @return [ContextDev::Models::WebScrapeResponse::Highlights]
28
+ required :highlights, -> { ContextDev::Models::WebScrapeResponse::Highlights }
29
+
22
30
  # @!attribute html
23
31
  # Rendered HTML after content filters.
24
32
  #
@@ -31,6 +39,15 @@ module ContextDev
31
39
  # @return [ContextDev::Models::WebScrapeResponse::Images]
32
40
  required :images, -> { ContextDev::Models::WebScrapeResponse::Images }
33
41
 
42
+ # @!attribute json
43
+ # Page data extracted into jsonParams.schema, after shared content filters. Values
44
+ # are grounded in the page; optional fields the page does not state are omitted,
45
+ # or null when their type allows null. An empty object when the filters leave no
46
+ # text.
47
+ #
48
+ # @return [ContextDev::Models::WebScrapeResponse::Json]
49
+ required :json, -> { ContextDev::Models::WebScrapeResponse::Json }
50
+
34
51
  # @!attribute markdown
35
52
  # Markdown after content filters.
36
53
  #
@@ -49,6 +66,12 @@ module ContextDev
49
66
  # @return [ContextDev::Models::WebScrapeResponse::Parsed]
50
67
  required :parsed, -> { ContextDev::Models::WebScrapeResponse::Parsed }
51
68
 
69
+ # @!attribute product
70
+ # Product detail page classification and the extracted product.
71
+ #
72
+ # @return [ContextDev::Models::WebScrapeResponse::Product]
73
+ required :product, -> { ContextDev::Models::WebScrapeResponse::Product }
74
+
52
75
  # @!attribute request_id
53
76
  # Unique id of this API call, also sent in the X-Request-Id response header. Quote
54
77
  # it when contacting support about a failed request.
@@ -69,8 +92,10 @@ module ContextDev
69
92
  required :url, String
70
93
 
71
94
  # @!attribute is_partial
72
- # Present when return-partial captures a page that is still loading or returns
73
- # images before image processing finishes. Partial responses are not cached.
95
+ # Present when return-partial captures a page that is still loading, returns
96
+ # images before image processing finishes, or cuts product AI extraction short.
97
+ # Also present if the optional product AI fallback fails. Partial responses are
98
+ # not cached.
74
99
  #
75
100
  # @return [Boolean, ContextDev::Models::WebScrapeResponse::IsPartial, nil]
76
101
  optional :is_partial, enum: -> { ContextDev::Models::WebScrapeResponse::IsPartial }, api_name: :isPartial
@@ -81,7 +106,7 @@ module ContextDev
81
106
  # @return [ContextDev::Models::WebScrapeResponse::KeyMetadata, nil]
82
107
  optional :key_metadata, -> { ContextDev::Models::WebScrapeResponse::KeyMetadata }
83
108
 
84
- # @!method initialize(bytes:, cache_metadata:, html:, images:, markdown:, metadata:, parsed:, request_id:, screenshot:, url:, is_partial: nil, key_metadata: nil)
109
+ # @!method initialize(bytes:, cache_metadata:, highlights:, html:, images:, json:, markdown:, metadata:, parsed:, product:, request_id:, screenshot:, url:, is_partial: nil, key_metadata: nil)
85
110
  # Some parameter documentations has been truncated, see
86
111
  # {ContextDev::Models::WebScrapeResponse} for more details.
87
112
  #
@@ -89,23 +114,29 @@ module ContextDev
89
114
  #
90
115
  # @param cache_metadata [ContextDev::Models::WebScrapeResponse::CacheMetadata] Cache outcome for this response. Composite responses are hits only when every ca
91
116
  #
117
+ # @param highlights [ContextDev::Models::WebScrapeResponse::Highlights] Plain-text passages relevant to highlightsParams.query, in page order, each pref
118
+ #
92
119
  # @param html [ContextDev::Models::WebScrapeResponse::HTML] Rendered HTML after content filters.
93
120
  #
94
121
  # @param images [ContextDev::Models::WebScrapeResponse::Images] Images after content filters. Empty when none are found.
95
122
  #
123
+ # @param json [ContextDev::Models::WebScrapeResponse::Json] Page data extracted into jsonParams.schema, after shared content filters. Values
124
+ #
96
125
  # @param markdown [ContextDev::Models::WebScrapeResponse::Markdown] Markdown after content filters.
97
126
  #
98
127
  # @param metadata [ContextDev::Models::WebScrapeResponse::Metadata] Page details, when available.
99
128
  #
100
129
  # @param parsed [ContextDev::Models::WebScrapeResponse::Parsed] Fields produced by parseParams.rules, after shared content filters.
101
130
  #
131
+ # @param product [ContextDev::Models::WebScrapeResponse::Product] Product detail page classification and the extracted product.
132
+ #
102
133
  # @param request_id [String] Unique id of this API call, also sent in the X-Request-Id response header. Quote
103
134
  #
104
135
  # @param screenshot [ContextDev::Models::WebScrapeResponse::Screenshot] An image data URL. Use directly as an image src.
105
136
  #
106
137
  # @param url [String] Final URL after redirects and browser actions.
107
138
  #
108
- # @param is_partial [Boolean, ContextDev::Models::WebScrapeResponse::IsPartial] Present when return-partial captures a page that is still loading or returns ima
139
+ # @param is_partial [Boolean, ContextDev::Models::WebScrapeResponse::IsPartial] Present when return-partial captures a page that is still loading, returns image
109
140
  #
110
141
  # @param key_metadata [ContextDev::Models::WebScrapeResponse::KeyMetadata] Credit usage, included whenever a valid API key is provided.
111
142
 
@@ -195,6 +226,27 @@ module ContextDev
195
226
  end
196
227
  end
197
228
 
229
+ # @see ContextDev::Models::WebScrapeResponse#highlights
230
+ class Highlights < ContextDev::Internal::Type::BaseModel
231
+ # @!attribute data
232
+ #
233
+ # @return [Array<String>, nil]
234
+ required :data, ContextDev::Internal::Type::ArrayOf[String], nil?: true
235
+
236
+ # @!attribute requested
237
+ #
238
+ # @return [Boolean]
239
+ required :requested, ContextDev::Internal::Type::Boolean
240
+
241
+ # @!method initialize(data:, requested:)
242
+ # Plain-text passages relevant to highlightsParams.query, in page order, each
243
+ # prefixed with its section heading in square brackets. Empty when the page has no
244
+ # text.
245
+ #
246
+ # @param data [Array<String>, nil]
247
+ # @param requested [Boolean]
248
+ end
249
+
198
250
  # @see ContextDev::Models::WebScrapeResponse#html
199
251
  class HTML < ContextDev::Internal::Type::BaseModel
200
252
  # @!attribute data
@@ -304,6 +356,28 @@ module ContextDev
304
356
  end
305
357
  end
306
358
 
359
+ # @see ContextDev::Models::WebScrapeResponse#json
360
+ class Json < ContextDev::Internal::Type::BaseModel
361
+ # @!attribute data
362
+ #
363
+ # @return [Hash{Symbol=>Object}, nil]
364
+ required :data, ContextDev::Internal::Type::HashOf[ContextDev::Internal::Type::Unknown], nil?: true
365
+
366
+ # @!attribute requested
367
+ #
368
+ # @return [Boolean]
369
+ required :requested, ContextDev::Internal::Type::Boolean
370
+
371
+ # @!method initialize(data:, requested:)
372
+ # Page data extracted into jsonParams.schema, after shared content filters. Values
373
+ # are grounded in the page; optional fields the page does not state are omitted,
374
+ # or null when their type allows null. An empty object when the filters leave no
375
+ # text.
376
+ #
377
+ # @param data [Hash{Symbol=>Object}, nil]
378
+ # @param requested [Boolean]
379
+ end
380
+
307
381
  # @see ContextDev::Models::WebScrapeResponse#markdown
308
382
  class Markdown < ContextDev::Internal::Type::BaseModel
309
383
  # @!attribute data
@@ -601,6 +675,245 @@ module ContextDev
601
675
  # @param requested [Boolean]
602
676
  end
603
677
 
678
+ # @see ContextDev::Models::WebScrapeResponse#product
679
+ class Product < ContextDev::Internal::Type::BaseModel
680
+ # @!attribute data
681
+ #
682
+ # @return [ContextDev::Models::WebScrapeResponse::Product::Data, nil]
683
+ required :data, -> { ContextDev::Models::WebScrapeResponse::Product::Data }, nil?: true
684
+
685
+ # @!attribute requested
686
+ #
687
+ # @return [Boolean]
688
+ required :requested, ContextDev::Internal::Type::Boolean
689
+
690
+ # @!method initialize(data:, requested:)
691
+ # Product detail page classification and the extracted product.
692
+ #
693
+ # @param data [ContextDev::Models::WebScrapeResponse::Product::Data, nil]
694
+ # @param requested [Boolean]
695
+
696
+ # @see ContextDev::Models::WebScrapeResponse::Product#data
697
+ class Data < ContextDev::Internal::Type::BaseModel
698
+ # @!attribute is_product_page
699
+ # Whether the page is a product detail page.
700
+ #
701
+ # @return [Boolean]
702
+ required :is_product_page, ContextDev::Internal::Type::Boolean, api_name: :isProductPage
703
+
704
+ # @!attribute product
705
+ # The extracted product, or null when the page is not a product detail page.
706
+ #
707
+ # @return [ContextDev::Models::WebScrapeResponse::Product::Data::Product, nil]
708
+ required :product, -> { ContextDev::Models::WebScrapeResponse::Product::Data::Product }, nil?: true
709
+
710
+ # @!method initialize(is_product_page:, product:)
711
+ # @param is_product_page [Boolean] Whether the page is a product detail page.
712
+ #
713
+ # @param product [ContextDev::Models::WebScrapeResponse::Product::Data::Product, nil] The extracted product, or null when the page is not a product detail page.
714
+
715
+ # @see ContextDev::Models::WebScrapeResponse::Product::Data#product
716
+ class Product < ContextDev::Internal::Type::BaseModel
717
+ # @!attribute availability
718
+ # Stock or ordering availability.
719
+ #
720
+ # @return [Symbol, ContextDev::Models::WebScrapeResponse::Product::Data::Product::Availability, nil]
721
+ required :availability,
722
+ enum: -> { ContextDev::Models::WebScrapeResponse::Product::Data::Product::Availability },
723
+ nil?: true
724
+
725
+ # @!attribute brand
726
+ # Brand or vendor.
727
+ #
728
+ # @return [String, nil]
729
+ required :brand, String, nil?: true
730
+
731
+ # @!attribute category
732
+ # Product category.
733
+ #
734
+ # @return [String, nil]
735
+ required :category, String, nil?: true
736
+
737
+ # @!attribute currency
738
+ # ISO 4217 currency code.
739
+ #
740
+ # @return [String, nil]
741
+ required :currency, String, nil?: true
742
+
743
+ # @!attribute description
744
+ # Product description.
745
+ #
746
+ # @return [String, nil]
747
+ required :description, String, nil?: true
748
+
749
+ # @!attribute dimensions
750
+ # Product dimensions as shown on the page.
751
+ #
752
+ # @return [Array<String>]
753
+ required :dimensions, ContextDev::Internal::Type::ArrayOf[String]
754
+
755
+ # @!attribute features
756
+ # Key features and specifications.
757
+ #
758
+ # @return [Array<String>]
759
+ required :features, ContextDev::Internal::Type::ArrayOf[String]
760
+
761
+ # @!attribute images
762
+ # Product image URLs, main image first.
763
+ #
764
+ # @return [Array<String>]
765
+ required :images, ContextDev::Internal::Type::ArrayOf[String]
766
+
767
+ # @!attribute image_url
768
+ # Main product image URL.
769
+ #
770
+ # @return [String, nil]
771
+ required :image_url, String, api_name: :imageUrl, nil?: true
772
+
773
+ # @!attribute name
774
+ # Product name.
775
+ #
776
+ # @return [String]
777
+ required :name, String
778
+
779
+ # @!attribute price
780
+ # Current price.
781
+ #
782
+ # @return [Float, nil]
783
+ required :price, Float, nil?: true
784
+
785
+ # @!attribute regular_price
786
+ # List price before any discount.
787
+ #
788
+ # @return [Float, nil]
789
+ required :regular_price, Float, api_name: :regularPrice, nil?: true
790
+
791
+ # @!attribute sku
792
+ # Product identifier such as a SKU or model number.
793
+ #
794
+ # @return [String, nil]
795
+ required :sku, String, nil?: true
796
+
797
+ # @!attribute tags
798
+ # Product tags.
799
+ #
800
+ # @return [Array<String>]
801
+ required :tags, ContextDev::Internal::Type::ArrayOf[String]
802
+
803
+ # @!attribute target_audience
804
+ # Intended audience.
805
+ #
806
+ # @return [Array<String>]
807
+ required :target_audience, ContextDev::Internal::Type::ArrayOf[String], api_name: :targetAudience
808
+
809
+ # @!attribute variants
810
+ # Product variations, such as different colors or sizes, with their attributes and
811
+ # images. Empty if none are found. May not include every variation offered by the
812
+ # store.
813
+ #
814
+ # @return [Array<ContextDev::Models::WebScrapeResponse::Product::Data::Product::Variant>]
815
+ required :variants,
816
+ -> { ContextDev::Internal::Type::ArrayOf[ContextDev::Models::WebScrapeResponse::Product::Data::Product::Variant] }
817
+
818
+ # @!method initialize(availability:, brand:, category:, currency:, description:, dimensions:, features:, images:, image_url:, name:, price:, regular_price:, sku:, tags:, target_audience:, variants:)
819
+ # Some parameter documentations has been truncated, see
820
+ # {ContextDev::Models::WebScrapeResponse::Product::Data::Product} for more
821
+ # details.
822
+ #
823
+ # The extracted product, or null when the page is not a product detail page.
824
+ #
825
+ # @param availability [Symbol, ContextDev::Models::WebScrapeResponse::Product::Data::Product::Availability, nil] Stock or ordering availability.
826
+ #
827
+ # @param brand [String, nil] Brand or vendor.
828
+ #
829
+ # @param category [String, nil] Product category.
830
+ #
831
+ # @param currency [String, nil] ISO 4217 currency code.
832
+ #
833
+ # @param description [String, nil] Product description.
834
+ #
835
+ # @param dimensions [Array<String>] Product dimensions as shown on the page.
836
+ #
837
+ # @param features [Array<String>] Key features and specifications.
838
+ #
839
+ # @param images [Array<String>] Product image URLs, main image first.
840
+ #
841
+ # @param image_url [String, nil] Main product image URL.
842
+ #
843
+ # @param name [String] Product name.
844
+ #
845
+ # @param price [Float, nil] Current price.
846
+ #
847
+ # @param regular_price [Float, nil] List price before any discount.
848
+ #
849
+ # @param sku [String, nil] Product identifier such as a SKU or model number.
850
+ #
851
+ # @param tags [Array<String>] Product tags.
852
+ #
853
+ # @param target_audience [Array<String>] Intended audience.
854
+ #
855
+ # @param variants [Array<ContextDev::Models::WebScrapeResponse::Product::Data::Product::Variant>] Product variations, such as different colors or sizes, with their attributes and
856
+
857
+ # Stock or ordering availability.
858
+ #
859
+ # @see ContextDev::Models::WebScrapeResponse::Product::Data::Product#availability
860
+ module Availability
861
+ extend ContextDev::Internal::Type::Enum
862
+
863
+ IN_STOCK = :in_stock
864
+ OUT_OF_STOCK = :out_of_stock
865
+ LIMITED_AVAILABILITY = :limited_availability
866
+ PREORDER = :preorder
867
+ BACKORDER = :backorder
868
+ MADE_TO_ORDER = :made_to_order
869
+ DISCONTINUED = :discontinued
870
+
871
+ # @!method self.values
872
+ # @return [Array<Symbol>]
873
+ end
874
+
875
+ class Variant < ContextDev::Internal::Type::BaseModel
876
+ # @!attribute attributes
877
+ # Explicit variant attributes such as color, size, material, pattern and
878
+ # properties declared by page.
879
+ #
880
+ # @return [Hash{Symbol=>String}]
881
+ required :attributes, ContextDev::Internal::Type::HashOf[String]
882
+
883
+ # @!attribute images
884
+ # Original source image URLs explicitly attached to this variant.
885
+ #
886
+ # @return [Array<String>]
887
+ required :images, ContextDev::Internal::Type::ArrayOf[String]
888
+
889
+ # @!attribute sku
890
+ #
891
+ # @return [String, nil]
892
+ required :sku, String, nil?: true
893
+
894
+ # @!attribute url
895
+ # Variant or offer URL when provided by the source. May be shared by variants.
896
+ #
897
+ # @return [String, nil]
898
+ required :url, String, nil?: true
899
+
900
+ # @!method initialize(attributes:, images:, sku:, url:)
901
+ # Some parameter documentations has been truncated, see
902
+ # {ContextDev::Models::WebScrapeResponse::Product::Data::Product::Variant} for
903
+ # more details.
904
+ #
905
+ # @param attributes [Hash{Symbol=>String}] Explicit variant attributes such as color, size, material, pattern and propertie
906
+ #
907
+ # @param images [Array<String>] Original source image URLs explicitly attached to this variant.
908
+ #
909
+ # @param sku [String, nil]
910
+ #
911
+ # @param url [String, nil] Variant or offer URL when provided by the source. May be shared by variants.
912
+ end
913
+ end
914
+ end
915
+ end
916
+
604
917
  # @see ContextDev::Models::WebScrapeResponse#screenshot
605
918
  class Screenshot < ContextDev::Internal::Type::BaseModel
606
919
  # @!attribute data
@@ -620,8 +933,10 @@ module ContextDev
620
933
  # @param requested [Boolean]
621
934
  end
622
935
 
623
- # Present when return-partial captures a page that is still loading or returns
624
- # images before image processing finishes. Partial responses are not cached.
936
+ # Present when return-partial captures a page that is still loading, returns
937
+ # images before image processing finishes, or cuts product AI extraction short.
938
+ # Also present if the optional product AI fallback fails. Partial responses are
939
+ # not cached.
625
940
  #
626
941
  # @see ContextDev::Models::WebScrapeResponse#is_partial
627
942
  module IsPartial
@@ -183,27 +183,39 @@ 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 the plain-text passages most relevant to
190
+ # highlightsParams.query. One credit per request, including cache hits and missing
191
+ # pages, or two with browser actions; highlights add 3 credits when passages are
192
+ # returned; JSON extraction adds four credits and runs an LLM over the page
193
+ # Markdown on every request that has text to extract; PDF OCR adds one credit per
194
+ # recovered page on fresh extraction; the product output adds one credit, plus six
195
+ # more when the specialized model is used. Original response bytes and screenshots
196
+ # are limited to 20 MiB each, screenshots to 40 megapixels, and the combined
197
+ # browser capture to 60 MiB.
198
+ #
199
+ # @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
200
  #
195
201
  # @param formats [ContextDev::Models::WebScrapeParams::Formats] Outputs to return. Enable at least one; omitted formats are false.
196
202
  #
197
203
  # @param url [String] The URL to scrape.
198
204
  #
205
+ # @param highlights_params [ContextDev::Models::WebScrapeParams::HighlightsParams] Highlight options. Requires formats.highlights: true.
206
+ #
199
207
  # @param image_params [ContextDev::Models::WebScrapeParams::ImageParams] Image options. Requires formats.images: true.
200
208
  #
209
+ # @param json_params [ContextDev::Models::WebScrapeParams::JsonParams] Required when formats.json is true.
210
+ #
201
211
  # @param markdown_params [ContextDev::Models::WebScrapeParams::MarkdownParams] Markdown options. Requires formats.markdown: true.
202
212
  #
203
213
  # @param max_age_ms [Integer] Maximum age of each cached output. Defaults to 1 day; 0 fetches fresh and update
204
214
  #
205
215
  # @param parse_params [ContextDev::Models::WebScrapeParams::ParseParams] Required when formats.parse is true.
206
216
  #
217
+ # @param product_params [ContextDev::Models::WebScrapeParams::ProductParams] Product options. Requires formats.product: true.
218
+ #
207
219
  # @param screenshot_params [ContextDev::Models::WebScrapeParams::ScreenshotParams] Screenshot options. Requires formats.screenshot: true.
208
220
  #
209
221
  # @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.20.0"
5
5
  end