mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Merge branch 'feat-sites' into feat-add-sites-comments
This commit is contained in:
commit
f710ce266b
14 changed files with 74 additions and 35 deletions
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
|
@ -142,7 +142,7 @@ jobs:
|
|||
run: |
|
||||
docker load --input /tmp/${{ env.IMAGE }}.tar
|
||||
docker compose up -d
|
||||
sleep 30
|
||||
sleep 60
|
||||
|
||||
- name: Run ${{matrix.service}} Tests
|
||||
run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug
|
||||
|
|
|
|||
|
|
@ -4042,9 +4042,9 @@ $projectCollections = array_merge([
|
|||
'size' => 1000000,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => '',
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
'default' => [],
|
||||
'array' => true,
|
||||
'filters' => ['json'],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('sourceType'),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ return [
|
|||
'sveltekit' => [
|
||||
'key' => 'sveltekit',
|
||||
'name' => 'SvelteKit',
|
||||
'logo' => 'sveltekit.png',
|
||||
'defaultServeRuntime' => 'node-22',
|
||||
'serveRuntimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
|
||||
'defaultBuildRuntime' => 'node-22',
|
||||
|
|
@ -28,7 +27,6 @@ return [
|
|||
'nextjs' => [
|
||||
'key' => 'nextjs',
|
||||
'name' => 'Next.js',
|
||||
'logo' => 'nextjs.png',
|
||||
'defaultServeRuntime' => 'node-22',
|
||||
'serveRuntimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
|
||||
'defaultBuildRuntime' => 'node-22',
|
||||
|
|
@ -37,7 +35,6 @@ return [
|
|||
'static' => [
|
||||
'key' => 'static',
|
||||
'name' => 'Static',
|
||||
'logo' => 'static.png',
|
||||
'defaultServeRuntime' => 'static-1',
|
||||
'serveRuntimes' => [
|
||||
'static-1'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
const TEMPLATE_FRAMEWORKS = [
|
||||
'SVELTEKIT' => [
|
||||
'name' => 'Svelte Kit',
|
||||
'key' => 'sveltekit',
|
||||
'name' => 'SvelteKit',
|
||||
'installCommand' => 'npm install',
|
||||
'buildCommand' => 'npm run build',
|
||||
'outputDirectory' => './build',
|
||||
|
|
@ -19,7 +20,7 @@ function getFramework(string $frameworkEnum, array $overrides)
|
|||
|
||||
return [
|
||||
[
|
||||
'id' => 'starter',
|
||||
'key' => 'starter',
|
||||
'name' => 'Personal portfolio',
|
||||
'useCases' => ['starter'],
|
||||
'frameworks' => [
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ $image = $this->getParam('image', '');
|
|||
<<: *x-logging
|
||||
restart: unless-stopped
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.6.26
|
||||
image: openruntimes/executor:0.7.0
|
||||
networks:
|
||||
- appwrite
|
||||
- runtimes
|
||||
|
|
|
|||
|
|
@ -879,7 +879,7 @@ services:
|
|||
hostname: exc1
|
||||
<<: *x-logging
|
||||
stop_signal: SIGINT
|
||||
image: openruntimes/executor:0.6.26
|
||||
image: openruntimes/executor:0.7.0
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- appwrite
|
||||
|
|
|
|||
|
|
@ -344,6 +344,16 @@ class Realtime extends Adapter
|
|||
$roles = [Role::team($project->getAttribute('teamId'))->toString()];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'sites':
|
||||
if ($parts[2] === 'deployments') {
|
||||
$channels[] = 'console';
|
||||
$channels[] = 'projects.' . $project->getId();
|
||||
$projectId = 'console';
|
||||
$roles = [Role::team($project->getAttribute('teamId'))->toString()];
|
||||
}
|
||||
|
||||
break;
|
||||
case 'migrations':
|
||||
$channels[] = 'console';
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class Builds extends Action
|
|||
'runtime' => $resource->getAttribute('runtime'),
|
||||
'source' => $deployment->getAttribute('path', ''),
|
||||
'sourceType' => strtolower($deviceForFunctions->getType()),
|
||||
'logs' => '',
|
||||
'logs' => [],
|
||||
'endTime' => null,
|
||||
'duration' => 0,
|
||||
'size' => 0
|
||||
|
|
@ -610,9 +610,29 @@ class Builds extends Action
|
|||
return;
|
||||
}
|
||||
|
||||
$logs = \mb_substr($logs, 0, null, 'UTF-8'); // Get only valid UTF8 part - removes leftover half-multibytes causing SQL errors
|
||||
// Get only valid UTF8 part - removes leftover half-multibytes causing SQL errors
|
||||
$logs = \mb_substr($logs, 0, null, 'UTF-8');
|
||||
|
||||
$build = $build->setAttribute('logs', $build->getAttribute('logs', '') . $logs);
|
||||
$currentChunks = $build->getAttribute('logs', []);
|
||||
|
||||
// Parse styled×tamped logs
|
||||
$streamChunks = [];
|
||||
$streamLogs = \str_replace("\\n", "{APPWRITE_LINEBREAK_PLACEHOLDER}", $logs);
|
||||
foreach (\explode("\n", $streamLogs) as $streamLog) {
|
||||
if (empty($streamLog)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$streamLog = \str_replace("{APPWRITE_LINEBREAK_PLACEHOLDER}", "\n", $streamLog);
|
||||
$streamParts = \explode(" ", $streamLog, 2);
|
||||
|
||||
$currentChunks[] = [
|
||||
'timestamp' => $streamParts[0] ?? '',
|
||||
'content' => $streamParts[1] ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$build = $build->setAttribute('logs', $currentChunks);
|
||||
$build = $dbForProject->updateDocument('builds', $build->getId(), $build);
|
||||
|
||||
/**
|
||||
|
|
@ -666,7 +686,7 @@ class Builds extends Action
|
|||
$build->setAttribute('status', 'ready');
|
||||
$build->setAttribute('path', $response['path']);
|
||||
$build->setAttribute('size', $response['size']);
|
||||
$build->setAttribute('logs', $response['output']);
|
||||
// $build->setAttribute('logs', $response['output']); // TODO: Figure out how to write them all at the end
|
||||
|
||||
$build = $dbForProject->updateDocument('builds', $buildId, $build);
|
||||
|
||||
|
|
@ -744,7 +764,14 @@ class Builds extends Action
|
|||
$build->setAttribute('endTime', $endTime);
|
||||
$build->setAttribute('duration', \intval(\ceil($durationEnd - $durationStart)));
|
||||
$build->setAttribute('status', 'failed');
|
||||
$build->setAttribute('logs', $th->getMessage());
|
||||
|
||||
$datetime = new \DateTime();
|
||||
$build->setAttribute('logs', [
|
||||
[
|
||||
'timestamp' => $datetime->format('Y-m-d\TH:i:s.vP'),
|
||||
'content' => "[31m" . $th->getMessage() . "[0m"
|
||||
]
|
||||
]);
|
||||
|
||||
$build = $dbForProject->updateDocument('builds', $buildId, $build);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
namespace Appwrite\Platform\Modules\Sites\Http\Deployments;
|
||||
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Query;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
|
|
@ -38,12 +39,13 @@ class GetDeployment extends Action
|
|||
->param('siteId', '', new UID(), 'Site ID.')
|
||||
->param('deploymentId', '', new UID(), 'Deployment ID.')
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('dbForProject')
|
||||
->inject('dbForConsole')
|
||||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(string $siteId, string $deploymentId, Response $response, Database $dbForProject, Database $dbForConsole)
|
||||
public function action(string $siteId, string $deploymentId, Response $response, Document $project, Database $dbForProject, Database $dbForConsole)
|
||||
{
|
||||
$site = $dbForProject->getDocument('sites', $siteId);
|
||||
|
||||
|
|
@ -69,8 +71,9 @@ class GetDeployment extends Action
|
|||
$deployment->setAttribute('size', $deployment->getAttribute('size', 0));
|
||||
|
||||
$rule = Authorization::skip(fn () => $dbForConsole->findOne('rules', [
|
||||
Query::equal("projectInternalId", [$project->getInternalId()]),
|
||||
Query::equal("resourceType", ["deployment"]),
|
||||
Query::equal("resourceId", [$deployment->getId()])
|
||||
Query::equal("resourceInternalId", [$deployment->getInternalId()])
|
||||
]));
|
||||
|
||||
if (!empty($rule)) {
|
||||
|
|
|
|||
|
|
@ -44,12 +44,13 @@ class ListDeployments extends Action
|
|||
->param('queries', [], new Deployments(), '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(', ', Deployments::ALLOWED_ATTRIBUTES), true)
|
||||
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
|
||||
->inject('response')
|
||||
->inject('project')
|
||||
->inject('dbForProject')
|
||||
->inject('dbForConsole')
|
||||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(string $siteId, array $queries, string $search, Response $response, Database $dbForProject, Database $dbForConsole)
|
||||
public function action(string $siteId, array $queries, string $search, Response $response, Document $project, Database $dbForProject, Database $dbForConsole)
|
||||
{
|
||||
$site = $dbForProject->getDocument('sites', $siteId);
|
||||
|
||||
|
|
@ -110,8 +111,9 @@ class ListDeployments extends Action
|
|||
$result->setAttribute('size', $result->getAttribute('size', 0));
|
||||
|
||||
$rule = Authorization::skip(fn () => $dbForConsole->findOne('rules', [
|
||||
Query::equal("projectInternalId", [$project->getInternalId()]),
|
||||
Query::equal("resourceType", ["deployment"]),
|
||||
Query::equal("resourceId", [$result->getId()])
|
||||
Query::equal("resourceInternalId", [$result->getInternalId()])
|
||||
]));
|
||||
|
||||
if (!empty($rule)) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ class ListFrameworks extends Base
|
|||
continue;
|
||||
}
|
||||
|
||||
$framework['$id'] = $id;
|
||||
$allowed[] = $framework;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,6 @@ class Framework extends Model
|
|||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Framework ID.',
|
||||
'default' => '',
|
||||
'example' => 'sveltekit',
|
||||
])
|
||||
->addRule('key', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Parent framework key.',
|
||||
|
|
|
|||
|
|
@ -10,12 +10,18 @@ class TemplateFramework extends Model
|
|||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Framework Name.',
|
||||
'default' => '',
|
||||
'example' => 'sveltekit',
|
||||
])
|
||||
->addRule('key', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Parent framework key.',
|
||||
'default' => '',
|
||||
'example' => 'sveltekit',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Framework Name.',
|
||||
'default' => '',
|
||||
'example' => 'SvelteKit'
|
||||
])
|
||||
->addRule('installCommand', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The install command used to install the dependencies.',
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TemplateSite extends Model
|
|||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('id', [
|
||||
->addRule('key', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site Template ID.',
|
||||
'default' => '',
|
||||
|
|
|
|||
Loading…
Reference in a new issue