diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index b31681fd64..02ef800f45 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1070,7 +1070,7 @@ return [ 'filters' => [], ], [ - '$id' => ID::custom('adapter'), // ssr or static + '$id' => ID::custom('rendering'), // ssr or static 'type' => Database::VAR_STRING, 'format' => '', 'size' => 128, diff --git a/app/config/frameworks.php b/app/config/frameworks.php index d19262ff57..5e89c1c915 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -23,7 +23,7 @@ return [ 'name' => 'Next.js', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'ssr' => [ 'key' => 'ssr', 'buildCommand' => 'npm run build', @@ -49,7 +49,7 @@ return [ 'name' => 'Nuxt', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'ssr' => [ 'key' => 'ssr', 'buildCommand' => 'npm run build', @@ -75,7 +75,7 @@ return [ 'name' => 'SvelteKit', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'ssr' => [ 'key' => 'ssr', 'buildCommand' => 'npm run build', @@ -101,7 +101,7 @@ return [ 'name' => 'Astro', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'ssr' => [ 'key' => 'ssr', 'buildCommand' => 'npm run build', @@ -127,7 +127,7 @@ return [ 'name' => 'Remix', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'ssr' => [ 'key' => 'ssr', 'buildCommand' => 'npm run build', @@ -153,7 +153,7 @@ return [ 'name' => 'Flutter', 'buildRuntime' => 'flutter-3.24', 'runtimes' => getVersions($templateRuntimes['FLUTTER']['versions'], 'flutter'), - 'adapters' => [ + 'renderingStrategies' => [ 'static' => [ 'key' => 'static', 'buildCommand' => 'flutter build web', @@ -170,7 +170,7 @@ return [ 'name' => 'Other', 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), - 'adapters' => [ + 'renderingStrategies' => [ 'static' => [ 'key' => 'static', 'buildCommand' => '', diff --git a/app/config/site-templates.php b/app/config/site-templates.php index 64d8cf3729..d31db344fc 100644 --- a/app/config/site-templates.php +++ b/app/config/site-templates.php @@ -26,7 +26,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'npm run build', 'outputDirectory' => './build', 'buildRuntime' => 'ssr-22', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'fallbackFile' => null, ], 'NEXTJS' => [ @@ -36,7 +36,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'npm run build', 'outputDirectory' => './.next', 'buildRuntime' => 'ssr-22', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'fallbackFile' => null, ], 'NUXT' => [ @@ -46,7 +46,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'npm run build', 'outputDirectory' => './.output', 'buildRuntime' => 'ssr-22', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'fallbackFile' => null, ], 'REMIX' => [ @@ -56,7 +56,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'npm run build', 'outputDirectory' => './build', 'buildRuntime' => 'ssr-22', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'fallbackFile' => null, ], 'ASTRO' => [ @@ -66,7 +66,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'npm run build', 'outputDirectory' => './dist', 'buildRuntime' => 'ssr-22', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'fallbackFile' => null, ], 'FLUTTER' => [ @@ -76,7 +76,7 @@ const TEMPLATE_FRAMEWORKS = [ 'buildCommand' => 'flutter build web', 'outputDirectory' => './build/web', 'buildRuntime' => 'flutter-3.24', - 'adapter' => 'static', + 'rendering' => 'static', 'fallbackFile' => null, ], ]; diff --git a/app/controllers/general.php b/app/controllers/general.php index c9efc90426..fd2f2b4685 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -216,7 +216,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw default => null }; - if ($resource->getAttribute('adapter', '') === 'static') { + if ($resource->getAttribute('rendering', '') === 'static') { $runtime = $runtimes['static-1'] ?? null; } @@ -413,9 +413,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $startCommand = $runtime['startCommand']; if (!is_null($framework)) { - $adapter = ($framework['adapters'] ?? [])[$resource->getAttribute('adapter', '')] ?? null; - if (!is_null($adapter) && isset($adapter['startCommand'])) { - $startCommand = $adapter['startCommand']; + $rendering = ($framework['renderingStrategies'] ?? [])[$resource->getAttribute('rendering', '')] ?? null; + if (!is_null($rendering) && isset($rendering['startCommand'])) { + $startCommand = $rendering['startCommand']; } } diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 809cb96cc2..cdd144a24f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -876,12 +876,12 @@ class Builds extends Action $bundleCommand = ''; if (!is_null($framework)) { - $adapter = ($framework['adapters'] ?? [])[$resource->getAttribute('adapter', '')] ?? null; - if (!is_null($adapter) && isset($adapter['envCommand'])) { - $envCommand = $adapter['envCommand']; + $rendering = ($framework['renderingStrategies'] ?? [])[$resource->getAttribute('rendering', '')] ?? null; + if (!is_null($rendering) && isset($rendering['envCommand'])) { + $envCommand = $rendering['envCommand']; } - if (!is_null($adapter) && isset($adapter['bundleCommand'])) { - $bundleCommand = $adapter['bundleCommand']; + if (!is_null($rendering) && isset($rendering['bundleCommand'])) { + $bundleCommand = $rendering['bundleCommand']; } } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index 079f2fec49..3c7d2662c9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -76,7 +76,7 @@ class Create extends Base ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('subdomain', '', new CustomId(), 'Unique custom sub-domain. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', true) ->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.') - ->param('adapter', '', new Text(8192, 0), 'Framework adapter. Allows: static, ssr', true) + ->param('rendering', '', new Text(8192, 0), 'Framework rendering strategy. Allows: static, ssr', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) @@ -105,14 +105,14 @@ class Create extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $adapter, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $rendering, string $installationId, ?string $fallbackFile, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) { - if (!empty($adapter)) { + if (!empty($rendering)) { $configFramework = Config::getParam('frameworks')[$framework] ?? []; - $adapters = \array_keys($configFramework['adapters'] ?? []); - $validator = new WhiteList($adapters, true); - if (!$validator->isValid($adapter)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Adapter not supported for the selected framework.'); + $renderingStraregies = \array_keys($configFramework['renderingStrategies'] ?? []); + $validator = new WhiteList($renderingStraregies, true); + if (!$validator->isValid($rendering)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Rendering strategy not supported for the selected framework.'); } } @@ -187,7 +187,7 @@ class Create extends Base 'providerSilentMode' => $providerSilentMode, 'specification' => $specification, 'buildRuntime' => $buildRuntime, - 'adapter' => $adapter, + 'rendering' => $rendering, ])); // Git connect logic diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 578e0cf164..339bd2a779 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -73,7 +73,7 @@ class Update extends Base ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', true) - ->param('adapter', '', new Text(8192, 0), 'Framework adapter. Usuallly allows: static, ssr', true) + ->param('rendering', '', new Text(8192, 0), 'Framework rendering strategy. Usuallly allows: static, ssr', true) ->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) @@ -97,14 +97,14 @@ class Update extends Base ->callback([$this, 'action']); } - public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $adapter, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) + public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $buildRuntime, string $rendering, ?string $fallbackFile, string $installationId, ?string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds, Database $dbForPlatform, GitHub $github) { - if (!empty($adapter)) { + if (!empty($rendering)) { $configFramework = Config::getParam('frameworks')[$framework] ?? []; - $adapters = \array_keys($configFramework['adapters'] ?? []); - $validator = new WhiteList($adapters, true); - if (!$validator->isValid($adapter)) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Adapter not supported for the selected framework.'); + $renderingStrategies = \array_keys($configFramework['renderingStrategies'] ?? []); + $validator = new WhiteList($renderingStrategies, true); + if (!$validator->isValid($rendering)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Rendering strategy not supported for the selected framework.'); } } @@ -238,7 +238,7 @@ class Update extends Base 'specification' => $specification, 'search' => implode(' ', [$siteId, $name, $framework]), 'buildRuntime' => $buildRuntime, - 'adapter' => $adapter, + 'rendering' => $rendering, 'fallbackFile' => $fallbackFile, ]))); diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index da222822e0..cf0deff59f 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -45,7 +45,7 @@ use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\Execution; use Appwrite\Utopia\Response\Model\File; use Appwrite\Utopia\Response\Model\Framework; -use Appwrite\Utopia\Response\Model\FrameworkAdapter; +use Appwrite\Utopia\Response\Model\FrameworkRendering; use Appwrite\Utopia\Response\Model\Func; use Appwrite\Utopia\Response\Model\Headers; use Appwrite\Utopia\Response\Model\HealthAntivirus; @@ -258,7 +258,7 @@ class Response extends SwooleResponse public const MODEL_SITE_LIST = 'siteList'; public const MODEL_FRAMEWORK = 'framework'; public const MODEL_FRAMEWORK_LIST = 'frameworkList'; - public const MODEL_FRAMEWORK_ADAPTER = 'frameworkAdapter'; + public const MODEL_FRAMEWORK_RENDERING = 'frameworkRendering'; public const MODEL_TEMPLATE_SITE = 'templateSite'; public const MODEL_TEMPLATE_SITE_LIST = 'templateSiteList'; public const MODEL_TEMPLATE_FRAMEWORK = 'templateFramework'; @@ -458,7 +458,7 @@ class Response extends SwooleResponse ->setModel(new Branch()) ->setModel(new Runtime()) ->setModel(new Framework()) - ->setModel(new FrameworkAdapter()) + ->setModel(new FrameworkRendering()) ->setModel(new Deployment()) ->setModel(new Execution()) ->setModel(new Build()) diff --git a/src/Appwrite/Utopia/Response/Model/Framework.php b/src/Appwrite/Utopia/Response/Model/Framework.php index 14d4052133..1a8e6f4615 100644 --- a/src/Appwrite/Utopia/Response/Model/Framework.php +++ b/src/Appwrite/Utopia/Response/Model/Framework.php @@ -35,9 +35,9 @@ class Framework extends Model 'example' => ['static-1', 'node-22'], 'array' => true, ]) - ->addRule('adapters', [ - 'type' => Response::MODEL_FRAMEWORK_ADAPTER, - 'description' => 'List of supported adapters.', + ->addRule('renderingStrategies', [ + 'type' => Response::MODEL_FRAMEWORK_RENDERING, + 'description' => 'List of supported rendering strategies.', 'default' => '', 'example' => [[ 'key' => 'static', 'buildRuntime' => 'node-22', 'buildCommand' => 'npm run build', 'installCommand' => 'npm install', 'outputDirectory' => './dist' ]], 'array' => true, diff --git a/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php b/src/Appwrite/Utopia/Response/Model/FrameworkRendering.php similarity index 91% rename from src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php rename to src/Appwrite/Utopia/Response/Model/FrameworkRendering.php index 8348f3a6d5..26e502bada 100644 --- a/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php +++ b/src/Appwrite/Utopia/Response/Model/FrameworkRendering.php @@ -5,7 +5,7 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; -class FrameworkAdapter extends Model +class FrameworkRendering extends Model { public function __construct() { @@ -44,7 +44,7 @@ class FrameworkAdapter extends Model */ public function getName(): string { - return 'Framework Adapter'; + return 'Framework Rendering'; } /** @@ -54,6 +54,6 @@ class FrameworkAdapter extends Model */ public function getType(): string { - return Response::MODEL_FRAMEWORK_ADAPTER; + return Response::MODEL_FRAMEWORK_RENDERING; } } diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index 9a760a3e2a..2f298a3901 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -131,9 +131,9 @@ class Site extends Model 'default' => '', 'example' => 'node-22', ]) - ->addRule('adapter', [ + ->addRule('rendering', [ 'type' => self::TYPE_STRING, - 'description' => 'Site framework adapter.', + 'description' => 'Site framework rendering strategy (adapter).', 'default' => null, 'example' => 'static', ]) diff --git a/src/Appwrite/Utopia/Response/Model/TemplateFramework.php b/src/Appwrite/Utopia/Response/Model/TemplateFramework.php index ae94ca4425..4847d3ae47 100644 --- a/src/Appwrite/Utopia/Response/Model/TemplateFramework.php +++ b/src/Appwrite/Utopia/Response/Model/TemplateFramework.php @@ -52,9 +52,9 @@ class TemplateFramework extends Model 'default' => '', 'example' => 'node-22', ]) - ->addRule('adapter', [ + ->addRule('rendering', [ 'type' => self::TYPE_STRING, - 'description' => 'Site framework runtime', + 'description' => 'Site framework rendering strategy', 'default' => '', 'example' => 'ssr', ]) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 2a0b11f16c..29b68a9306 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -279,7 +279,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Astro site', 'framework' => 'astro', - 'adapter' => 'ssr', + 'rendering' => 'ssr', 'buildRuntime' => 'ssr-22', 'outputDirectory' => './dist', 'buildCommand' => 'npm run build', @@ -559,7 +559,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => $starterTemplate['body']['name'], 'framework' => $nextjsFramework['key'], - 'adapter' => $nextjsFramework['adapter'], + 'rendering' => $nextjsFramework['rendering'], 'buildCommand' => $nextjsFramework['buildCommand'], 'buildRuntime' => $nextjsFramework['buildRuntime'], 'fallbackFile' => $nextjsFramework['fallbackFile'], @@ -1194,7 +1194,7 @@ class SitesCustomServerTest extends Scope $this->assertArrayHasKey('key', $framework); $this->assertArrayHasKey('buildRuntime', $framework); $this->assertArrayHasKey('runtimes', $framework); - $this->assertArrayHasKey('adapters', $framework); + $this->assertArrayHasKey('renderingStrategies', $framework); } public function testSiteTemplate(): void @@ -1208,7 +1208,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Template site', 'framework' => $template['frameworks'][0]['key'], - 'adapter' => $template['frameworks'][0]['adapter'], + 'rendering' => $template['frameworks'][0]['rendering'], 'buildRuntime' => $template['frameworks'][0]['buildRuntime'], 'outputDirectory' => $template['frameworks'][0]['outputDirectory'], 'buildCommand' => $template['frameworks'][0]['buildCommand'], @@ -1258,7 +1258,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Startup site', 'framework' => 'other', - 'adapter' => 'static', + 'rendering' => 'static', 'buildRuntime' => 'static-1', 'outputDirectory' => './', 'buildCommand' => '', @@ -1292,7 +1292,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Startup 2 site', 'framework' => 'other', - 'adapter' => 'static', + 'rendering' => 'static', 'buildRuntime' => 'static-1', 'outputDirectory' => './', 'buildCommand' => '', @@ -1332,7 +1332,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Startup 2 site', 'framework' => 'other', - 'adapter' => 'static', + 'rendering' => 'static', 'buildRuntime' => 'static-1', 'outputDirectory' => './', 'buildCommand' => '', @@ -1352,7 +1352,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'A site', 'framework' => 'other', - 'adapter' => 'static', + 'rendering' => 'static', 'buildRuntime' => 'static-1', 'outputDirectory' => './', 'buildCommand' => '', @@ -1414,7 +1414,7 @@ class SitesCustomServerTest extends Scope 'siteId' => ID::unique(), 'name' => 'Startup site', 'framework' => 'other', - 'adapter' => 'static', + 'rendering' => 'static', 'buildRuntime' => 'static-1', 'outputDirectory' => './', 'buildCommand' => '',