Skip to content

Commit 7ea4904

Browse files
feat(client): support raw responses
1 parent 5e8ce6f commit 7ea4904

35 files changed

+159
-53
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Scrapegraphai\Core\Implementation;
4+
5+
use Psr\Http\Message\ResponseInterface;
6+
7+
class HasRawResponse
8+
{
9+
public ResponseInterface $rawResponse;
10+
}

src/Crawl/CrawlGetResultsResponse.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212

1313
/**
1414
* @phpstan-type crawl_get_results_response = array{
15-
* result?: mixed|string|null,
16-
* status?: value-of<Status>|null,
17-
* taskID?: string|null,
15+
* result?: mixed|string,
16+
* status?: value-of<Status>,
17+
* taskID?: string,
1818
* traceback?: string|null,
1919
* }
20+
* When used in a response, this type parameter can be used to define a $rawResponse property.
21+
* @template TRawResponse of object = object{}
22+
*
23+
* @mixin TRawResponse
2024
*/
2125
final class CrawlGetResultsResponse implements BaseModel
2226
{

src/Crawl/CrawlStartParams/Rules.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
use Scrapegraphai\Core\Contracts\BaseModel;
1010

1111
/**
12-
* @phpstan-type rules_alias = array{
13-
* exclude?: list<string>|null, sameDomain?: bool|null
14-
* }
12+
* @phpstan-type rules_alias = array{exclude?: list<string>, sameDomain?: bool}
1513
*/
1614
final class Rules implements BaseModel
1715
{

src/Crawl/CrawlStartResponse.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
use Scrapegraphai\Core\Contracts\BaseModel;
1010

1111
/**
12-
* @phpstan-type crawl_start_response = array{taskID?: string|null}
12+
* @phpstan-type crawl_start_response = array{taskID?: string}
13+
* When used in a response, this type parameter can be used to define a $rawResponse property.
14+
* @template TRawResponse of object = object{}
15+
*
16+
* @mixin TRawResponse
1317
*/
1418
final class CrawlStartResponse implements BaseModel
1519
{

src/Credits/CreditGetResponse.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
/**
1212
* @phpstan-type credit_get_response = array{
13-
* remainingCredits?: int|null, totalCreditsUsed?: int|null
13+
* remainingCredits?: int, totalCreditsUsed?: int
1414
* }
15+
* When used in a response, this type parameter can be used to define a $rawResponse property.
16+
* @template TRawResponse of object = object{}
17+
*
18+
* @mixin TRawResponse
1519
*/
1620
final class CreditGetResponse implements BaseModel
1721
{

src/Feedback/FeedbackSubmitResponse.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010

1111
/**
1212
* @phpstan-type feedback_submit_response = array{
13-
* feedbackID?: string|null,
14-
* feedbackTimestamp?: \DateTimeInterface|null,
15-
* message?: string|null,
16-
* requestID?: string|null,
13+
* feedbackID?: string,
14+
* feedbackTimestamp?: \DateTimeInterface,
15+
* message?: string,
16+
* requestID?: string,
1717
* }
18+
* When used in a response, this type parameter can be used to define a $rawResponse property.
19+
* @template TRawResponse of object = object{}
20+
*
21+
* @mixin TRawResponse
1822
*/
1923
final class FeedbackSubmitResponse implements BaseModel
2024
{

src/GenerateSchema/GenerateSchemaGetResponse/CompletedSchemaGenerationResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* @phpstan-type completed_schema_generation_response = array{
1414
* error?: string|null,
1515
* generatedSchema?: mixed,
16-
* refinedPrompt?: string|null,
17-
* requestID?: string|null,
18-
* status?: value-of<Status>|null,
19-
* userPrompt?: string|null,
16+
* refinedPrompt?: string,
17+
* requestID?: string,
18+
* status?: value-of<Status>,
19+
* userPrompt?: string,
2020
* }
2121
*/
2222
final class CompletedSchemaGenerationResponse implements BaseModel

src/GenerateSchema/GenerateSchemaGetResponse/FailedSchemaGenerationResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
/**
1313
* @phpstan-type failed_schema_generation_response = array{
14-
* error?: string|null,
14+
* error?: string,
1515
* generatedSchema?: mixed,
1616
* refinedPrompt?: string|null,
17-
* requestID?: string|null,
18-
* status?: value-of<Status>|null,
19-
* userPrompt?: string|null,
17+
* requestID?: string,
18+
* status?: value-of<Status>,
19+
* userPrompt?: string,
2020
* }
2121
*/
2222
final class FailedSchemaGenerationResponse implements BaseModel

src/GenerateSchema/GenerateSchemaNewResponse.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
* @phpstan-type generate_schema_new_response = array{
1414
* error?: string|null,
1515
* generatedSchema?: mixed,
16-
* refinedPrompt?: string|null,
17-
* requestID?: string|null,
18-
* status?: value-of<Status>|null,
19-
* userPrompt?: string|null,
16+
* refinedPrompt?: string,
17+
* requestID?: string,
18+
* status?: value-of<Status>,
19+
* userPrompt?: string,
2020
* }
21+
* When used in a response, this type parameter can be used to define a $rawResponse property.
22+
* @template TRawResponse of object = object{}
23+
*
24+
* @mixin TRawResponse
2125
*/
2226
final class GenerateSchemaNewResponse implements BaseModel
2327
{

src/Healthz/HealthzCheckResponse.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
/**
1212
* @phpstan-type healthz_check_response = array{
13-
* services?: array<string, string>|null, status?: string|null
13+
* services?: array<string, string>, status?: string
1414
* }
15+
* When used in a response, this type parameter can be used to define a $rawResponse property.
16+
* @template TRawResponse of object = object{}
17+
*
18+
* @mixin TRawResponse
1519
*/
1620
final class HealthzCheckResponse implements BaseModel
1721
{

0 commit comments

Comments
 (0)