mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge branch 'feat-sites' into chore-add-template-tests-to-sites
This commit is contained in:
commit
ab7041d653
29 files changed
+165
-61
No files matched your search
@@ -84,7 +84,7 @@ class Base extends Action
|
||||
'providerCommitHash' => $commitDetails['commitHash'] ?? '',
|
||||
'providerCommitAuthorUrl' => $authorUrl,
|
||||
'providerCommitAuthor' => $commitDetails['commitAuthor'] ?? '',
|
||||
'providerCommitMessage' => $commitDetails['commitMessage'] ?? '',
|
||||
'providerCommitMessage' => mb_strimwidth($commitDetails['commitMessage'] ?? '', 0, 255, '...'),
|
||||
'providerCommitUrl' => $commitDetails['commitUrl'] ?? '',
|
||||
'providerBranch' => $providerBranch,
|
||||
'providerRootDirectory' => $function->getAttribute('providerRootDirectory', ''),
|
||||
@@ -172,7 +172,7 @@ class Base extends Action
|
||||
'providerCommitHash' => $commitDetails['commitHash'] ?? '',
|
||||
'providerCommitAuthorUrl' => $authorUrl,
|
||||
'providerCommitAuthor' => $commitDetails['commitAuthor'] ?? '',
|
||||
'providerCommitMessage' => $commitDetails['commitMessage'] ?? '',
|
||||
'providerCommitMessage' => mb_strimwidth($commitDetails['commitMessage'] ?? '', 0, 255, '...'),
|
||||
'providerCommitUrl' => $commitDetails['commitUrl'] ?? '',
|
||||
'providerBranch' => $providerBranch,
|
||||
'providerRootDirectory' => $site->getAttribute('providerRootDirectory', ''),
|
||||
|
||||
@@ -49,7 +49,7 @@ class Get extends Action
|
||||
],
|
||||
contentType: ContentType::NONE,
|
||||
))
|
||||
->label('abuse-limit', 10)
|
||||
->label('abuse-limit', 120)
|
||||
->label('abuse-key', 'userId:{userId}, url:{url}')
|
||||
->label('abuse-time', 60)
|
||||
->param('value', '', new Text(256), 'Resource value.')
|
||||
|
||||
@@ -249,7 +249,6 @@ class Create extends Base
|
||||
'errors' => '',
|
||||
'logs' => '',
|
||||
'duration' => 0.0,
|
||||
'search' => implode(' ', [$functionId, $executionId]),
|
||||
]);
|
||||
|
||||
$queueForEvents
|
||||
|
||||
@@ -19,7 +19,6 @@ use Utopia\Database\Validator\Query\Cursor;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
class XList extends Base
|
||||
{
|
||||
@@ -55,13 +54,12 @@ class XList extends Base
|
||||
))
|
||||
->param('functionId', '', new UID(), 'Function ID.')
|
||||
->param('queries', [], new Executions(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Executions::ALLOWED_ATTRIBUTES), true)
|
||||
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(string $functionId, array $queries, string $search, Response $response, Database $dbForProject)
|
||||
public function action(string $functionId, array $queries, Response $response, Database $dbForProject)
|
||||
{
|
||||
$function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId));
|
||||
|
||||
@@ -78,10 +76,6 @@ class XList extends Base
|
||||
throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage());
|
||||
}
|
||||
|
||||
if (!empty($search)) {
|
||||
$queries[] = Query::search('search', $search);
|
||||
}
|
||||
|
||||
// Set internal queries
|
||||
$queries[] = Query::equal('resourceInternalId', [$function->getInternalId()]);
|
||||
$queries[] = Query::equal('resourceType', ['functions']);
|
||||
|
||||
@@ -97,6 +97,7 @@ class Update extends Base
|
||||
Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||
|
||||
$queries = [
|
||||
Query::equal('trigger', 'manual'),
|
||||
Query::equal("type", ["deployment"]),
|
||||
Query::equal("deploymentResourceType", ["function"]),
|
||||
Query::equal("deploymentResourceInternalId", [$function->getInternalId()]),
|
||||
|
||||
@@ -53,7 +53,7 @@ class Get extends Base
|
||||
|
||||
public function action(string $templateId, Response $response)
|
||||
{
|
||||
$templates = Config::getParam('function-templates', []);
|
||||
$templates = Config::getParam('templates-function', []);
|
||||
|
||||
$filtered = \array_filter($templates, function ($template) use ($templateId) {
|
||||
return $template['id'] === $templateId;
|
||||
|
||||
@@ -57,7 +57,7 @@ class XList extends Base
|
||||
|
||||
public function action(array $runtimes, array $usecases, int $limit, int $offset, Response $response)
|
||||
{
|
||||
$templates = Config::getParam('function-templates', []);
|
||||
$templates = Config::getParam('templates-function', []);
|
||||
|
||||
if (!empty($runtimes)) {
|
||||
$templates = \array_filter($templates, function ($template) use ($runtimes) {
|
||||
|
||||
@@ -493,8 +493,11 @@ class Builds extends Action
|
||||
$vars[$var->getAttribute('key')] = $var->getAttribute('value', '');
|
||||
}
|
||||
|
||||
// Some runtimes/frameworks can't compile with less memory than this
|
||||
$minMemory = $resource->getCollection() === 'sites' ? 2048 : 1024;
|
||||
|
||||
$cpus = $spec['cpus'] ?? APP_COMPUTE_CPUS_DEFAULT;
|
||||
$memory = max($spec['memory'] ?? APP_COMPUTE_MEMORY_DEFAULT, 1024); // We have a minimum of 1024MB here because some runtimes can't compile with less memory than this.
|
||||
$memory = max($spec['memory'] ?? APP_COMPUTE_MEMORY_DEFAULT, $minMemory);
|
||||
$timeout = (int) System::getEnv('_APP_COMPUTE_BUILD_TIMEOUT', 900);
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ use Utopia\Database\Validator\Query\Cursor;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
use Utopia\Validator\Text;
|
||||
|
||||
class XList extends Base
|
||||
{
|
||||
@@ -54,13 +53,12 @@ class XList extends Base
|
||||
))
|
||||
->param('siteId', '', new UID(), 'Site ID.')
|
||||
->param('queries', [], new Logs(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Executions::ALLOWED_ATTRIBUTES), true)
|
||||
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(string $siteId, array $queries, string $search, Response $response, Database $dbForProject)
|
||||
public function action(string $siteId, array $queries, Response $response, Database $dbForProject)
|
||||
{
|
||||
$site = $dbForProject->getDocument('sites', $siteId);
|
||||
|
||||
@@ -74,10 +72,6 @@ class XList extends Base
|
||||
throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage());
|
||||
}
|
||||
|
||||
if (!empty($search)) {
|
||||
$queries[] = Query::search('search', $search);
|
||||
}
|
||||
|
||||
// Set internal queries
|
||||
$queries[] = Query::equal('resourceInternalId', [$site->getInternalId()]);
|
||||
$queries[] = Query::equal('resourceType', ['sites']);
|
||||
|
||||
@@ -86,6 +86,7 @@ class Update extends Base
|
||||
])));
|
||||
|
||||
$queries = [
|
||||
Query::equal('trigger', 'manual'),
|
||||
Query::equal("type", ["deployment"]),
|
||||
Query::equal("deploymentResourceType", ["site"]),
|
||||
Query::equal("deploymentResourceInternalId", [$site->getInternalId()]),
|
||||
|
||||
@@ -98,8 +98,33 @@ 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 $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
|
||||
) {
|
||||
if (!empty($adapter)) {
|
||||
$configFramework = Config::getParam('frameworks')[$framework] ?? [];
|
||||
$adapters = \array_keys($configFramework['adapters'] ?? []);
|
||||
|
||||
@@ -53,7 +53,7 @@ class Get extends Base
|
||||
|
||||
public function action(string $templateId, Response $response)
|
||||
{
|
||||
$templates = Config::getParam('site-templates', []);
|
||||
$templates = Config::getParam('templates-site', []);
|
||||
|
||||
$allowedTemplates = \array_filter($templates, function ($item) use ($templateId) {
|
||||
return $item['key'] === $templateId;
|
||||
|
||||
@@ -57,7 +57,7 @@ class XList extends Base
|
||||
|
||||
public function action(array $frameworks, array $usecases, int $limit, int $offset, Response $response)
|
||||
{
|
||||
$templates = Config::getParam('site-templates', []);
|
||||
$templates = Config::getParam('templates-site', []);
|
||||
|
||||
if (!empty($frameworks)) {
|
||||
$templates = \array_filter($templates, function ($template) use ($frameworks) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Screenshot extends Action
|
||||
|
||||
public function action(string $templateId): void
|
||||
{
|
||||
$templates = Config::getParam('site-templates', []);
|
||||
$templates = Config::getParam('templates-site', []);
|
||||
|
||||
$allowedTemplates = \array_filter($templates, function ($item) use ($templateId) {
|
||||
return $item['key'] === $templateId;
|
||||
@@ -46,6 +46,10 @@ class Screenshot extends Action
|
||||
// Register
|
||||
$email = uniqid() . 'user@localhost.test';
|
||||
$password = 'password';
|
||||
|
||||
Console::info("Email: {$email}");
|
||||
Console::info("Pass: {$password}");
|
||||
|
||||
$user = $client->call(Client::METHOD_POST, '/account', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => 'console',
|
||||
@@ -137,11 +141,11 @@ class Screenshot extends Action
|
||||
'name' => $template["name"],
|
||||
'framework' => $framework['key'],
|
||||
'adapter' => $framework['adapter'],
|
||||
'buildCommand' => $framework['buildCommand'],
|
||||
'buildCommand' => $framework['buildCommand'] ?? '',
|
||||
'buildRuntime' => $framework['buildRuntime'],
|
||||
'fallbackFile' => $framework['fallbackFile'],
|
||||
'installCommand' => $framework['installCommand'],
|
||||
'outputDirectory' => $framework['outputDirectory'],
|
||||
'fallbackFile' => $framework['fallbackFile'] ?? '',
|
||||
'installCommand' => $framework['installCommand'] ?? '',
|
||||
'outputDirectory' => $framework['outputDirectory'] ?? '',
|
||||
'providerRootDirectory' => $framework['providerRootDirectory'],
|
||||
'timeout' => 60
|
||||
]);
|
||||
@@ -214,12 +218,17 @@ class Screenshot extends Action
|
||||
$deploymentId = $deployment['body']['$id'];
|
||||
|
||||
// Await screenshot
|
||||
$attempts = 50;
|
||||
$attempts = 60; // 5 min
|
||||
$sleep = 5;
|
||||
|
||||
$idLight = '';
|
||||
$idDark = '';
|
||||
|
||||
if ($templateId === 'starter-for-react-native') {
|
||||
Console::warning("React Native template takes long to build, increasing waiting time ...");
|
||||
$attempts = 180; // 15 min
|
||||
}
|
||||
|
||||
Console::log("Awaiting deployment (every $sleep seconds, $attempts attempts)");
|
||||
|
||||
for ($i = 0; $i < $attempts; $i++) {
|
||||
@@ -279,7 +288,6 @@ class Screenshot extends Action
|
||||
foreach ($themes as $theme) {
|
||||
$file = $client->call(Client::METHOD_GET, '/storage/buckets/screenshots/files/' . $theme['fileId'] . '/download', [
|
||||
'x-appwrite-project' => 'console',
|
||||
'x-appwrite-mode' => 'admin',
|
||||
'cookie' => $cookieConsole
|
||||
]);
|
||||
|
||||
|
||||
@@ -271,7 +271,6 @@ class Functions extends Action
|
||||
'errors' => $message,
|
||||
'logs' => '',
|
||||
'duration' => 0.0,
|
||||
'search' => implode(' ', [$function->getId(), $executionId]),
|
||||
]);
|
||||
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
@@ -407,7 +406,6 @@ class Functions extends Action
|
||||
'errors' => '',
|
||||
'logs' => '',
|
||||
'duration' => 0.0,
|
||||
'search' => implode(' ', [$functionId, $executionId]),
|
||||
]);
|
||||
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Appwrite\Utopia\Database\Validator\Queries;
|
||||
class Logs extends Base
|
||||
{
|
||||
public const ALLOWED_ATTRIBUTES = [
|
||||
'status',
|
||||
'responseStatusCode',
|
||||
'duration',
|
||||
'requestMethod',
|
||||
|
||||
Reference in new issue
Block a user