From ff99b26b7637564f862495b39c9ee729aee170b2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2026 09:02:55 +0000 Subject: [PATCH 1/7] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9673209..21c2cfc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-b0c72d2fe5911c9ce155275b954198bf2152e915a7e5b9f719aad50e222b9ef8.yml -openapi_spec_hash: 5cf943ea5718059b7975417b012cee28 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-5f711a43f60f18016c38794f4dbd4fa86221e2ac2e50f9875ae84f5a247db136.yml +openapi_spec_hash: 1000553b31fbfe8574b5c7ed47b2166e config_hash: 0fb0ceca5946298c416cec0cca5260c7 From 3dbbac273b81d666b1dc7584e125bd5ce0ba3d9a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2026 09:40:13 +0000 Subject: [PATCH 2/7] feat(api): api update --- .stats.yml | 4 ++-- src/News/NewsSearchParams/FilterBy/SourceCountry.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 21c2cfc..ab4d401 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-5f711a43f60f18016c38794f4dbd4fa86221e2ac2e50f9875ae84f5a247db136.yml -openapi_spec_hash: 1000553b31fbfe8574b5c7ed47b2166e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-f6a6ca581fd279a5c8028e3e00d84fd5114c0ba206f15e84c24d8abeedbf47d9.yml +openapi_spec_hash: 07010001ef5726f6f0f6ecdea1b36b51 config_hash: 0fb0ceca5946298c416cec0cca5260c7 diff --git a/src/News/NewsSearchParams/FilterBy/SourceCountry.php b/src/News/NewsSearchParams/FilterBy/SourceCountry.php index 3919e6a..efc6d81 100644 --- a/src/News/NewsSearchParams/FilterBy/SourceCountry.php +++ b/src/News/NewsSearchParams/FilterBy/SourceCountry.php @@ -20,6 +20,8 @@ enum SourceCountry: string case CL = 'cl'; + case CZ = 'cz'; + case DE = 'de'; case FI = 'fi'; From 759764d3566b21ed7aeafffbaa097340d51a9fd2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Aug 2026 12:28:34 +0000 Subject: [PATCH 3/7] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index ab4d401..91ac12d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-f6a6ca581fd279a5c8028e3e00d84fd5114c0ba206f15e84c24d8abeedbf47d9.yml -openapi_spec_hash: 07010001ef5726f6f0f6ecdea1b36b51 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-29a5e9392b60f02d4c19d457b92666bf54d49479670e719f36f23a5d3943f188.yml +openapi_spec_hash: 8a9c44d740853834fb6d7174013c1984 config_hash: 0fb0ceca5946298c416cec0cca5260c7 From 84e23875b946b62c378ddd8f4f3c70c76e3bba47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 02:21:39 +0000 Subject: [PATCH 4/7] feat(api): api update --- .stats.yml | 4 ++-- src/ServiceContracts/WebContract.php | 6 +++--- src/Services/WebService.php | 6 +++--- src/Web/WebWebCrawlMdParams.php | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91ac12d..44d1600 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-29a5e9392b60f02d4c19d457b92666bf54d49479670e719f36f23a5d3943f188.yml -openapi_spec_hash: 8a9c44d740853834fb6d7174013c1984 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-d4c568ebc1a0f853b02c55ba800c7d7b66189bc6dd22c3cb565a81361c832e2b.yml +openapi_spec_hash: 9a0ecdc06874eee29a3a58a699923405 config_hash: 0fb0ceca5946298c416cec0cca5260c7 diff --git a/src/ServiceContracts/WebContract.php b/src/ServiceContracts/WebContract.php index ddf3b08..d09ef46 100644 --- a/src/ServiceContracts/WebContract.php +++ b/src/ServiceContracts/WebContract.php @@ -239,9 +239,9 @@ public function search( * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. After each scrape, the crawler checks the elapsed time and, if exceeded, returns the pages collected so far instead of continuing. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). * @param list $tags Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. * @param int $timeoutMs Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes). - * @param string $urlRegex Regex pattern. Only URLs matching this pattern will be followed and scraped. + * @param string $urlRegex Regex pattern. Only URLs matching this pattern will be followed and scraped. An automatic prefix scope in the form ^ follows a redirect of the starting page. * @param bool $useMainContentOnly Extract only the main content, stripping headers, footers, sidebars, and navigation - * @param int $waitForMs Optional browser wait time in milliseconds after initial page load for each crawled page. Min: 0. Max: 30000 (30 seconds). + * @param int $waitForMs Browser wait time in milliseconds after initial page load for each crawled page. Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). * @param \ContextDev\Web\WebWebCrawlMdParams\Zdr|value-of<\ContextDev\Web\WebWebCrawlMdParams\Zdr> $zdr Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true. * @param RequestOpts|null $requestOptions * @@ -269,7 +269,7 @@ public function webCrawlMd( ?int $timeoutMs = null, ?string $urlRegex = null, bool $useMainContentOnly = false, - ?int $waitForMs = null, + int $waitForMs = 3500, \ContextDev\Web\WebWebCrawlMdParams\Zdr|string $zdr = 'disabled', RequestOptions|array|null $requestOptions = null, ): WebWebCrawlMdResponse; diff --git a/src/Services/WebService.php b/src/Services/WebService.php index e4a4019..ca137c0 100644 --- a/src/Services/WebService.php +++ b/src/Services/WebService.php @@ -384,9 +384,9 @@ public function search( * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. After each scrape, the crawler checks the elapsed time and, if exceeded, returns the pages collected so far instead of continuing. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). * @param list $tags Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. * @param int $timeoutMs Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes). - * @param string $urlRegex Regex pattern. Only URLs matching this pattern will be followed and scraped. + * @param string $urlRegex Regex pattern. Only URLs matching this pattern will be followed and scraped. An automatic prefix scope in the form ^ follows a redirect of the starting page. * @param bool $useMainContentOnly Extract only the main content, stripping headers, footers, sidebars, and navigation - * @param int $waitForMs Optional browser wait time in milliseconds after initial page load for each crawled page. Min: 0. Max: 30000 (30 seconds). + * @param int $waitForMs Browser wait time in milliseconds after initial page load for each crawled page. Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). * @param \ContextDev\Web\WebWebCrawlMdParams\Zdr|value-of<\ContextDev\Web\WebWebCrawlMdParams\Zdr> $zdr Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true. * @param RequestOpts|null $requestOptions * @@ -414,7 +414,7 @@ public function webCrawlMd( ?int $timeoutMs = null, ?string $urlRegex = null, bool $useMainContentOnly = false, - ?int $waitForMs = null, + int $waitForMs = 3500, \ContextDev\Web\WebWebCrawlMdParams\Zdr|string $zdr = 'disabled', RequestOptions|array|null $requestOptions = null, ): WebWebCrawlMdResponse { diff --git a/src/Web/WebWebCrawlMdParams.php b/src/Web/WebWebCrawlMdParams.php index 316c3e5..5979957 100644 --- a/src/Web/WebWebCrawlMdParams.php +++ b/src/Web/WebWebCrawlMdParams.php @@ -161,7 +161,7 @@ final class WebWebCrawlMdParams implements BaseModel public ?int $timeoutMs; /** - * Regex pattern. Only URLs matching this pattern will be followed and scraped. + * Regex pattern. Only URLs matching this pattern will be followed and scraped. An automatic prefix scope in the form ^ follows a redirect of the starting page. */ #[Optional] public ?string $urlRegex; @@ -173,7 +173,7 @@ final class WebWebCrawlMdParams implements BaseModel public ?bool $useMainContentOnly; /** - * Optional browser wait time in milliseconds after initial page load for each crawled page. Min: 0. Max: 30000 (30 seconds). + * Browser wait time in milliseconds after initial page load for each crawled page. Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). */ #[Optional] public ?int $waitForMs; @@ -466,7 +466,7 @@ public function withTimeoutMs(int $timeoutMs): self } /** - * Regex pattern. Only URLs matching this pattern will be followed and scraped. + * Regex pattern. Only URLs matching this pattern will be followed and scraped. An automatic prefix scope in the form ^ follows a redirect of the starting page. */ public function withURLRegex(string $urlRegex): self { @@ -488,7 +488,7 @@ public function withUseMainContentOnly(bool $useMainContentOnly): self } /** - * Optional browser wait time in milliseconds after initial page load for each crawled page. Min: 0. Max: 30000 (30 seconds). + * Browser wait time in milliseconds after initial page load for each crawled page. Defaults to 3500 (3.5 seconds). Min: 0. Max: 30000 (30 seconds). */ public function withWaitForMs(int $waitForMs): self { From 28f1d2042669e3c13d22deb6af421cbeff82b9e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Aug 2026 07:22:11 +0000 Subject: [PATCH 5/7] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 44d1600..e115f20 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-d4c568ebc1a0f853b02c55ba800c7d7b66189bc6dd22c3cb565a81361c832e2b.yml -openapi_spec_hash: 9a0ecdc06874eee29a3a58a699923405 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-7e6b2353ee8631f506bd8ef7657f1684cddf84805c01d89c691d7f98c42127f7.yml +openapi_spec_hash: b63b980d90fc9c2b896b2739a8e15a59 config_hash: 0fb0ceca5946298c416cec0cca5260c7 From 251478ecc8e0ea5db2ce136aa9c78b84b775543c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Aug 2026 10:55:04 +0000 Subject: [PATCH 6/7] feat(api): api update --- .stats.yml | 4 +- src/AI/AIExtractProductResponse/Product.php | 72 ++++++++ .../Product/Availability.php | 25 +++ src/AI/AIExtractProductsResponse/Product.php | 72 ++++++++ .../Product/Availability.php | 25 +++ src/ServiceContracts/WebContract.php | 19 +- src/Services/WebRawService.php | 14 +- src/Services/WebService.php | 20 ++- src/Web/WebExtractParams.php | 36 +++- src/Web/WebExtractParams/Action.php | 41 +++++ .../Action/WebScrapePerformAction.php | 79 ++++++++ .../Action/WebScrapeWaitAction.php | 79 ++++++++ src/Web/WebExtractResponse/Metadata.php | 31 ++++ .../Metadata/ActionsApplied.php | 170 ++++++++++++++++++ .../Metadata/ActionsApplied/Status.php | 17 ++ tests/Services/WebTest.php | 1 + 16 files changed, 677 insertions(+), 28 deletions(-) create mode 100644 src/AI/AIExtractProductResponse/Product/Availability.php create mode 100644 src/AI/AIExtractProductsResponse/Product/Availability.php create mode 100644 src/Web/WebExtractParams/Action.php create mode 100644 src/Web/WebExtractParams/Action/WebScrapePerformAction.php create mode 100644 src/Web/WebExtractParams/Action/WebScrapeWaitAction.php create mode 100644 src/Web/WebExtractResponse/Metadata/ActionsApplied.php create mode 100644 src/Web/WebExtractResponse/Metadata/ActionsApplied/Status.php diff --git a/.stats.yml b/.stats.yml index e115f20..4aa99bd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-7e6b2353ee8631f506bd8ef7657f1684cddf84805c01d89c691d7f98c42127f7.yml -openapi_spec_hash: b63b980d90fc9c2b896b2739a8e15a59 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-bf7ffa610bd4a02ea5bcb157521d17a041a48f78d87bf8fe8d812d3cbb87b489.yml +openapi_spec_hash: 90142d96969dea44c46a01abb683c426 config_hash: 0fb0ceca5946298c416cec0cca5260c7 diff --git a/src/AI/AIExtractProductResponse/Product.php b/src/AI/AIExtractProductResponse/Product.php index 5aa9310..be85873 100644 --- a/src/AI/AIExtractProductResponse/Product.php +++ b/src/AI/AIExtractProductResponse/Product.php @@ -4,6 +4,7 @@ namespace ContextDev\AI\AIExtractProductResponse; +use ContextDev\AI\AIExtractProductResponse\Product\Availability; use ContextDev\AI\AIExtractProductResponse\Product\BillingFrequency; use ContextDev\AI\AIExtractProductResponse\Product\PricingModel; use ContextDev\Core\Attributes\Optional; @@ -22,12 +23,15 @@ * sku: string|null, * tags: list, * targetAudience: list, + * availability?: null|Availability|value-of, * billingFrequency?: null|BillingFrequency|value-of, * category?: string|null, * currency?: string|null, + * dimensions?: list|null, * imageURL?: string|null, * price?: float|null, * pricingModel?: null|PricingModel|value-of, + * regularPrice?: float|null, * url?: string|null, * } */ @@ -86,6 +90,14 @@ final class Product implements BaseModel #[Required('target_audience', list: 'string')] public array $targetAudience; + /** + * Normalized stock or ordering availability. + * + * @var value-of|null $availability + */ + #[Optional(enum: Availability::class, nullable: true)] + public ?string $availability; + /** * Billing frequency for the product. * @@ -110,6 +122,14 @@ enum: BillingFrequency::class, #[Optional(nullable: true)] public ?string $currency; + /** + * Dimension statements shown for the product, preserving labels, values, and units. + * + * @var list|null $dimensions + */ + #[Optional(list: 'string')] + public ?array $dimensions; + /** * URL to the product image. */ @@ -130,6 +150,12 @@ enum: BillingFrequency::class, #[Optional('pricing_model', enum: PricingModel::class, nullable: true)] public ?string $pricingModel; + /** + * Original or regular price before a displayed discount. + */ + #[Optional('regular_price', nullable: true)] + public ?float $regularPrice; + /** * URL to the product page. */ @@ -179,7 +205,9 @@ public function __construct() * @param list $images * @param list $tags * @param list $targetAudience + * @param Availability|value-of|null $availability * @param BillingFrequency|value-of|null $billingFrequency + * @param list|null $dimensions * @param PricingModel|value-of|null $pricingModel */ public static function with( @@ -190,12 +218,15 @@ public static function with( ?string $sku, array $tags, array $targetAudience, + Availability|string|null $availability = null, BillingFrequency|string|null $billingFrequency = null, ?string $category = null, ?string $currency = null, + ?array $dimensions = null, ?string $imageURL = null, ?float $price = null, PricingModel|string|null $pricingModel = null, + ?float $regularPrice = null, ?string $url = null, ): self { $self = new self; @@ -208,12 +239,15 @@ public static function with( $self['tags'] = $tags; $self['targetAudience'] = $targetAudience; + null !== $availability && $self['availability'] = $availability; null !== $billingFrequency && $self['billingFrequency'] = $billingFrequency; null !== $category && $self['category'] = $category; null !== $currency && $self['currency'] = $currency; + null !== $dimensions && $self['dimensions'] = $dimensions; null !== $imageURL && $self['imageURL'] = $imageURL; null !== $price && $self['price'] = $price; null !== $pricingModel && $self['pricingModel'] = $pricingModel; + null !== $regularPrice && $self['regularPrice'] = $regularPrice; null !== $url && $self['url'] = $url; return $self; @@ -304,6 +338,20 @@ public function withTargetAudience(array $targetAudience): self return $self; } + /** + * Normalized stock or ordering availability. + * + * @param Availability|value-of|null $availability + */ + public function withAvailability( + Availability|string|null $availability + ): self { + $self = clone $this; + $self['availability'] = $availability; + + return $self; + } + /** * Billing frequency for the product. * @@ -340,6 +388,19 @@ public function withCurrency(?string $currency): self return $self; } + /** + * Dimension statements shown for the product, preserving labels, values, and units. + * + * @param list $dimensions + */ + public function withDimensions(array $dimensions): self + { + $self = clone $this; + $self['dimensions'] = $dimensions; + + return $self; + } + /** * URL to the product image. */ @@ -376,6 +437,17 @@ public function withPricingModel( return $self; } + /** + * Original or regular price before a displayed discount. + */ + public function withRegularPrice(?float $regularPrice): self + { + $self = clone $this; + $self['regularPrice'] = $regularPrice; + + return $self; + } + /** * URL to the product page. */ diff --git a/src/AI/AIExtractProductResponse/Product/Availability.php b/src/AI/AIExtractProductResponse/Product/Availability.php new file mode 100644 index 0000000..da8e62e --- /dev/null +++ b/src/AI/AIExtractProductResponse/Product/Availability.php @@ -0,0 +1,25 @@ +, * targetAudience: list, + * availability?: null|Availability|value-of, * billingFrequency?: null|BillingFrequency|value-of, * category?: string|null, * currency?: string|null, + * dimensions?: list|null, * imageURL?: string|null, * price?: float|null, * pricingModel?: null|PricingModel|value-of, + * regularPrice?: float|null, * url?: string|null, * } */ @@ -84,6 +88,14 @@ final class Product implements BaseModel #[Required('target_audience', list: 'string')] public array $targetAudience; + /** + * Normalized stock or ordering availability. + * + * @var value-of|null $availability + */ + #[Optional(enum: Availability::class, nullable: true)] + public ?string $availability; + /** * Billing frequency for the product. * @@ -108,6 +120,14 @@ enum: BillingFrequency::class, #[Optional(nullable: true)] public ?string $currency; + /** + * Dimension statements shown for the product, preserving labels, values, and units. + * + * @var list|null $dimensions + */ + #[Optional(list: 'string')] + public ?array $dimensions; + /** * URL to the product image. */ @@ -128,6 +148,12 @@ enum: BillingFrequency::class, #[Optional('pricing_model', enum: PricingModel::class, nullable: true)] public ?string $pricingModel; + /** + * Original or regular price before a displayed discount. + */ + #[Optional('regular_price', nullable: true)] + public ?float $regularPrice; + /** * URL to the product page. */ @@ -177,7 +203,9 @@ public function __construct() * @param list $images * @param list $tags * @param list $targetAudience + * @param Availability|value-of|null $availability * @param BillingFrequency|value-of|null $billingFrequency + * @param list|null $dimensions * @param PricingModel|value-of|null $pricingModel */ public static function with( @@ -188,12 +216,15 @@ public static function with( ?string $sku, array $tags, array $targetAudience, + Availability|string|null $availability = null, BillingFrequency|string|null $billingFrequency = null, ?string $category = null, ?string $currency = null, + ?array $dimensions = null, ?string $imageURL = null, ?float $price = null, PricingModel|string|null $pricingModel = null, + ?float $regularPrice = null, ?string $url = null, ): self { $self = new self; @@ -206,12 +237,15 @@ public static function with( $self['tags'] = $tags; $self['targetAudience'] = $targetAudience; + null !== $availability && $self['availability'] = $availability; null !== $billingFrequency && $self['billingFrequency'] = $billingFrequency; null !== $category && $self['category'] = $category; null !== $currency && $self['currency'] = $currency; + null !== $dimensions && $self['dimensions'] = $dimensions; null !== $imageURL && $self['imageURL'] = $imageURL; null !== $price && $self['price'] = $price; null !== $pricingModel && $self['pricingModel'] = $pricingModel; + null !== $regularPrice && $self['regularPrice'] = $regularPrice; null !== $url && $self['url'] = $url; return $self; @@ -302,6 +336,20 @@ public function withTargetAudience(array $targetAudience): self return $self; } + /** + * Normalized stock or ordering availability. + * + * @param Availability|value-of|null $availability + */ + public function withAvailability( + Availability|string|null $availability + ): self { + $self = clone $this; + $self['availability'] = $availability; + + return $self; + } + /** * Billing frequency for the product. * @@ -338,6 +386,19 @@ public function withCurrency(?string $currency): self return $self; } + /** + * Dimension statements shown for the product, preserving labels, values, and units. + * + * @param list $dimensions + */ + public function withDimensions(array $dimensions): self + { + $self = clone $this; + $self['dimensions'] = $dimensions; + + return $self; + } + /** * URL to the product image. */ @@ -374,6 +435,17 @@ public function withPricingModel( return $self; } + /** + * Original or regular price before a displayed discount. + */ + public function withRegularPrice(?float $regularPrice): self + { + $self = clone $this; + $self['regularPrice'] = $regularPrice; + + return $self; + } + /** * URL to the product page. */ diff --git a/src/AI/AIExtractProductsResponse/Product/Availability.php b/src/AI/AIExtractProductsResponse/Product/Availability.php new file mode 100644 index 0000000..f1ce214 --- /dev/null +++ b/src/AI/AIExtractProductsResponse/Product/Availability.php @@ -0,0 +1,25 @@ + $schema JSON Schema for the returned data object. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. + * @param array $schema JSON Schema for the returned data object. Image fields such as `image_urls` or `product_photos` automatically make page image references available to extraction, so product data and photos can be returned in one call. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. * @param string $url The starting website URL to crawl and extract from. Must include http:// or https://. + * @param list $actions Optional browser actions executed in order on the requested page after it loads and before extraction. Requires a paid plan. When actions are provided and stopAfterMs is omitted, the crawl budget defaults to 110000 ms. * @param bool $factCheck When true, every returned value must be grounded in facts stated on the page; fields that cannot be supported by the page are returned as null/empty. When false (default), the model may make reasonable inferences and derivations from the page content (e.g. ideal customer, competitor analysis, recommendations) while keeping verifiable specifics (names, quotes, URLs, dates, metrics) faithful to the source. * @param bool $followSubdomains when true, follow links on subdomains of the starting URL's domain * @param bool $includeFrames when true, iframe contents are included in Markdown before extraction @@ -57,7 +59,7 @@ interface WebContract * @param int $maxPages Maximum number of pages to analyze for extraction. Hard cap: 50. Defaults to 5. * @param Pdf|PdfShape $pdf * @param bool $settleAnimations When true, waits briefly for CSS and transition animations to settle before extracting each crawled page. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages. - * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). + * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are provided. * @param list $tags Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. * @param int $timeoutMs Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes). * @param int $waitForMs optional browser wait time in milliseconds after initial page load for each crawled page @@ -68,6 +70,7 @@ interface WebContract public function extract( array $schema, string $url, + ?array $actions = null, bool $factCheck = false, bool $followSubdomains = false, bool $includeFrames = false, @@ -278,7 +281,7 @@ public function webCrawlMd( * @api * * @param string $url Full URL to scrape (must include http:// or https:// protocol) - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param \ContextDev\Web\WebWebScrapeHTMLParams\Country|value-of<\ContextDev\Web\WebWebScrapeHTMLParams\Country> $country fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2) * @param list|null $excludeSelectors CSS selectors to remove from the result. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]". * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. @@ -321,7 +324,7 @@ public function webScrapeHTML( * @api * * @param string $url Page URL to inspect. Must include http:// or https://. - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param bool $dedupe When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false. * @param Enrichment|EnrichmentShape|null $enrichment optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. @@ -350,7 +353,7 @@ public function webScrapeImages( * @api * * @param string $url Full URL to scrape into LLM usable Markdown (must include http:// or https:// protocol) - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param \ContextDev\Web\WebWebScrapeMdParams\Country|value-of<\ContextDev\Web\WebWebScrapeMdParams\Country> $country fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2) * @param list|null $excludeSelectors CSS selectors to remove before conversion to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]". * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. diff --git a/src/Services/WebRawService.php b/src/Services/WebRawService.php index 12cb21d..f035990 100644 --- a/src/Services/WebRawService.php +++ b/src/Services/WebRawService.php @@ -44,15 +44,16 @@ use ContextDev\Web\WebWebScrapeSitemapResponse; /** + * @phpstan-import-type ActionShape from \ContextDev\Web\WebExtractParams\Action * @phpstan-import-type PdfShape from \ContextDev\Web\WebExtractParams\Pdf * @phpstan-import-type ViewportShape from \ContextDev\Web\WebScreenshotParams\Viewport * @phpstan-import-type MarkdownOptionsShape from \ContextDev\Web\WebSearchParams\MarkdownOptions * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebCrawlMdParams\Pdf as PdfShape1 - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeHTMLParams\Action + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeHTMLParams\Action as ActionShape1 * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebScrapeHTMLParams\Pdf as PdfShape2 - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeImagesParams\Action as ActionShape1 + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeImagesParams\Action as ActionShape2 * @phpstan-import-type EnrichmentShape from \ContextDev\Web\WebWebScrapeImagesParams\Enrichment - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeMdParams\Action as ActionShape2 + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeMdParams\Action as ActionShape3 * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebScrapeMdParams\Pdf as PdfShape3 * @phpstan-import-type RequestOpts from \ContextDev\RequestOptions */ @@ -72,6 +73,7 @@ public function __construct(private Client $client) {} * @param array{ * schema: array, * url: string, + * actions?: list, * factCheck?: bool, * followSubdomains?: bool, * includeFrames?: bool, @@ -377,7 +379,7 @@ public function webCrawlMd( * * @param array{ * url: string, - * actions?: list|null, + * actions?: list|null, * country?: value-of, * excludeSelectors?: list|null, * headers?: array, @@ -424,7 +426,7 @@ public function webScrapeHTML( * * @param array{ * url: string, - * actions?: list|null, + * actions?: list|null, * dedupe?: bool, * enrichment?: Enrichment|EnrichmentShape|null, * headers?: array, @@ -483,7 +485,7 @@ public function webScrapeImages( * * @param array{ * url: string, - * actions?: list|null, + * actions?: list|null, * country?: value-of, * excludeSelectors?: list|null, * headers?: array, diff --git a/src/Services/WebService.php b/src/Services/WebService.php index ca137c0..737f120 100644 --- a/src/Services/WebService.php +++ b/src/Services/WebService.php @@ -32,15 +32,16 @@ use ContextDev\Web\WebWebScrapeSitemapResponse; /** + * @phpstan-import-type ActionShape from \ContextDev\Web\WebExtractParams\Action * @phpstan-import-type PdfShape from \ContextDev\Web\WebExtractParams\Pdf * @phpstan-import-type ViewportShape from \ContextDev\Web\WebScreenshotParams\Viewport * @phpstan-import-type MarkdownOptionsShape from \ContextDev\Web\WebSearchParams\MarkdownOptions * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebCrawlMdParams\Pdf as PdfShape1 - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeHTMLParams\Action + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeHTMLParams\Action as ActionShape1 * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebScrapeHTMLParams\Pdf as PdfShape2 - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeImagesParams\Action as ActionShape1 + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeImagesParams\Action as ActionShape2 * @phpstan-import-type EnrichmentShape from \ContextDev\Web\WebWebScrapeImagesParams\Enrichment - * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeMdParams\Action as ActionShape2 + * @phpstan-import-type ActionShape from \ContextDev\Web\WebWebScrapeMdParams\Action as ActionShape3 * @phpstan-import-type PdfShape from \ContextDev\Web\WebWebScrapeMdParams\Pdf as PdfShape3 * @phpstan-import-type RequestOpts from \ContextDev\RequestOptions */ @@ -64,8 +65,9 @@ public function __construct(private Client $client) * * Crawl a website, use the provided JSON Schema and instructions to prioritize relevant internal links, and extract structured data from the selected pages. * - * @param array $schema JSON Schema for the returned data object. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. + * @param array $schema JSON Schema for the returned data object. Image fields such as `image_urls` or `product_photos` automatically make page image references available to extraction, so product data and photos can be returned in one call. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. * @param string $url The starting website URL to crawl and extract from. Must include http:// or https://. + * @param list $actions Optional browser actions executed in order on the requested page after it loads and before extraction. Requires a paid plan. When actions are provided and stopAfterMs is omitted, the crawl budget defaults to 110000 ms. * @param bool $factCheck When true, every returned value must be grounded in facts stated on the page; fields that cannot be supported by the page are returned as null/empty. When false (default), the model may make reasonable inferences and derivations from the page content (e.g. ideal customer, competitor analysis, recommendations) while keeping verifiable specifics (names, quotes, URLs, dates, metrics) faithful to the source. * @param bool $followSubdomains when true, follow links on subdomains of the starting URL's domain * @param bool $includeFrames when true, iframe contents are included in Markdown before extraction @@ -75,7 +77,7 @@ public function __construct(private Client $client) * @param int $maxPages Maximum number of pages to analyze for extraction. Hard cap: 50. Defaults to 5. * @param Pdf|PdfShape $pdf * @param bool $settleAnimations When true, waits briefly for CSS and transition animations to settle before extracting each crawled page. Defaults to false. This adds a bit of latency in exchange for more stable output on animated pages. - * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). + * @param int $stopAfterMs Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are provided. * @param list $tags Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. * @param int $timeoutMs Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes). * @param int $waitForMs optional browser wait time in milliseconds after initial page load for each crawled page @@ -86,6 +88,7 @@ public function __construct(private Client $client) public function extract( array $schema, string $url, + ?array $actions = null, bool $factCheck = false, bool $followSubdomains = false, bool $includeFrames = false, @@ -105,6 +108,7 @@ public function extract( [ 'schema' => $schema, 'url' => $url, + 'actions' => $actions, 'factCheck' => $factCheck, 'followSubdomains' => $followSubdomains, 'includeFrames' => $includeFrames, @@ -456,7 +460,7 @@ public function webCrawlMd( * Scrapes the given URL and returns the raw HTML content of the page. The base request costs 1 credit; requests with browser actions cost 2 credits. * * @param string $url Full URL to scrape (must include http:// or https:// protocol) - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param \ContextDev\Web\WebWebScrapeHTMLParams\Country|value-of<\ContextDev\Web\WebWebScrapeHTMLParams\Country> $country fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2) * @param list|null $excludeSelectors CSS selectors to remove from the result. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]". * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. @@ -526,7 +530,7 @@ public function webScrapeHTML( * Extract image assets from a web page, including standard URLs, inline SVGs, data URIs, responsive image sources, metadata, CSS backgrounds, video posters, and embeds. The base request costs 1 credit, or 2 credits with browser actions. When enrichment is enabled, the entire call costs 5 credits, including requests that also use actions. * * @param string $url Page URL to inspect. Must include http:// or https://. - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param bool $dedupe When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false. * @param Enrichment|EnrichmentShape|null $enrichment optional per-image processing, sent as deep-object query params such as enrichment[resolution]=true * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. @@ -594,7 +598,7 @@ public function webScrapeImages( * | 500 | No | Internal error | * * @param string $url Full URL to scrape into LLM usable Markdown (must include http:// or https:// protocol) - * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. + * @param list|null $actions Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions. * @param \ContextDev\Web\WebWebScrapeMdParams\Country|value-of<\ContextDev\Web\WebWebScrapeMdParams\Country> $country fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2) * @param list|null $excludeSelectors CSS selectors to remove before conversion to Markdown. Applied after includeSelectors. Exclusion takes precedence: an element matching both is removed. Examples: "nav", "footer", ".ad-banner", "[aria-hidden=true]". * @param array $headers Optional outbound HTTP headers forwarded only to the target URL, sent as deep-object query params such as headers[X-Custom]=value. When provided, caching is bypassed: the result is neither read from nor written to cache. diff --git a/src/Web/WebExtractParams.php b/src/Web/WebExtractParams.php index 1140f0f..a6f95ce 100644 --- a/src/Web/WebExtractParams.php +++ b/src/Web/WebExtractParams.php @@ -9,6 +9,7 @@ use ContextDev\Core\Concerns\SdkModel; use ContextDev\Core\Concerns\SdkParams; use ContextDev\Core\Contracts\BaseModel; +use ContextDev\Web\WebExtractParams\Action; use ContextDev\Web\WebExtractParams\Pdf; /** @@ -16,11 +17,14 @@ * * @see ContextDev\Services\WebService::extract() * + * @phpstan-import-type ActionVariants from \ContextDev\Web\WebExtractParams\Action + * @phpstan-import-type ActionShape from \ContextDev\Web\WebExtractParams\Action * @phpstan-import-type PdfShape from \ContextDev\Web\WebExtractParams\Pdf * * @phpstan-type WebExtractParamsShape = array{ * schema: array, * url: string, + * actions?: list|null, * factCheck?: bool|null, * followSubdomains?: bool|null, * includeFrames?: bool|null, @@ -43,7 +47,7 @@ final class WebExtractParams implements BaseModel use SdkParams; /** - * JSON Schema for the returned data object. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. + * JSON Schema for the returned data object. Image fields such as `image_urls` or `product_photos` automatically make page image references available to extraction, so product data and photos can be returned in one call. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. * * @var array $schema */ @@ -56,6 +60,14 @@ final class WebExtractParams implements BaseModel #[Required] public string $url; + /** + * Optional browser actions executed in order on the requested page after it loads and before extraction. Requires a paid plan. When actions are provided and stopAfterMs is omitted, the crawl budget defaults to 110000 ms. + * + * @var list|null $actions + */ + #[Optional(list: Action::class)] + public ?array $actions; + /** * When true, every returned value must be grounded in facts stated on the page; fields that cannot be supported by the page are returned as null/empty. When false (default), the model may make reasonable inferences and derivations from the page content (e.g. ideal customer, competitor analysis, recommendations) while keeping verifiable specifics (names, quotes, URLs, dates, metrics) faithful to the source. */ @@ -108,7 +120,7 @@ final class WebExtractParams implements BaseModel public ?bool $settleAnimations; /** - * Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). + * Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are provided. */ #[Optional] public ?int $stopAfterMs; @@ -158,12 +170,14 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param array $schema + * @param list|null $actions * @param Pdf|PdfShape|null $pdf * @param list|null $tags */ public static function with( array $schema, string $url, + ?array $actions = null, ?bool $factCheck = null, ?bool $followSubdomains = null, ?bool $includeFrames = null, @@ -183,6 +197,7 @@ public static function with( $self['schema'] = $schema; $self['url'] = $url; + null !== $actions && $self['actions'] = $actions; null !== $factCheck && $self['factCheck'] = $factCheck; null !== $followSubdomains && $self['followSubdomains'] = $followSubdomains; null !== $includeFrames && $self['includeFrames'] = $includeFrames; @@ -201,7 +216,7 @@ public static function with( } /** - * JSON Schema for the returned data object. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. + * JSON Schema for the returned data object. Image fields such as `image_urls` or `product_photos` automatically make page image references available to extraction, so product data and photos can be returned in one call. TypeScript Zod users can pass a JSON Schema generated from a Zod object; Python users can pass the equivalent JSON Schema object. * * @param array $schema */ @@ -224,6 +239,19 @@ public function withURL(string $url): self return $self; } + /** + * Optional browser actions executed in order on the requested page after it loads and before extraction. Requires a paid plan. When actions are provided and stopAfterMs is omitted, the crawl budget defaults to 110000 ms. + * + * @param list $actions + */ + public function withActions(array $actions): self + { + $self = clone $this; + $self['actions'] = $actions; + + return $self; + } + /** * When true, every returned value must be grounded in facts stated on the page; fields that cannot be supported by the page are returned as null/empty. When false (default), the model may make reasonable inferences and derivations from the page content (e.g. ideal customer, competitor analysis, recommendations) while keeping verifiable specifics (names, quotes, URLs, dates, metrics) faithful to the source. */ @@ -324,7 +352,7 @@ public function withSettleAnimations(bool $settleAnimations): self } /** - * Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Default: 80000 (80s). + * Soft time budget for the crawl in milliseconds. Min: 10000 (10s). Max: 110000 (110s). Defaults to 80000 (80s), or 110000 (110s) when browser actions are provided. */ public function withStopAfterMs(int $stopAfterMs): self { diff --git a/src/Web/WebExtractParams/Action.php b/src/Web/WebExtractParams/Action.php new file mode 100644 index 0000000..c5434e7 --- /dev/null +++ b/src/Web/WebExtractParams/Action.php @@ -0,0 +1,41 @@ +|array + */ + public static function variants(): array + { + return [ + 'wait' => WebScrapeWaitAction::class, + 'perform' => WebScrapePerformAction::class, + ]; + } +} diff --git a/src/Web/WebExtractParams/Action/WebScrapePerformAction.php b/src/Web/WebExtractParams/Action/WebScrapePerformAction.php new file mode 100644 index 0000000..33eb7a1 --- /dev/null +++ b/src/Web/WebExtractParams/Action/WebScrapePerformAction.php @@ -0,0 +1,79 @@ + */ + use SdkModel; + + /** @var 'perform' $do */ + #[Required] + public string $do = 'perform'; + + #[Required] + public string $action; + + /** + * `new WebScrapePerformAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebScrapePerformAction::with(action: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebScrapePerformAction)->withAction(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(string $action): self + { + $self = new self; + + $self['action'] = $action; + + return $self; + } + + public function withAction(string $action): self + { + $self = clone $this; + $self['action'] = $action; + + return $self; + } + + /** + * @param 'perform' $do + */ + public function withDo(string $do): self + { + $self = clone $this; + $self['do'] = $do; + + return $self; + } +} diff --git a/src/Web/WebExtractParams/Action/WebScrapeWaitAction.php b/src/Web/WebExtractParams/Action/WebScrapeWaitAction.php new file mode 100644 index 0000000..1b93ad6 --- /dev/null +++ b/src/Web/WebExtractParams/Action/WebScrapeWaitAction.php @@ -0,0 +1,79 @@ + */ + use SdkModel; + + /** @var 'wait' $do */ + #[Required] + public string $do = 'wait'; + + #[Required] + public int $timeMs; + + /** + * `new WebScrapeWaitAction()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * WebScrapeWaitAction::with(timeMs: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new WebScrapeWaitAction)->withTimeMs(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $timeMs): self + { + $self = new self; + + $self['timeMs'] = $timeMs; + + return $self; + } + + /** + * @param 'wait' $do + */ + public function withDo(string $do): self + { + $self = clone $this; + $self['do'] = $do; + + return $self; + } + + public function withTimeMs(int $timeMs): self + { + $self = clone $this; + $self['timeMs'] = $timeMs; + + return $self; + } +} diff --git a/src/Web/WebExtractResponse/Metadata.php b/src/Web/WebExtractResponse/Metadata.php index 35b923d..56dd6da 100644 --- a/src/Web/WebExtractResponse/Metadata.php +++ b/src/Web/WebExtractResponse/Metadata.php @@ -4,11 +4,15 @@ namespace ContextDev\Web\WebExtractResponse; +use ContextDev\Core\Attributes\Optional; use ContextDev\Core\Attributes\Required; use ContextDev\Core\Concerns\SdkModel; use ContextDev\Core\Contracts\BaseModel; +use ContextDev\Web\WebExtractResponse\Metadata\ActionsApplied; /** + * @phpstan-import-type ActionsAppliedShape from \ContextDev\Web\WebExtractResponse\Metadata\ActionsApplied + * * @phpstan-type MetadataShape = array{ * maxCrawlDepth: int, * numBlocked: int, @@ -16,6 +20,7 @@ * numSkipped: int, * numSucceeded: int, * numURLs: int, + * actionsApplied?: list|null, * } */ final class Metadata implements BaseModel @@ -44,6 +49,14 @@ final class Metadata implements BaseModel #[Required('numUrls')] public int $numURLs; + /** + * One verified outcome per requested browser action, in request order. + * + * @var list|null $actionsApplied + */ + #[Optional(list: ActionsApplied::class)] + public ?array $actionsApplied; + /** * `new Metadata()` is missing required properties by the API. * @@ -80,6 +93,8 @@ public function __construct() * Construct an instance from the required parameters. * * You must use named parameters to construct any parameters with a default value. + * + * @param list|null $actionsApplied */ public static function with( int $maxCrawlDepth, @@ -88,6 +103,7 @@ public static function with( int $numSkipped, int $numSucceeded, int $numURLs, + ?array $actionsApplied = null, ): self { $self = new self; @@ -98,6 +114,8 @@ public static function with( $self['numSucceeded'] = $numSucceeded; $self['numURLs'] = $numURLs; + null !== $actionsApplied && $self['actionsApplied'] = $actionsApplied; + return $self; } @@ -151,4 +169,17 @@ public function withNumURLs(int $numURLs): self return $self; } + + /** + * One verified outcome per requested browser action, in request order. + * + * @param list $actionsApplied + */ + public function withActionsApplied(array $actionsApplied): self + { + $self = clone $this; + $self['actionsApplied'] = $actionsApplied; + + return $self; + } } diff --git a/src/Web/WebExtractResponse/Metadata/ActionsApplied.php b/src/Web/WebExtractResponse/Metadata/ActionsApplied.php new file mode 100644 index 0000000..17e71de --- /dev/null +++ b/src/Web/WebExtractResponse/Metadata/ActionsApplied.php @@ -0,0 +1,170 @@ +, + * completionEvidence?: string|null, + * durationMs?: float|null, + * error?: string|null, + * method?: string|null, + * targetDescription?: string|null, + * } + */ +final class ActionsApplied implements BaseModel +{ + /** @use SdkModel */ + use SdkModel; + + #[Required] + public string $instruction; + + /** + * Applied means the requested page state was visibly verified. Failed means it was not verified. Skipped means it was not attempted. + * + * @var value-of $status + */ + #[Required(enum: Status::class)] + public string $status; + + /** + * Visible page evidence used to verify an applied action. + */ + #[Optional] + public ?string $completionEvidence; + + #[Optional] + public ?float $durationMs; + + #[Optional] + public ?string $error; + + #[Optional] + public ?string $method; + + #[Optional] + public ?string $targetDescription; + + /** + * `new ActionsApplied()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * ActionsApplied::with(instruction: ..., status: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new ActionsApplied)->withInstruction(...)->withStatus(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + * + * @param Status|value-of $status + */ + public static function with( + string $instruction, + Status|string $status, + ?string $completionEvidence = null, + ?float $durationMs = null, + ?string $error = null, + ?string $method = null, + ?string $targetDescription = null, + ): self { + $self = new self; + + $self['instruction'] = $instruction; + $self['status'] = $status; + + null !== $completionEvidence && $self['completionEvidence'] = $completionEvidence; + null !== $durationMs && $self['durationMs'] = $durationMs; + null !== $error && $self['error'] = $error; + null !== $method && $self['method'] = $method; + null !== $targetDescription && $self['targetDescription'] = $targetDescription; + + return $self; + } + + public function withInstruction(string $instruction): self + { + $self = clone $this; + $self['instruction'] = $instruction; + + return $self; + } + + /** + * Applied means the requested page state was visibly verified. Failed means it was not verified. Skipped means it was not attempted. + * + * @param Status|value-of $status + */ + public function withStatus(Status|string $status): self + { + $self = clone $this; + $self['status'] = $status; + + return $self; + } + + /** + * Visible page evidence used to verify an applied action. + */ + public function withCompletionEvidence(string $completionEvidence): self + { + $self = clone $this; + $self['completionEvidence'] = $completionEvidence; + + return $self; + } + + public function withDurationMs(float $durationMs): self + { + $self = clone $this; + $self['durationMs'] = $durationMs; + + return $self; + } + + public function withError(string $error): self + { + $self = clone $this; + $self['error'] = $error; + + return $self; + } + + public function withMethod(string $method): self + { + $self = clone $this; + $self['method'] = $method; + + return $self; + } + + public function withTargetDescription(string $targetDescription): self + { + $self = clone $this; + $self['targetDescription'] = $targetDescription; + + return $self; + } +} diff --git a/src/Web/WebExtractResponse/Metadata/ActionsApplied/Status.php b/src/Web/WebExtractResponse/Metadata/ActionsApplied/Status.php new file mode 100644 index 0000000..18c133c --- /dev/null +++ b/src/Web/WebExtractResponse/Metadata/ActionsApplied/Status.php @@ -0,0 +1,17 @@ + 'bar', ], url: 'https://example.com', + actions: [['do' => 'wait', 'timeMs' => 0]], factCheck: true, followSubdomains: true, includeFrames: true, From 5aba734ad8037516545acbf58cbd203905d512b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Aug 2026 10:55:32 +0000 Subject: [PATCH 7/7] release: 2.12.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- src/Version.php | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e6c39ad..0746cbe 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.11.0" + ".": "2.12.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e27ef3e..173a508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 2.12.0 (2026-08-21) + +Full Changelog: [v2.11.0...v2.12.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.11.0...v2.12.0) + +### Features + +* **api:** api update ([251478e](https://github.com/context-dot-dev/context-php-sdk/commit/251478ecc8e0ea5db2ce136aa9c78b84b775543c)) +* **api:** api update ([84e2387](https://github.com/context-dot-dev/context-php-sdk/commit/84e23875b946b62c378ddd8f4f3c70c76e3bba47)) +* **api:** api update ([3dbbac2](https://github.com/context-dot-dev/context-php-sdk/commit/3dbbac273b81d666b1dc7584e125bd5ce0ba3d9a)) + ## 2.11.0 (2026-08-18) Full Changelog: [v2.10.0...v2.11.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.10.0...v2.11.0) diff --git a/README.md b/README.md index e315b06..be5e105 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The REST API documentation can be found on [docs.context.dev](https://docs.conte ``` -composer require "context-dev/context-dev-php 2.11.0" +composer require "context-dev/context-dev-php 2.12.0" ``` diff --git a/src/Version.php b/src/Version.php index 41b0b98..500f4fa 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace ContextDev; // x-release-please-start-version -const VERSION = '2.11.0'; +const VERSION = '2.12.0'; // x-release-please-end