diff --git a/app/config/collections2.php b/app/config/collections2.php index 356738f634..ad3fff71c6 100644 --- a/app/config/collections2.php +++ b/app/config/collections2.php @@ -10,6 +10,7 @@ $collections = [ 'projects' => [ '$collection' => Database::COLLECTIONS, '$id' => 'projects', + 'name' => 'Projects', 'attributes' => [ [ '$id' => 'teamId', @@ -22,6 +23,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'description', 'type' => Database::VAR_STRING, @@ -199,12 +211,21 @@ $collections = [ 'filters' => ['json'], ], ], - 'indexes' => [], + 'indexes' => [ + [ + '$id' => '_fulltext_name', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['name'], + 'lengths' => [1024], + 'orders' => [Database::ORDER_ASC], + ] + ], ], 'users' => [ '$collection' => Database::COLLECTIONS, '$id' => 'users', + 'name' => 'Users', 'attributes' => [ [ '$id' => 'name', @@ -353,6 +374,7 @@ $collections = [ 'sessions' => [ '$collection' => Database::COLLECTIONS, '$id' => 'sessions', + 'name' => 'Sessions', 'attributes' => [ [ '$id' => 'userId', @@ -600,7 +622,19 @@ $collections = [ 'teams' => [ '$collection' => Database::COLLECTIONS, '$id' => 'teams', + 'name' => 'Teams', 'attributes' => [ + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'dateCreated', 'type' => Database::VAR_INTEGER, @@ -624,12 +658,21 @@ $collections = [ 'filters' => [], ], ], - 'indexes' => [], + 'indexes' => [ + [ + '$id' => '_fulltext_name', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['name'], + 'lengths' => [1024], + 'orders' => [Database::ORDER_ASC], + ] + ], ], 'memberships' => [ '$collection' => Database::COLLECTIONS, '$id' => 'memberships', + 'name' => 'Memberships', 'attributes' => [ [ '$id' => 'teamId', @@ -737,6 +780,7 @@ $collections = [ 'files' => [ '$collection' => Database::COLLECTIONS, '$id' => 'files', + 'name' => 'Files', 'attributes' => [ [ '$id' => 'dateCreated', @@ -915,6 +959,7 @@ $collections = [ 'functions' => [ '$collection' => Database::COLLECTIONS, '$id' => 'functions', + 'name' => 'Functions', 'attributes' => [ [ '$id' => 'execute', @@ -927,6 +972,17 @@ $collections = [ 'array' => true, 'filters' => [], ], + [ + '$id' => 'name', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2048, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => 'dateCreated', 'type' => Database::VAR_INTEGER, @@ -1050,12 +1106,21 @@ $collections = [ 'filters' => [], ], ], - 'indexes' => [], + 'indexes' => [ + [ + '$id' => '_fulltext_name', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['name'], + 'lengths' => [1024], + 'orders' => [Database::ORDER_ASC], + ] + ], ], 'tags' => [ '$collection' => Database::COLLECTIONS, '$id' => 'tags', + 'name' => 'Tags', 'attributes' => [ [ '$id' => 'dateCreated', @@ -1128,6 +1193,7 @@ $collections = [ 'executions' => [ '$collection' => Database::COLLECTIONS, '$id' => 'executions', + 'name' => 'Executions', 'attributes' => [ [ '$id' => 'dateCreated', @@ -1244,6 +1310,7 @@ $collections = [ 'certificates' => [ '$collection' => Database::COLLECTIONS, '$id' => 'certificates', + 'name' => 'Certificates', 'attributes' => [ [ '$id' => 'domain', diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 60f0f848cd..7416b031ac 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -37,12 +37,13 @@ App::post('/v1/database/collections') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_COLLECTION) ->param('collectionId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') + ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') ->param('read', null, new Permissions(), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', null, new Permissions(), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->inject('response') ->inject('dbForExternal') ->inject('audits') - ->action(function ($collectionId, $read, $write, $response, $dbForExternal, $audits) { + ->action(function ($collectionId, $name, $read, $write, $response, $dbForExternal, $audits) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForExternal*/ /** @var Appwrite\Event\Event $audits */ @@ -55,6 +56,7 @@ App::post('/v1/database/collections') $read = (is_null($read)) ? ($collection->getRead() ?? []) : $read; // By default inherit read permissions $write = (is_null($write)) ? ($collection->getWrite() ?? []) : $write; // By default inherit write permissions + $collection->setAttribute('name', $name); $collection->setAttribute('$read', $read); $collection->setAttribute('$write', $write); @@ -139,12 +141,13 @@ App::put('/v1/database/collections/:collectionId') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_COLLECTION) ->param('collectionId', '', new UID(), 'Collection unique ID.') + ->param('name', null, new Text(128), 'Collection name. Max length: 128 chars.') ->param('read', null, new Permissions(), 'An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) ->param('write', null, new Permissions(), 'An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) ->inject('response') ->inject('dbForExternal') ->inject('audits') - ->action(function ($collectionId, $read, $write, $response, $dbForExternal, $audits) { + ->action(function ($collectionId, $name, $read, $write, $response, $dbForExternal, $audits) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForExternal */ /** @var Appwrite\Event\Event $audits */ @@ -160,6 +163,7 @@ App::put('/v1/database/collections/:collectionId') try { $collection = $dbForExternal->updateDocument(Database::COLLECTIONS, $collection->getId(), new Document(\array_merge($collection->getArrayCopy(), [ + 'name' => $name, '$read' => $read, '$write' => $write ]))); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 9a5ef8ed71..292e42bed0 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -40,6 +40,7 @@ App::post('/v1/functions') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_FUNCTION) ->param('functionId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') + ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') ->param('execute', [], new ArrayList(new Text(64)), 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.') ->param('vars', [], new Assoc(), 'Key-value JSON object.', true) @@ -48,7 +49,7 @@ App::post('/v1/functions') ->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true) ->inject('response') ->inject('dbForInternal') - ->action(function ($functionId, $execute, $runtime, $vars, $events, $schedule, $timeout, $response, $dbForInternal) { + ->action(function ($functionId, $name, $execute, $runtime, $vars, $events, $schedule, $timeout, $response, $dbForInternal) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForInternal */ @@ -58,6 +59,7 @@ App::post('/v1/functions') 'dateCreated' => time(), 'dateUpdated' => time(), 'status' => 'disabled', + 'name' => $name, 'runtime' => $runtime, 'tag' => '', 'vars' => $vars, diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index c25b70cc26..3bc8740ccb 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -35,6 +35,7 @@ App::post('/v1/projects') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_PROJECT) ->param('projectId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') + ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) @@ -50,7 +51,7 @@ App::post('/v1/projects') ->inject('dbForInternal') ->inject('dbForExternal') ->inject('consoleDB') - ->action(function ($projectId, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal, $consoleDB) { + ->action(function ($projectId, $name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $dbForConsole, $dbForInternal, $dbForExternal, $consoleDB) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Database $dbForInternal */ @@ -68,6 +69,7 @@ App::post('/v1/projects') '$collection' => 'projects', '$read' => ['team:' . $teamId], '$write' => ['team:' . $teamId . '/owner', 'team:' . $teamId . '/developer'], + 'name' => $name, 'teamId' => $team->getId(), 'description' => $description, 'logo' => $logo, @@ -606,6 +608,7 @@ App::post('/v1/projects/:projectId/webhooks') ->label('sdk.response.model', Response::MODEL_WEBHOOK) ->param('webhookId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Webhook name. Max length: 128 chars.') ->param('events', null, new ArrayList(new WhiteList(array_keys(Config::getParam('events'), true), true)), 'Events list.') ->param('url', null, new URL(), 'Webhook URL.') ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') @@ -613,7 +616,7 @@ App::post('/v1/projects/:projectId/webhooks') ->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($webhookId, $projectId, $events, $url, $security, $httpUser, $httpPass, $response, $dbForConsole) { + ->action(function ($webhookId, $projectId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -627,6 +630,7 @@ App::post('/v1/projects/:projectId/webhooks') $webhook = new Document([ '$id' => $webhookId == 'unique()' ? $dbForConsole->getId() : $webhookId, + 'name' => $name, 'events' => $events, 'url' => $url, 'security' => $security, @@ -718,6 +722,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') ->label('sdk.response.model', Response::MODEL_WEBHOOK) ->param('projectId', null, new UID(), 'Project unique ID.') ->param('webhookId', null, new UID(), 'Webhook unique ID.') + ->param('name', null, new Text(128), 'Webhook name. Max length: 128 chars.') ->param('events', null, new ArrayList(new WhiteList(array_keys(Config::getParam('events'), true), true)), 'Events list.') ->param('url', null, new URL(), 'Webhook URL.') ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') @@ -725,7 +730,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') ->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($projectId, $webhookId, $events, $url, $security, $httpUser, $httpPass, $response, $dbForConsole) { + ->action(function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -744,6 +749,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') } $project->findAndReplace('$id', $webhook->getId(), $webhook + ->setAttribute('name', $name) ->setAttribute('events', $events) ->setAttribute('url', $url) ->setAttribute('security', $security) @@ -802,10 +808,11 @@ App::post('/v1/projects/:projectId/keys') ->label('sdk.response.model', Response::MODEL_KEY) ->param('keyId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('scopes', null, new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true)), 'Key scopes list.') ->inject('response') ->inject('dbForConsole') - ->action(function ($keyId, $projectId, $scopes, $response, $dbForConsole) { + ->action(function ($keyId, $projectId, $name, $scopes, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -817,6 +824,7 @@ App::post('/v1/projects/:projectId/keys') $key = new Document([ '$id' => $keyId == 'unique()' ? $dbForConsole->getId() : $keyId, + 'name' => $name, 'scopes' => $scopes, 'secret' => \bin2hex(\random_bytes(128)), ]); @@ -902,6 +910,7 @@ App::put('/v1/projects/:projectId/keys/:keyId') ->label('sdk.response.model', Response::MODEL_KEY) ->param('projectId', null, new UID(), 'Project unique ID.') ->param('keyId', null, new UID(), 'Key unique ID.') + ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('scopes', null, new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true)), 'Key scopes list') ->inject('response') ->inject('dbForConsole') @@ -977,6 +986,7 @@ App::post('/v1/projects/:projectId/tasks') ->label('sdk.response.model', Response::MODEL_TASK) ->param('taskId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') ->param('projectId', null, new UID(), 'Project unique ID.') + ->param('name', null, new Text(128), 'Task name. Max length: 128 chars.') ->param('status', null, new WhiteList(['play', 'pause'], true), 'Task status.') ->param('schedule', null, new Cron(), 'Task schedule CRON syntax.') ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') @@ -987,7 +997,7 @@ App::post('/v1/projects/:projectId/tasks') ->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($taskId, $projectId, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $dbForConsole) { + ->action(function ($taskId, $projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -1004,6 +1014,7 @@ App::post('/v1/projects/:projectId/tasks') $task = new Document([ '$id' => $taskId == 'unique()' ? $dbForConsole->getId() : $taskId, 'projectId' => $project->getId(), + 'name' => $name, 'status' => $status, 'schedule' => $schedule, 'updated' => \time(), @@ -1108,6 +1119,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId') ->label('sdk.response.model', Response::MODEL_TASK) ->param('projectId', null, new UID(), 'Project unique ID.') ->param('taskId', null, new UID(), 'Task unique ID.') + ->param('name', null, new Text(128), 'Task name. Max length: 128 chars.') ->param('status', null, new WhiteList(['play', 'pause'], true), 'Task status.') ->param('schedule', null, new Cron(), 'Task schedule CRON syntax.') ->param('security', false, new Boolean(true), 'Certificate verification, false for disabled or true for enabled.') @@ -1118,7 +1130,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId') ->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($projectId, $taskId, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $dbForConsole) { + ->action(function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -1139,6 +1151,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId') $security = ($security === '1' || $security === 'true' || $security === 1 || $security === true); $project->findAndReplace('$id', $task->getId(), $task + ->setAttribute('name', $name) ->setAttribute('status', $status) ->setAttribute('schedule', $schedule) ->setAttribute('updated', \time()) @@ -1207,12 +1220,13 @@ App::post('/v1/projects/:projectId/platforms') ->param('platformId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('type', null, new WhiteList(['web', 'flutter-ios', 'flutter-android', 'flutter-linux', 'flutter-macos', 'flutter-windows', 'ios', 'android', 'unity'], true), 'Platform type.') + ->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.') ->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true) ->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true) ->param('hostname', '', new Text(256), 'Platform client hostname. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($platformId, $projectId, $type, $key, $store, $hostname, $response, $dbForConsole) { + ->action(function ($platformId, $projectId, $type, $name, $key, $store, $hostname, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -1225,6 +1239,7 @@ App::post('/v1/projects/:projectId/platforms') $platform = new Document([ '$id' => $platformId == 'unique()' ? $dbForConsole->getId() : $platformId, 'type' => $type, + 'name' => $name, 'key' => $key, 'store' => $store, 'hostname' => $hostname, @@ -1316,12 +1331,13 @@ App::put('/v1/projects/:projectId/platforms/:platformId') ->label('sdk.response.model', Response::MODEL_PLATFORM) ->param('projectId', null, new UID(), 'Project unique ID.') ->param('platformId', null, new UID(), 'Platform unique ID.') + ->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.') ->param('key', '', new Text(256), 'Package name for android or bundle ID for iOS. Max length: 256 chars.', true) ->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true) ->param('hostname', '', new Text(256), 'Platform client URL. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function ($projectId, $platformId, $key, $store, $hostname, $response, $dbForConsole) { + ->action(function ($projectId, $platformId, $name, $key, $store, $hostname, $response, $dbForConsole) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForConsole */ @@ -1338,6 +1354,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId') } $platform + ->setAttribute('name', $name) ->setAttribute('dateUpdated', \time()) ->setAttribute('key', $key) ->setAttribute('store', $store) @@ -1345,6 +1362,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId') ; $project->findAndReplace('$id', $platform->getId(), $platform + ->setAttribute('name', $name) ->setAttribute('dateUpdated', \time()) ->setAttribute('key', $key) ->setAttribute('store', $store) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 64949a87b7..0a80970c48 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -34,11 +34,12 @@ App::post('/v1/teams') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_TEAM) ->param('teamId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, and underscore. Can\'t start with a leading underscore. Max length is 36 chars.') + ->param('name', null, new Text(128), 'Team name. Max length: 128 chars.') ->param('roles', ['owner'], new ArrayList(new Key()), 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', true) ->inject('response') ->inject('user') ->inject('dbForInternal') - ->action(function ($teamId, $roles, $response, $user, $dbForInternal) { + ->action(function ($teamId, $name, $roles, $response, $user, $dbForInternal) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Document $user */ /** @var Utopia\Database\Database $dbForInternal */ @@ -53,6 +54,7 @@ App::post('/v1/teams') '$id' => $teamId , '$read' => ['team:'.$teamId], '$write' => ['team:'.$teamId .'/owner'], + 'name' => $name, 'sum' => ($isPrivilegedUser || $isAppUser) ? 0 : 1, 'dateCreated' => \time(), ])); @@ -142,6 +144,37 @@ App::get('/v1/teams/:teamId') $response->dynamic($team, Response::MODEL_TEAM); }); +App::put('/v1/teams/:teamId') + ->desc('Update Team') + ->groups(['api', 'teams']) + ->label('event', 'teams.update') + ->label('scope', 'teams.write') + ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) + ->label('sdk.namespace', 'teams') + ->label('sdk.method', 'update') + ->label('sdk.description', '/docs/references/teams/update-team.md') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->label('sdk.response.model', Response::MODEL_TEAM) + ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('name', null, new Text(128), 'Team name. Max length: 128 chars.') + ->inject('response') + ->inject('dbForInternal') + ->action(function ($teamId, $name, $response, $dbForInternal) { + /** @var Appwrite\Utopia\Response $response */ + /** @var Utopia\Database\Database $dbForInternal */ + + $team = $dbForInternal->getDocument('teams', $teamId); + + if ($team->isEmpty()) { + throw new Exception('Team not found', 404); + } + + $team = $dbForInternal->updateDocument('teams', $team->getId(), $team->setAttribute('name', $name)); + + $response->dynamic($team, Response::MODEL_TEAM); + }); + App::delete('/v1/teams/:teamId') ->desc('Delete Team') ->groups(['api', 'teams']) diff --git a/app/views/console/comps/header.phtml b/app/views/console/comps/header.phtml index ee764ff835..06e30d4a5a 100644 --- a/app/views/console/comps/header.phtml +++ b/app/views/console/comps/header.phtml @@ -15,7 +15,7 @@ data-ls-bind="{{router.params.project}}" data-unsync="1" data-ls-loop="projects.projects" data-ls-as="option" aria-label="Switch Project"> - + @@ -212,11 +212,14 @@ data-analytics-label="Create Project">
Appwrite projects are containers for your resources and apps across different platforms.
+ + + - + @@ -195,6 +195,9 @@ $maxCells = 10;