Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/dedalus-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
Expand All @@ -37,7 +37,7 @@ jobs:
test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/dedalus-php' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.0.1"
".": "0.1.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 32
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs/dedalus-5d397081e492cd0e3832b7065574c06c90a67312c1c4caed119aa6c7c53c4d28.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/dedalus-labs/dedalus-32ccb3c17674e0ee68fd6eafbdd0f210bccfd09fce0702e28b8278e06678deec.yml
openapi_spec_hash: ccb02923079d91569a17162c88da590b
config_hash: f3b61260a0c9a88977fb5fc3b355047b
config_hash: 3b16603a18779d453842a0d56638384d
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

## 0.1.0 (2026-08-13)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/dedalus-labs/dedalus-php/compare/v0.0.1...v0.1.0)

### Features

* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([48c5677](https://github.com/dedalus-labs/dedalus-php/commit/48c5677ac159ea532a57f208a8f5c6bfe127622c))


### Chores

* configure new SDK language ([7b4e6e9](https://github.com/dedalus-labs/dedalus-php/commit/7b4e6e9a997cc2781f9411e51777a3c346146638))
* **internal:** codegen related update ([1a8768a](https://github.com/dedalus-labs/dedalus-php/commit/1a8768a0bc95b52c4f056c99f6265b1bda4e2210))
* update SDK settings ([93dd383](https://github.com/dedalus-labs/dedalus-php/commit/93dd383df792db94c595c14e2927cb47b6bf8904))
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ The REST API documentation can be found on [docs.dedaluslabs.ai](https://docs.de

To use this package, install via Composer by adding the following to your application's `composer.json`:

<!-- x-release-please-start-version -->

```json
{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:stainless-sdks/dedalus-php.git"
"url": "git@github.com:dedalus-labs/dedalus-php.git"
}
],
"require": {
Expand All @@ -26,6 +28,8 @@ To use this package, install via Composer by adding the following to your applic
}
```

<!-- x-release-please-end -->

## Usage

This library uses named parameters to specify optional arguments.
Expand Down Expand Up @@ -225,4 +229,4 @@ PHP 8.1.0 or higher.

## Contributing

See [the contributing documentation](https://github.com/stainless-sdks/dedalus-php/tree/main/CONTRIBUTING.md).
See [the contributing documentation](https://github.com/dedalus-labs/dedalus-php/tree/main/CONTRIBUTING.md).
9 changes: 8 additions & 1 deletion src/Core/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Dedalus\Core\Exceptions\APIConnectionException;
use Dedalus\Core\Exceptions\APIStatusException;
use Dedalus\Core\Implementation\RawResponse;
use Dedalus\Core\Implementation\StreamingHttpClient;
use Dedalus\RequestOptions;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
Expand Down Expand Up @@ -249,7 +250,13 @@ protected function sendRequest(
$err = null;

try {
$rsp = $transporter->sendRequest($req);
if ($transporter instanceof StreamingHttpClient) {
$rsp = $transporter->sendRequest($req, timeout: $opts->timeout);
} elseif (is_a($transporter, '\GuzzleHttp\Client')) {
$rsp = $transporter->send($req, ['timeout' => $opts->timeout]);
} else {
$rsp = $transporter->sendRequest($req);
}
} catch (ClientExceptionInterface $e) {
$err = $e;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Core/Implementation/StreamingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ final class StreamingHttpClient implements ClientInterface
{
public function __construct(private ClientInterface $inner) {}

public function sendRequest(RequestInterface $request): ResponseInterface
public function sendRequest(RequestInterface $request, ?float $timeout = null): ResponseInterface
{
if (is_a($this->inner, '\GuzzleHttp\Client')) {
return $this->inner->send($request, ['stream' => true]);
$options = ['stream' => true];
if (null !== $timeout) {
$options['timeout'] = $timeout;
}

return $this->inner->send($request, $options);
}

return $this->inner->sendRequest($request);
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace Dedalus;

// x-release-please-start-version
const VERSION = '0.0.1';
const VERSION = '0.1.0';
// x-release-please-end
81 changes: 81 additions & 0 deletions tests/Core/RequestTimeoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace Tests\Core;

use Dedalus\Core\BaseClient;
use Dedalus\Core\Implementation\StreamingHttpClient;
use Dedalus\RequestOptions;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Http\Discovery\Psr17FactoryDiscovery;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @coversNothing
*/
#[CoversNothing]
class RequestTimeoutTest extends TestCase
{
#[Test]
public function testPassesPerRequestTimeoutToGuzzleTransporter(): void
{
[$client, $mock] = $this->buildClient();

$client->request('GET', '/', options: ['timeout' => 1.5]);

$this->assertSame(1.5, $mock->getLastOptions()['timeout']);
}

#[Test]
public function testPassesDefaultTimeoutToGuzzleTransporter(): void
{
[$client, $mock] = $this->buildClient();

$client->request('GET', '/');

$this->assertSame((new RequestOptions)->timeout, $mock->getLastOptions()['timeout']);
}

#[Test]
public function testPassesTimeoutToStreamingTransporter(): void
{
[$client, $mock] = $this->buildClient(streaming: true);

$client->request('GET', '/', headers: ['Accept' => 'text/event-stream'], options: ['timeout' => 2.5]);

$options = $mock->getLastOptions();
$this->assertTrue($options['stream']);
$this->assertSame(2.5, $options['timeout']);
}

/**
* @return array{BaseClient, MockHandler}
*/
private function buildClient(bool $streaming = false): array
{
$response = $streaming
? new Response(200, ['Content-Type' => 'text/event-stream'], '')
: new Response(200, ['Content-Type' => 'application/json'], '{}');

$mock = new MockHandler([$response]);
$guzzle = new GuzzleClient(['handler' => HandlerStack::create($mock)]);

$options = RequestOptions::with(
transporter: $guzzle,
streamingTransporter: new StreamingHttpClient($guzzle),
uriFactory: Psr17FactoryDiscovery::findUriFactory(),
requestFactory: Psr17FactoryDiscovery::findRequestFactory(),
streamFactory: Psr17FactoryDiscovery::findStreamFactory(),
);

$client = new class(headers: [], baseUrl: 'http://localhost', options: $options) extends BaseClient {};

return [$client, $mock];
}
}