diff --git a/app/config/platforms.php b/app/config/platforms.php index 21db108624..13c6d73203 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -1,9 +1,5 @@ [ 'key' => APP_PLATFORM_CLIENT, diff --git a/app/init.php b/app/init.php index 1eb7cc93ce..45620a9a02 100644 --- a/app/init.php +++ b/app/init.php @@ -142,6 +142,9 @@ const APP_SOCIAL_DEV = 'https://dev.to/appwrite'; const APP_SOCIAL_STACKSHARE = 'https://stackshare.io/appwrite'; const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation=1'; const APP_HOSTNAME_INTERNAL = 'appwrite'; +const APP_PLATFORM_SERVER = 'server'; +const APP_PLATFORM_CLIENT = 'client'; +const APP_PLATFORM_CONSOLE = 'console'; // Database Reconnect const DATABASE_RECONNECT_SLEEP = 2; diff --git a/composer.json b/composer.json index 73bb84159a..658ddfc53c 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,7 @@ }, "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "0.38.*", + "appwrite/sdk-generator": "0.39.*", "phpunit/phpunit": "9.5.20", "swoole/ide-helper": "5.1.2", "textalk/websocket": "1.5.7", diff --git a/composer.lock b/composer.lock index a0d2f3be1f..6e9d369fa8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b737874b23ae7480c9579c5ee28ad46f", + "content-hash": "0e770d4489dbe657c00281b1afd3c0ee", "packages": [ { "name": "adhocore/jwt", @@ -3001,16 +3001,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.38.8", + "version": "0.39.18", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef" + "reference": "3f12532d3a41f6e3e7528f41c0e79a6d473c4a4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef", - "reference": "6367c57ddbcf7b88cacb900c4fe7ef3f28bf38ef", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/3f12532d3a41f6e3e7528f41c0e79a6d473c4a4c", + "reference": "3f12532d3a41f6e3e7528f41c0e79a6d473c4a4c", "shasum": "" }, "require": { @@ -3046,9 +3046,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.38.8" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.18" }, - "time": "2024-06-17T00:42:27+00:00" + "time": "2024-08-27T11:22:14+00:00" }, { "name": "doctrine/deprecations", diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 114e12ac85..8b5093eeab 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -5,9 +5,11 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Specification\Format\OpenAPI3; use Appwrite\Specification\Format\Swagger2; use Appwrite\Specification\Specification; -use Appwrite\Utopia\Response; +use Appwrite\Utopia\Request as AppwriteRequest; +use Appwrite\Utopia\Response as AppwriteResponse; use Exception; -use Swoole\Http\Response as HttpResponse; +use Swoole\Http\Request as SwooleRequest; +use Swoole\Http\Response as SwooleResponse; use Utopia\App; use Utopia\Cache\Adapter\None; use Utopia\Cache\Cache; @@ -17,7 +19,8 @@ use Utopia\Database\Adapter\MySQL; use Utopia\Database\Database; use Utopia\Platform\Action; use Utopia\Registry\Registry; -use Utopia\Request; +use Utopia\Request as UtopiaRequest; +use Utopia\Response as UtopiaResponse; use Utopia\System\System; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -29,6 +32,16 @@ class Specs extends Action return 'specs'; } + public function getRequest(): UtopiaRequest + { + return new AppwriteRequest(new SwooleRequest()); + } + + public function getResponse(): UtopiaResponse + { + return new AppwriteResponse(new SwooleResponse()); + } + public function __construct() { $this @@ -42,11 +55,11 @@ class Specs extends Action public function action(string $version, string $mode, Registry $register): void { $appRoutes = App::getRoutes(); - $response = new Response(new HttpResponse()); + $response = $this->getResponse(); $mocks = ($mode === 'mocks'); // Mock dependencies - App::setResource('request', fn () => new Request()); + App::setResource('request', fn () => $this->getRequest()); App::setResource('response', fn () => $response); App::setResource('dbForConsole', fn () => new Database(new MySQL(''), new Cache(new None()))); App::setResource('dbForProject', fn () => new Database(new MySQL(''), new Cache(new None()))); @@ -183,10 +196,8 @@ class Specs extends Action case APP_AUTH_TYPE_SESSION: $sdkPlatforms[] = APP_PLATFORM_CLIENT; break; - case APP_AUTH_TYPE_KEY: - $sdkPlatforms[] = APP_PLATFORM_SERVER; - break; case APP_AUTH_TYPE_JWT: + case APP_AUTH_TYPE_KEY: $sdkPlatforms[] = APP_PLATFORM_SERVER; break; case APP_AUTH_TYPE_ADMIN: diff --git a/src/Appwrite/Utopia/Request.php b/src/Appwrite/Utopia/Request.php index 3f0a196d5e..26c1baf188 100644 --- a/src/Appwrite/Utopia/Request.php +++ b/src/Appwrite/Utopia/Request.php @@ -122,7 +122,11 @@ class Request extends UtopiaRequest */ public function getHeaders(): array { - $headers = $this->generateHeaders(); + try { + $headers = $this->generateHeaders(); + } catch (\Throwable) { + $headers = []; + } if (empty($this->swoole->cookie)) { return $headers;