diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index aaae7c6a8..475f03689 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -17,7 +17,6 @@ /packages/console/ @eldadfux @lohanidamodar /packages/di/ @eldadfux @ChiragAgg5k /packages/domains/ @ChiragAgg5k @eldadfux @lohanidamodar -/packages/fastly/ @loks0n /packages/http/ @lohanidamodar @eldadfux @Meldiron /packages/nats/ @loks0n @levivannoort /packages/platform/ @lohanidamodar @shimonewman diff --git a/README.md b/README.md index ebabdf22a..79111938f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The source of truth for the [utopia-php](https://github.com/utopia-php) libraries. Each `packages/` is an independent Composer library; development happens here, and every push is mirrored to its read-only repository (e.g. `utopia-php/http`), so Composer/Packagist distribution is unchanged — mechanics in [docs/distribution.md](docs/distribution.md). -[`utopia-php/audit`](https://github.com/appwrite/appwrite/tree/main/packages/audit), [`utopia-php/auth`](https://github.com/appwrite/appwrite/tree/main/packages/auth), [`utopia-php/cache`](https://github.com/appwrite/appwrite/tree/main/packages/cache), [`utopia-php/cdn`](https://github.com/appwrite/appwrite/tree/main/packages/cdn), [`utopia-php/circuit-breaker`](https://github.com/appwrite/appwrite/tree/main/packages/circuit-breaker), [`utopia-php/cli`](https://github.com/appwrite/appwrite/tree/main/packages/cli), [`utopia-php/client`](https://github.com/appwrite/appwrite/tree/main/packages/client), [`utopia-php/compression`](https://github.com/appwrite/appwrite/tree/main/packages/compression), [`utopia-php/console`](https://github.com/appwrite/appwrite/tree/main/packages/console), [`utopia-php/di`](https://github.com/appwrite/appwrite/tree/main/packages/di), [`utopia-php/dns`](https://github.com/appwrite/appwrite/tree/main/packages/dns), [`utopia-php/domains`](https://github.com/appwrite/appwrite/tree/main/packages/domains), [`utopia-php/http`](https://github.com/appwrite/appwrite/tree/main/packages/http), [`utopia-php/image`](https://github.com/appwrite/appwrite/tree/main/packages/image), [`utopia-php/messaging`](https://github.com/appwrite/appwrite/tree/main/packages/messaging), [`utopia-php/nats`](https://github.com/appwrite/appwrite/tree/main/packages/nats), [`utopia-php/openapi`](https://github.com/appwrite/appwrite/tree/main/packages/openapi), [`utopia-php/platform`](https://github.com/appwrite/appwrite/tree/main/packages/platform), [`utopia-php/pools`](https://github.com/appwrite/appwrite/tree/main/packages/pools), [`utopia-php/queue`](https://github.com/appwrite/appwrite/tree/main/packages/queue), [`utopia-php/schedule`](https://github.com/appwrite/appwrite/tree/main/packages/schedule), [`utopia-php/servers`](https://github.com/appwrite/appwrite/tree/main/packages/servers), [`utopia-php/smtp`](https://github.com/appwrite/appwrite/tree/main/packages/smtp), [`utopia-php/span`](https://github.com/appwrite/appwrite/tree/main/packages/span), [`utopia-php/storage`](https://github.com/appwrite/appwrite/tree/main/packages/storage), [`utopia-php/system`](https://github.com/appwrite/appwrite/tree/main/packages/system), [`utopia-php/telemetry`](https://github.com/appwrite/appwrite/tree/main/packages/telemetry), [`utopia-php/user-agent`](https://github.com/appwrite/appwrite/tree/main/packages/user-agent), [`utopia-php/validators`](https://github.com/appwrite/appwrite/tree/main/packages/validators), [`utopia-php/vcs`](https://github.com/appwrite/appwrite/tree/main/packages/vcs) and [`utopia-php/websocket`](https://github.com/appwrite/appwrite/tree/main/packages/websocket) are maintained in Appwrite. Their distribution mirrors and Packagist packages remain available. +[`utopia-php/audit`](https://github.com/appwrite/appwrite/tree/main/packages/audit), [`utopia-php/auth`](https://github.com/appwrite/appwrite/tree/main/packages/auth), [`utopia-php/cache`](https://github.com/appwrite/appwrite/tree/main/packages/cache), [`utopia-php/cdn`](https://github.com/appwrite/appwrite/tree/main/packages/cdn), [`utopia-php/circuit-breaker`](https://github.com/appwrite/appwrite/tree/main/packages/circuit-breaker), [`utopia-php/cli`](https://github.com/appwrite/appwrite/tree/main/packages/cli), [`utopia-php/client`](https://github.com/appwrite/appwrite/tree/main/packages/client), [`utopia-php/compression`](https://github.com/appwrite/appwrite/tree/main/packages/compression), [`utopia-php/console`](https://github.com/appwrite/appwrite/tree/main/packages/console), [`utopia-php/di`](https://github.com/appwrite/appwrite/tree/main/packages/di), [`utopia-php/dns`](https://github.com/appwrite/appwrite/tree/main/packages/dns), [`utopia-php/domains`](https://github.com/appwrite/appwrite/tree/main/packages/domains), [`utopia-php/http`](https://github.com/appwrite/appwrite/tree/main/packages/http), [`utopia-php/image`](https://github.com/appwrite/appwrite/tree/main/packages/image), [`utopia-php/messaging`](https://github.com/appwrite/appwrite/tree/main/packages/messaging), [`utopia-php/nats`](https://github.com/appwrite/appwrite/tree/main/packages/nats), [`utopia-php/openapi`](https://github.com/appwrite/appwrite/tree/main/packages/openapi), [`utopia-php/platform`](https://github.com/appwrite/appwrite/tree/main/packages/platform), [`utopia-php/pools`](https://github.com/appwrite/appwrite/tree/main/packages/pools), [`utopia-php/queue`](https://github.com/appwrite/appwrite/tree/main/packages/queue), [`utopia-php/schedule`](https://github.com/appwrite/appwrite/tree/main/packages/schedule), [`utopia-php/servers`](https://github.com/appwrite/appwrite/tree/main/packages/servers), [`utopia-php/smtp`](https://github.com/appwrite/appwrite/tree/main/packages/smtp), [`utopia-php/span`](https://github.com/appwrite/appwrite/tree/main/packages/span), [`utopia-php/storage`](https://github.com/appwrite/appwrite/tree/main/packages/storage), [`utopia-php/system`](https://github.com/appwrite/appwrite/tree/main/packages/system), [`utopia-php/telemetry`](https://github.com/appwrite/appwrite/tree/main/packages/telemetry), [`utopia-php/user-agent`](https://github.com/appwrite/appwrite/tree/main/packages/user-agent), [`utopia-php/validators`](https://github.com/appwrite/appwrite/tree/main/packages/validators), [`utopia-php/vcs`](https://github.com/appwrite/appwrite/tree/main/packages/vcs) and [`utopia-php/websocket`](https://github.com/appwrite/appwrite/tree/main/packages/websocket) are maintained in Appwrite. Their distribution mirrors and Packagist packages remain available. [`utopia-php/fastly`](https://github.com/utopia-php/fastly) is maintained in Appwrite's Edge repository, its only consumer. ## Quickstart @@ -52,7 +52,6 @@ Local siblings only: arrows point at dependencies between the packages in this c ```mermaid graph TD config - fastly replication reputation ``` diff --git a/packages/fastly/.github/workflows/mirror.yml b/packages/fastly/.github/workflows/mirror.yml deleted file mode 100644 index e14fc8816..000000000 --- a/packages/fastly/.github/workflows/mirror.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Mirror - -on: - pull_request_target: - types: [opened] - issues: - types: [opened] - -permissions: - issues: write - pull-requests: write - -jobs: - redirect: - uses: utopia-php/monorepo/.github/workflows/mirror-redirect.yml@main - with: - package: fastly diff --git a/packages/fastly/.gitignore b/packages/fastly/.gitignore deleted file mode 100644 index 50be0df59..000000000 --- a/packages/fastly/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/vendor/ -composer.lock -composer.linked.json -.phpunit.cache/ -.phpunit.result.cache diff --git a/packages/fastly/CHANGELOG.md b/packages/fastly/CHANGELOG.md deleted file mode 100644 index 0803ef105..000000000 --- a/packages/fastly/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Changelog - -## 0.1.0 - -- Initial release: Fastly surrogate-key purge client built on `utopia-php/client`. diff --git a/packages/fastly/README.md b/packages/fastly/README.md deleted file mode 100644 index 0fef8bd9c..000000000 --- a/packages/fastly/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Utopia Fastly - -> [!IMPORTANT] -> This repository is a read-only mirror of the [utopia-php monorepo](https://github.com/utopia-php/monorepo). Development happens in [`packages/fastly`](https://github.com/utopia-php/monorepo/tree/main/packages/fastly) — please open issues and pull requests there. - -A small [Fastly](https://www.fastly.com) API client for PHP 8.4+, built on -[utopia-php/client](https://github.com/utopia-php/client). It currently exposes -surrogate-key purging. - -## Install - -```bash -composer require utopia-php/fastly -``` - -## Usage - -```php -purge('homepage'); -``` - -`purge()` issues `POST {endpoint}/{serviceId}/purge/{surrogateKey}` with the API -token in the `Fastly-Key` header. A non-2xx response raises -`Utopia\Fastly\Exception\PurgeException`; network failures surface as the -underlying PSR-18 client exceptions. - -The endpoint (`https://api.fastly.com/service`) and token header (`Fastly-Key`) -are constructor arguments, so the client also works against a compatible proxy: - -```php -$fastly = new Fastly($client, $serviceId, $token, 'https://cdn.internal/service', 'X-Purge-Key'); -``` diff --git a/packages/fastly/composer.json b/packages/fastly/composer.json deleted file mode 100644 index 756b2bb79..000000000 --- a/packages/fastly/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "utopia-php/fastly", - "description": "Fastly HTTP API client built on utopia-php/client", - "type": "library", - "keywords": [ - "php", - "fastly", - "cdn", - "purge", - "http", - "utopia" - ], - "license": "MIT", - "autoload": { - "psr-4": { - "Utopia\\Fastly\\": "src/Fastly/" - } - }, - "autoload-dev": { - "psr-4": { - "Utopia\\Fastly\\Tests\\": "tests/" - } - }, - "scripts": { - "test": "phpunit" - }, - "require": { - "php": ">=8.4", - "psr/http-client": "^1.0", - "utopia-php/client": "^0.5", - "utopia-php/psr7": "^0.2" - } -} diff --git a/packages/fastly/phpstan.neon b/packages/fastly/phpstan.neon deleted file mode 100644 index 776ccd86c..000000000 --- a/packages/fastly/phpstan.neon +++ /dev/null @@ -1,4 +0,0 @@ -parameters: - level: max - paths: - - src diff --git a/packages/fastly/phpunit.xml b/packages/fastly/phpunit.xml deleted file mode 100644 index 6f244f569..000000000 --- a/packages/fastly/phpunit.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - tests - - - - - src - - - diff --git a/packages/fastly/src/Fastly/Exception/PurgeException.php b/packages/fastly/src/Fastly/Exception/PurgeException.php deleted file mode 100644 index cc08b7fc0..000000000 --- a/packages/fastly/src/Fastly/Exception/PurgeException.php +++ /dev/null @@ -1,20 +0,0 @@ -requests = new RequestFactory(); - } - - /** - * Purge every response tagged with a surrogate key. - * - * Network failures surface as the underlying PSR-18 client exceptions; a - * non-2xx response from Fastly is reported as a PurgeException. - * - * @throws PurgeException When Fastly does not acknowledge the purge. - */ - public function purge(string $surrogateKey): void - { - $url = rtrim($this->endpoint, '/') - . '/' . rawurlencode($this->serviceId) - . '/purge/' . rawurlencode($surrogateKey); - - $request = $this->requests->createRequest(Method::POST, $url) - ->withHeader($this->tokenHeader, $this->token) - ->withHeader('Accept', 'application/json'); - - $response = $this->client->sendRequest($request); - - $status = $response->getStatusCode(); - if ($status < 200 || $status >= 300) { - throw new PurgeException($surrogateKey, $status, (string) $response->getBody()); - } - } -} diff --git a/packages/fastly/tests/PurgeTest.php b/packages/fastly/tests/PurgeTest.php deleted file mode 100644 index a28fc45e2..000000000 --- a/packages/fastly/tests/PurgeTest.php +++ /dev/null @@ -1,81 +0,0 @@ -request = $request; - - return new ResponseFactory()->createResponse($this->status); - } - }; - } - - public function testPurgeSendsSignedPostToFastly(): void - { - $client = $this->recordingClient(); - new Fastly($client, 'svc1', 'secret-token')->purge('homepage'); - - $this->assertNotNull($client->request); - $this->assertSame('POST', $client->request->getMethod()); - $this->assertSame( - 'https://api.fastly.com/service/svc1/purge/homepage', - (string) $client->request->getUri(), - ); - $this->assertSame('secret-token', $client->request->getHeaderLine('Fastly-Key')); - $this->assertSame('application/json', $client->request->getHeaderLine('Accept')); - } - - public function testServiceIdAndKeyAreUrlEncoded(): void - { - $client = $this->recordingClient(); - new Fastly($client, 'svc 1', 'tok')->purge('home/page'); - - $this->assertSame( - 'https://api.fastly.com/service/svc%201/purge/home%2Fpage', - (string) $client->request->getUri(), - ); - } - - public function testCustomEndpointAndTokenHeader(): void - { - $client = $this->recordingClient(); - new Fastly($client, 'svc1', 'tok', 'https://cdn.example.com/service/', 'X-Purge-Key') - ->purge('a'); - - $this->assertSame('https://cdn.example.com/service/svc1/purge/a', (string) $client->request->getUri()); - $this->assertSame('tok', $client->request->getHeaderLine('X-Purge-Key')); - } - - public function testNon2xxResponseThrows(): void - { - $fastly = new Fastly($this->recordingClient(403), 'svc1', 'bad-token'); - - $this->expectException(PurgeException::class); - $this->expectExceptionMessage('Fastly purge failed for key: status 403'); - $fastly->purge('key'); - } -}