mirror of
https://github.com/appwrite/appwrite
synced 2026-05-21 16:08:22 +00:00
Merge branch 'feat-sites' into feat-bash-support
This commit is contained in:
commit
06f138b39d
19 changed files with 285 additions and 34 deletions
|
|
@ -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' => [
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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' => '',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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' => '',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
])
|
||||
|
|
|
|||
|
|
@ -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.',
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue