Skip to content

Commit 787f92f

Browse files
feat(api): api update
1 parent e99ca05 commit 787f92f

6 files changed

Lines changed: 62 additions & 11 deletions

File tree

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 25
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-a4f78808dc23a76896b451576b3b44b0d663977f2032eaed0271dd386b20c43c.yml
3-
openapi_spec_hash: 01f9e1ae0d635f8b874f48e3ba461476
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-021b48afe1d6e3f54c4ebe3d0da4beb3fb8b69a6d384a4aeadbc5bab7f967603.yml
3+
openapi_spec_hash: 2aa5b59d78c708b094acf29cc0d9a68a
44
config_hash: c7b0cdaba3b9797b77efd89e1754d803

‎src/ServiceContracts/WebContract.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use ContextDev\Web\WebExtractFontsResponse;
1111
use ContextDev\Web\WebExtractParams\Pdf;
1212
use ContextDev\Web\WebExtractResponse;
13+
use ContextDev\Web\WebExtractStyleguideParams\ColorScheme;
1314
use ContextDev\Web\WebExtractStyleguideResponse;
14-
use ContextDev\Web\WebScreenshotParams\ColorScheme;
1515
use ContextDev\Web\WebScreenshotParams\Country;
1616
use ContextDev\Web\WebScreenshotParams\FullScreenshot;
1717
use ContextDev\Web\WebScreenshotParams\HandleCookiePopup;
@@ -116,6 +116,7 @@ public function extractFonts(
116116
/**
117117
* @api
118118
*
119+
* @param ColorScheme|value-of<ColorScheme> $colorScheme Optional browser color scheme to emulate for websites that respond to prefers-color-scheme. This value is part of the styleguide cache key.
119120
* @param string $directURL A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, the styleguide is extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.
120121
* @param string $domain Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated. You must provide either 'domain' or 'directUrl', but not both.
121122
* @param int $maxAgeMs Maximum age in milliseconds for cached data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.
@@ -125,6 +126,7 @@ public function extractFonts(
125126
* @throws APIException
126127
*/
127128
public function extractStyleguide(
129+
ColorScheme|string|null $colorScheme = null,
128130
?string $directURL = null,
129131
?string $domain = null,
130132
int $maxAgeMs = 7776000000,
@@ -135,7 +137,7 @@ public function extractStyleguide(
135137
/**
136138
* @api
137139
*
138-
* @param ColorScheme|value-of<ColorScheme> $colorScheme Optional parameter to choose the site's visual theme in the screenshot. Use 'light' or 'dark' when the site offers both appearances.
140+
* @param \ContextDev\Web\WebScreenshotParams\ColorScheme|value-of<\ContextDev\Web\WebScreenshotParams\ColorScheme> $colorScheme Optional parameter to choose the site's visual theme in the screenshot. Use 'light' or 'dark' when the site offers both appearances.
139141
* @param Country|value-of<Country> $country Two-letter ISO 3166-1 alpha-2 country code for the website request location. When provided, Context.dev fetches the target page from that country.
140142
* @param string $directURL A specific URL to screenshot directly, bypassing domain resolution (e.g., 'https://example.com/pricing'). When provided, the screenshot is taken of this exact URL. You must provide either 'domain' or 'directUrl', but not both.
141143
* @param string $domain Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated. You must provide either 'domain' or 'directUrl', but not both.
@@ -152,7 +154,7 @@ public function extractStyleguide(
152154
* @throws APIException
153155
*/
154156
public function screenshot(
155-
ColorScheme|string|null $colorScheme = null,
157+
\ContextDev\Web\WebScreenshotParams\ColorScheme|string|null $colorScheme = null,
156158
Country|string|null $country = null,
157159
?string $directURL = null,
158160
?string $domain = null,

‎src/Services/WebRawService.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
use ContextDev\Web\WebExtractParams\Pdf;
1919
use ContextDev\Web\WebExtractResponse;
2020
use ContextDev\Web\WebExtractStyleguideParams;
21+
use ContextDev\Web\WebExtractStyleguideParams\ColorScheme;
2122
use ContextDev\Web\WebExtractStyleguideResponse;
2223
use ContextDev\Web\WebScreenshotParams;
23-
use ContextDev\Web\WebScreenshotParams\ColorScheme;
2424
use ContextDev\Web\WebScreenshotParams\Country;
2525
use ContextDev\Web\WebScreenshotParams\FullScreenshot;
2626
use ContextDev\Web\WebScreenshotParams\HandleCookiePopup;
@@ -181,7 +181,11 @@ public function extractFonts(
181181
* Extract a comprehensive design system from a website including colors, typography, spacing, shadows, and UI components.
182182
*
183183
* @param array{
184-
* directURL?: string, domain?: string, maxAgeMs?: int, timeoutMs?: int
184+
* colorScheme?: ColorScheme|value-of<ColorScheme>,
185+
* directURL?: string,
186+
* domain?: string,
187+
* maxAgeMs?: int,
188+
* timeoutMs?: int,
185189
* }|WebExtractStyleguideParams $params
186190
* @param RequestOpts|null $requestOptions
187191
*
@@ -217,7 +221,7 @@ public function extractStyleguide(
217221
* Capture a screenshot of a website.
218222
*
219223
* @param array{
220-
* colorScheme?: ColorScheme|value-of<ColorScheme>,
224+
* colorScheme?: WebScreenshotParams\ColorScheme|value-of<WebScreenshotParams\ColorScheme>,
221225
* country?: value-of<Country>,
222226
* directURL?: string,
223227
* domain?: string,

‎src/Services/WebService.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use ContextDev\Web\WebExtractFontsResponse;
1414
use ContextDev\Web\WebExtractParams\Pdf;
1515
use ContextDev\Web\WebExtractResponse;
16+
use ContextDev\Web\WebExtractStyleguideParams\ColorScheme;
1617
use ContextDev\Web\WebExtractStyleguideResponse;
17-
use ContextDev\Web\WebScreenshotParams\ColorScheme;
1818
use ContextDev\Web\WebScreenshotParams\Country;
1919
use ContextDev\Web\WebScreenshotParams\FullScreenshot;
2020
use ContextDev\Web\WebScreenshotParams\HandleCookiePopup;
@@ -190,6 +190,7 @@ public function extractFonts(
190190
*
191191
* Extract a comprehensive design system from a website including colors, typography, spacing, shadows, and UI components.
192192
*
193+
* @param ColorScheme|value-of<ColorScheme> $colorScheme Optional browser color scheme to emulate for websites that respond to prefers-color-scheme. This value is part of the styleguide cache key.
193194
* @param string $directURL A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, the styleguide is extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.
194195
* @param string $domain Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated. You must provide either 'domain' or 'directUrl', but not both.
195196
* @param int $maxAgeMs Maximum age in milliseconds for cached data before the API performs a hard refresh. Defaults to 3 months (7776000000 ms). Values below 1 day (86400000 ms) are clamped to 1 day; values above 1 year (31536000000 ms) are clamped to 1 year.
@@ -199,6 +200,7 @@ public function extractFonts(
199200
* @throws APIException
200201
*/
201202
public function extractStyleguide(
203+
ColorScheme|string|null $colorScheme = null,
202204
?string $directURL = null,
203205
?string $domain = null,
204206
int $maxAgeMs = 7776000000,
@@ -207,6 +209,7 @@ public function extractStyleguide(
207209
): WebExtractStyleguideResponse {
208210
$params = Util::removeNulls(
209211
[
212+
'colorScheme' => $colorScheme,
210213
'directURL' => $directURL,
211214
'domain' => $domain,
212215
'maxAgeMs' => $maxAgeMs,
@@ -225,7 +228,7 @@ public function extractStyleguide(
225228
*
226229
* Capture a screenshot of a website.
227230
*
228-
* @param ColorScheme|value-of<ColorScheme> $colorScheme Optional parameter to choose the site's visual theme in the screenshot. Use 'light' or 'dark' when the site offers both appearances.
231+
* @param \ContextDev\Web\WebScreenshotParams\ColorScheme|value-of<\ContextDev\Web\WebScreenshotParams\ColorScheme> $colorScheme Optional parameter to choose the site's visual theme in the screenshot. Use 'light' or 'dark' when the site offers both appearances.
229232
* @param Country|value-of<Country> $country Two-letter ISO 3166-1 alpha-2 country code for the website request location. When provided, Context.dev fetches the target page from that country.
230233
* @param string $directURL A specific URL to screenshot directly, bypassing domain resolution (e.g., 'https://example.com/pricing'). When provided, the screenshot is taken of this exact URL. You must provide either 'domain' or 'directUrl', but not both.
231234
* @param string $domain Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The domain will be automatically normalized and validated. You must provide either 'domain' or 'directUrl', but not both.
@@ -242,7 +245,7 @@ public function extractStyleguide(
242245
* @throws APIException
243246
*/
244247
public function screenshot(
245-
ColorScheme|string|null $colorScheme = null,
248+
\ContextDev\Web\WebScreenshotParams\ColorScheme|string|null $colorScheme = null,
246249
Country|string|null $country = null,
247250
?string $directURL = null,
248251
?string $domain = null,

‎src/Web/WebExtractStyleguideParams.php‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
use ContextDev\Core\Concerns\SdkModel;
99
use ContextDev\Core\Concerns\SdkParams;
1010
use ContextDev\Core\Contracts\BaseModel;
11+
use ContextDev\Web\WebExtractStyleguideParams\ColorScheme;
1112

1213
/**
1314
* Extract a comprehensive design system from a website including colors, typography, spacing, shadows, and UI components.
1415
*
1516
* @see ContextDev\Services\WebService::extractStyleguide()
1617
*
1718
* @phpstan-type WebExtractStyleguideParamsShape = array{
19+
* colorScheme?: null|ColorScheme|value-of<ColorScheme>,
1820
* directURL?: string|null,
1921
* domain?: string|null,
2022
* maxAgeMs?: int|null,
@@ -27,6 +29,14 @@ final class WebExtractStyleguideParams implements BaseModel
2729
use SdkModel;
2830
use SdkParams;
2931

32+
/**
33+
* Optional browser color scheme to emulate for websites that respond to prefers-color-scheme. This value is part of the styleguide cache key.
34+
*
35+
* @var value-of<ColorScheme>|null $colorScheme
36+
*/
37+
#[Optional(enum: ColorScheme::class)]
38+
public ?string $colorScheme;
39+
3040
/**
3141
* A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, the styleguide is extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.
3242
*/
@@ -60,15 +70,19 @@ public function __construct()
6070
* Construct an instance from the required parameters.
6171
*
6272
* You must use named parameters to construct any parameters with a default value.
73+
*
74+
* @param ColorScheme|value-of<ColorScheme>|null $colorScheme
6375
*/
6476
public static function with(
77+
ColorScheme|string|null $colorScheme = null,
6578
?string $directURL = null,
6679
?string $domain = null,
6780
?int $maxAgeMs = null,
6881
?int $timeoutMs = null,
6982
): self {
7083
$self = new self;
7184

85+
null !== $colorScheme && $self['colorScheme'] = $colorScheme;
7286
null !== $directURL && $self['directURL'] = $directURL;
7387
null !== $domain && $self['domain'] = $domain;
7488
null !== $maxAgeMs && $self['maxAgeMs'] = $maxAgeMs;
@@ -77,6 +91,19 @@ public static function with(
7791
return $self;
7892
}
7993

94+
/**
95+
* Optional browser color scheme to emulate for websites that respond to prefers-color-scheme. This value is part of the styleguide cache key.
96+
*
97+
* @param ColorScheme|value-of<ColorScheme> $colorScheme
98+
*/
99+
public function withColorScheme(ColorScheme|string $colorScheme): self
100+
{
101+
$self = clone $this;
102+
$self['colorScheme'] = $colorScheme;
103+
104+
return $self;
105+
}
106+
80107
/**
81108
* A specific URL to fetch the styleguide from directly, bypassing domain resolution (e.g., 'https://example.com/design-system'). When provided, the styleguide is extracted from this exact URL. You must provide either 'domain' or 'directUrl', but not both.
82109
*/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\Web\WebExtractStyleguideParams;
6+
7+
/**
8+
* Optional browser color scheme to emulate for websites that respond to prefers-color-scheme. This value is part of the styleguide cache key.
9+
*/
10+
enum ColorScheme: string
11+
{
12+
case LIGHT = 'light';
13+
14+
case DARK = 'dark';
15+
}

0 commit comments

Comments
 (0)