diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index b209a7ec32..806b6cf088 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -971,16 +971,16 @@ return [ 'default' => false, 'array' => false, ], - // [ - // '$id' => ID::custom('logging'), - // 'type' => Database::VAR_BOOLEAN, - // 'signed' => true, - // 'size' => 0, - // 'format' => '', - // 'filters' => [], - // 'required' => true, - // 'array' => false, - // ], + [ + '$id' => ID::custom('logging'), + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 0, + 'format' => '', + 'filters' => [], + 'required' => true, + 'array' => false, + ], [ '$id' => ID::custom('framework'), 'type' => Database::VAR_STRING, @@ -1725,6 +1725,28 @@ return [ 'default' => '', 'array' => false, 'filters' => [], + ], + [ + '$id' => ID::custom('adapter'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => '', + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('fallbackFile'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], ] ], 'indexes' => [ diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 9e9f99db63..cc8a611416 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -9268,7 +9268,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "entrypoint": { @@ -9889,7 +9889,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "entrypoint": { @@ -24730,6 +24730,11 @@ "description": "Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -25360,6 +25365,11 @@ "description": "Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -36864,6 +36874,11 @@ "description": "Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "framework": { "type": "string", "description": "Site framework.", @@ -36986,6 +37001,7 @@ "name", "enabled", "live", + "logging", "framework", "deploymentId", "deploymentCreatedAt", @@ -37205,7 +37221,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "runtime": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 287ce791c3..ecda53b77b 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -8355,7 +8355,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "entrypoint": { @@ -8751,7 +8751,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "entrypoint": { @@ -16828,6 +16828,11 @@ "description": "Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -17233,6 +17238,11 @@ "description": "Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -27413,6 +27423,11 @@ "description": "Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "framework": { "type": "string", "description": "Site framework.", @@ -27535,6 +27550,7 @@ "name", "enabled", "live", + "logging", "framework", "deploymentId", "deploymentCreatedAt", @@ -27603,7 +27619,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "runtime": { diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 05acf4a551..4d3ab5bce8 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -9425,7 +9425,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "default": true, "x-example": false }, @@ -10061,7 +10061,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "default": true, "x-example": false }, @@ -25234,6 +25234,12 @@ "default": true, "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "default": true, + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -25878,6 +25884,12 @@ "default": true, "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "default": true, + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -37444,6 +37456,11 @@ "description": "Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "framework": { "type": "string", "description": "Site framework.", @@ -37567,6 +37584,7 @@ "name", "enabled", "live", + "logging", "framework", "deploymentId", "deploymentCreatedAt", @@ -37788,7 +37806,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "runtime": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index b7371b1bbd..c2d3b06ebc 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -8509,7 +8509,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "default": true, "x-example": false }, @@ -8924,7 +8924,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "default": true, "x-example": false }, @@ -17298,6 +17298,12 @@ "default": true, "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "default": true, + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -17721,6 +17727,12 @@ "default": true, "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "default": true, + "x-example": false + }, "timeout": { "type": "integer", "description": "Maximum request time in seconds.", @@ -27964,6 +27976,11 @@ "description": "Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration.", "x-example": false }, + "logging": { + "type": "boolean", + "description": "When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.", + "x-example": false + }, "framework": { "type": "string", "description": "Site framework.", @@ -28087,6 +28104,7 @@ "name", "enabled", "live", + "logging", "framework", "deploymentId", "deploymentCreatedAt", @@ -28155,7 +28173,7 @@ }, "logging": { "type": "boolean", - "description": "Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.", + "description": "When disabled, executions will exclude logs and errors, and will be slightly faster.", "x-example": false }, "runtime": { diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 107be3d888..5b2cabdab2 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -232,6 +232,8 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'entrypoint' => $resource->getAttribute('entrypoint', ''), 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $resource->getAttribute('outputDirectory', ''), + 'adapter' => $resource->getAttribute('adapter', ''), + 'fallbackFile' => $resource->getAttribute('fallbackFile', ''), 'type' => 'vcs', 'installationId' => $installationId, 'installationInternalId' => $installationInternalId, diff --git a/app/controllers/general.php b/app/controllers/general.php index 3afe1d8a3d..3f105484e1 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -261,7 +261,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw }; // Static site enforced runtime - if ($resource->getAttribute('adapter', '') === 'static') { + if ($deployment->getAttribute('adapter', '') === 'static') { $runtime = $runtimes['static-1'] ?? null; } @@ -410,8 +410,8 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw ]); // SPA fallbackFile override - if ($resource->getAttribute('adapter', '') === 'static' && $resource->getAttribute('fallbackFile', '') !== '') { - $vars['OPEN_RUNTIMES_STATIC_FALLBACK'] = $resource->getAttribute('fallbackFile', ''); + if ($deployment->getAttribute('adapter', '') === 'static' && $deployment->getAttribute('fallbackFile', '') !== '') { + $vars['OPEN_RUNTIMES_STATIC_FALLBACK'] = $deployment->getAttribute('fallbackFile', ''); } /** Execute function */ @@ -438,7 +438,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $startCommand = $runtime['startCommand']; if (!is_null($framework)) { - $adapter = ($framework['adapters'] ?? [])[$resource->getAttribute('adapter', '')] ?? null; + $adapter = ($framework['adapters'] ?? [])[$deployment->getAttribute('adapter', '')] ?? null; if (!is_null($adapter) && isset($adapter['startCommand'])) { $startCommand = $adapter['startCommand']; } @@ -473,7 +473,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw ); // Branded 404 override - if ($executionResponse['statusCode'] === 404 && $resource->getAttribute('adapter', '') === 'static') { + if ($executionResponse['statusCode'] === 404 && $deployment->getAttribute('adapter', '') === 'static') { $layout = new View(__DIR__ . '/../views/general/404.phtml'); $executionResponse['body'] = $layout->render(); $executionResponse['headers']['content-length'] = \strlen($executionResponse['body']); diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 6d44be239d..542b29bcd5 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -171,6 +171,8 @@ class Base extends Action 'resourceType' => 'sites', 'buildCommands' => implode(' && ', $commands), 'buildOutput' => $site->getAttribute('outputDirectory', ''), + 'adapter' => $site->getAttribute('adapter', ''), + 'fallbackFile' => $site->getAttribute('fallbackFile', ''), 'type' => 'vcs', 'installationId' => $installation->getId(), 'installationInternalId' => $installation->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index 28f2c3cd1f..cf31d3d7d2 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -76,7 +76,7 @@ class Create extends Base ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_COMPUTE_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true) ->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true) - ->param('logging', true, new Boolean(), 'Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.', true) + ->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) ->param('commands', '', new Text(8192, 0), 'Build Commands.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index d1714685d8..3c876ed91e 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -80,7 +80,7 @@ class Update extends Base ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_COMPUTE_TIMEOUT', 900)), 'Maximum execution time in seconds.', true) ->param('enabled', true, new Boolean(), 'Is function enabled? When set to \'disabled\', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.', true) - ->param('logging', true, new Boolean(), 'Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.', true) + ->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) ->param('commands', '', new Text(8192, 0), 'Build Commands.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API Key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 9ea5638ac3..3f28e7a7ce 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -768,6 +768,10 @@ class Builds extends Action $resource->setAttribute('adapter', $detection->getName()); $resource->setAttribute('fallbackFile', $detection->getFallbackFile() ?? ''); $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); + + $deployment->setAttribute('adapter', $detection->getName()); + $deployment->setAttribute('fallbackFile', $detection->getFallbackFile() ?? ''); + $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); } elseif ($adapter === 'ssr' && $detection->getName() === 'static') { throw new \Exception('Adapter mismatch. Detected: ' . $detection->getName() . ' does not match with the set adapter: ' . $adapter); } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index ab2d9282ac..0b45c42e4b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -241,13 +241,15 @@ class Create extends Action 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $outputDirectory, + 'adapter' => $site->getAttribute('adapter', ''), + 'fallbackFile' => $site->getAttribute('fallbackFile', ''), 'sourcePath' => $path, 'sourceSize' => $fileSize, 'totalSize' => $fileSize, 'search' => implode(' ', [$deploymentId]), 'activate' => $activate, 'sourceMetadata' => $metadata, - 'type' => $type + 'type' => $type, ])); $site = $site @@ -306,6 +308,8 @@ class Create extends Action 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $outputDirectory, + 'adapter' => $site->getAttribute('adapter', ''), + 'fallbackFile' => $site->getAttribute('fallbackFile', ''), 'sourcePath' => $path, 'sourceSize' => $fileSize, 'totalSize' => $fileSize, @@ -314,7 +318,7 @@ class Create extends Action 'search' => implode(' ', [$deploymentId]), 'activate' => $activate, 'sourceMetadata' => $metadata, - 'type' => $type + 'type' => $type, ])); $site = $site diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 9e33a6b839..1b3b08b7e3 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -114,6 +114,8 @@ class Create extends Action 'totalSize' => $deployment->getAttribute('sourceSize', 0), 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $site->getAttribute('outputDirectory', ''), + 'adapter' => $site->getAttribute('adapter', ''), + 'fallbackFile' => $site->getAttribute('fallbackFile', ''), 'search' => implode(' ', [$deploymentId]), 'screenshotLight' => '', 'screenshotDark' => '', diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index c3a4b3ca96..a27ce4b2ba 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -156,6 +156,8 @@ class Create extends Base 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $site->getAttribute('outputDirectory', ''), + 'adapter' => $site->getAttribute('adapter', ''), + 'fallbackFile' => $site->getAttribute('fallbackFile', ''), 'type' => 'manual', 'search' => implode(' ', [$deploymentId]), 'activate' => $activate, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index ada665267a..1a39edea46 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -64,7 +64,8 @@ class Create extends Base ->param('siteId', '', new CustomId(), 'Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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.') ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.') - ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) // TODO: Add logging param later + ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) + ->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true) ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_COMPUTE_TIMEOUT', 900)), 'Maximum request time in seconds.', true) ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) @@ -96,6 +97,7 @@ class Create extends Base string $name, string $framework, bool $enabled, + bool $logging, int $timeout, string $installCommand, string $buildCommand, @@ -140,6 +142,7 @@ class Create extends Base '$id' => $siteId, 'enabled' => $enabled, 'live' => true, + 'logging' => $logging, 'name' => $name, 'framework' => $framework, 'deploymentInternalId' => '', diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index b971c4c4f3..416062862a 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -68,7 +68,8 @@ class Update extends Base ->param('siteId', '', new UID(), 'Site ID.') ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.') - ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) // TODO: Add logging param later + ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) + ->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true) ->param('timeout', 15, new Range(1, (int) System::getEnv('_APP_COMPUTE_TIMEOUT', 900)), 'Maximum request time in seconds.', true) ->param('installCommand', '', new Text(8192, 0), 'Install Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) @@ -103,6 +104,7 @@ class Update extends Base string $name, string $framework, bool $enabled, + bool $logging, int $timeout, string $installCommand, string $buildCommand, @@ -246,6 +248,7 @@ class Update extends Base 'name' => $name, 'framework' => $framework, 'enabled' => $enabled, + 'logging' => $logging, 'live' => $live, 'timeout' => $timeout, 'installCommand' => $installCommand, diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index e0929684fb..e33d7663fd 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -55,7 +55,7 @@ class Func extends Model ]) ->addRule('logging', [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.', + 'description' => 'When disabled, executions will exclude logs and errors, and will be slightly faster.', 'default' => true, 'example' => false, ]) diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index 478b7881b3..e6e205909b 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -46,6 +46,12 @@ class Site extends Model 'default' => true, 'example' => false, ]) + ->addRule('logging', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', + 'default' => true, + 'example' => false, + ]) ->addRule('framework', [ 'type' => self::TYPE_STRING, 'description' => 'Site framework.', diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index a0880b0a4e..d0cc3b5ba5 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -539,6 +539,88 @@ class SitesCustomServerTest extends Scope $this->cleanupSite($siteId); } + public function testSettingsForRollback(): void + { + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Static site', + 'framework' => 'astro', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './dist', + 'buildCommand' => 'npm run build', + 'installCommand' => 'npm install', + ]); + $this->assertNotEmpty($siteId); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertEmpty($site['body']['adapter']); + $this->assertEmpty($site['body']['fallbackFile']); + + $domain = $this->setupSiteDomain($siteId); + $this->assertNotEmpty($domain); + + $deploymentId1 = $this->setupDeployment($siteId, [ + 'code' => $this->packageSite('astro-static'), + 'activate' => 'true' + ]); + $this->assertNotEmpty($deploymentId1); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertEquals('static', $site['body']['adapter']); + $this->assertEquals('index.html', $site['body']['fallbackFile']); + + $site = $this->updateSite([ + 'name' => 'SSR site', + 'framework' => 'astro', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './dist', + 'buildCommand' => 'npm run build', + 'installCommand' => 'npm install', + 'adapter' => 'ssr', + 'fallbackFile' => '', + '$id' => $siteId, + ]); + + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertEquals('ssr', $site['body']['adapter']); + $this->assertEmpty($site['body']['fallbackFile']); + + $deploymentId2 = $this->setupDeployment($siteId, [ + 'code' => $this->packageSite('astro'), + 'activate' => 'true' + ]); + $this->assertNotEmpty($deploymentId2); + + $site = $this->getSite($siteId); + $this->assertEquals('200', $site['headers']['status-code']); + $this->assertEquals('ssr', $site['body']['adapter']); + + $proxyClient = new Client(); + $proxyClient->setEndpoint('http://' . $domain); + $response = $proxyClient->call(Client::METHOD_GET, '/'); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro SSR", $response['body']); + $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); + $this->assertEquals(404, $response['headers']['status-code']); + + $response = $this->updateSiteDeployment($siteId, $deploymentId1); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']['$id']); + + $proxyClient = new Client(); + $proxyClient->setEndpoint('http://' . $domain); + $response = $proxyClient->call(Client::METHOD_GET, '/'); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro static", $response['body']); + $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro static", $response['body']); + + $this->cleanupSite($siteId); + } + public function testListSites(): void { /** @@ -1905,6 +1987,57 @@ class SitesCustomServerTest extends Scope $this->assertNotEquals($log1Id, $log2Id); + $site = $this->updateSite( + [ + '$id' => $siteId, + 'name' => 'SSR site', + 'framework' => 'astro', + 'adapter' => 'ssr', + 'buildRuntime' => 'node-22', + 'outputDirectory' => './dist', + 'buildCommand' => 'npm run build', + 'installCommand' => 'npm install', + 'fallbackFile' => '', + 'logging' => false // set logging to false + ] + ); + $this->assertEquals(200, $site['headers']['status-code']); + $response = $proxyClient->call(Client::METHOD_GET, '/logs-inline'); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Inline logs printed.", $response['body']); + + $logs = $this->listLogs($siteId, [ + Query::orderDesc('$createdAt')->toString(), + Query::limit(1)->toString(), + ]); + $this->assertEquals(200, $logs['headers']['status-code']); + $this->assertEquals("GET", $logs['body']['executions'][0]['requestMethod']); + $this->assertEquals("/logs-inline", $logs['body']['executions'][0]['requestPath']); + $this->assertEmpty($logs['body']['executions'][0]['logs']); + $this->assertEmpty($logs['body']['executions'][0]['logs']); + $this->assertEmpty($logs['body']['executions'][0]['errors']); + $this->assertEmpty($logs['body']['executions'][0]['errors']); + $log1Id = $logs['body']['executions'][0]['$id']; + $this->assertNotEmpty($log1Id); + + $response = $proxyClient->call(Client::METHOD_GET, '/logs-action'); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Action logs printed.", $response['body']); + + $logs = $this->listLogs($siteId, [ + Query::orderDesc('$createdAt')->toString(), + Query::limit(1)->toString(), + ]); + $this->assertEquals(200, $logs['headers']['status-code']); + $this->assertEquals("GET", $logs['body']['executions'][0]['requestMethod']); + $this->assertEquals("/logs-action", $logs['body']['executions'][0]['requestPath']); + $this->assertEmpty($logs['body']['executions'][0]['logs']); + $this->assertEmpty($logs['body']['executions'][0]['logs']); + $this->assertEmpty($logs['body']['executions'][0]['errors']); + $this->assertEmpty($logs['body']['executions'][0]['errors']); + $log2Id = $logs['body']['executions'][0]['$id']; + $this->assertNotEmpty($log2Id); + $this->cleanupSite($siteId); }