chore: add allowed attributes to query

This commit is contained in:
Chirag Aggarwal
2025-04-09 13:03:56 +00:00
parent b4b356e61f
commit e8a0425cc3
4 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ _APP_SYSTEM_TEAM_EMAIL=team@appwrite.io
_APP_EMAIL_SECURITY=security@appwrite.io
_APP_EMAIL_CERTIFICATES=certificates@appwrite.io
_APP_SYSTEM_RESPONSE_FORMAT=
_APP_OPTIONS_ABUSE=enabled
_APP_OPTIONS_ABUSE=disabled
_APP_OPTIONS_ROUTER_PROTECTION=disabled
_APP_OPTIONS_FORCE_HTTPS=disabled
_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS=disabled
@@ -12,15 +12,11 @@ use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Exception\Query as QueryException;
use Utopia\Database\Query;
use Utopia\Database\Validator\Queries;
use Utopia\Database\Validator\Query\Cursor;
use Utopia\Database\Validator\Query\Limit;
use Utopia\Database\Validator\Query\Offset;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Text;
use Appwrite\Utopia\Database\Validator\Queries\DevKeys;
class XList extends Action
{
use HTTP;
@@ -53,7 +49,7 @@ class XList extends Action
contentType: ContentType::JSON
))
->param('projectId', '', new UID(), 'Project unique ID.')
->param('queries', [], new Queries([new Limit(), new Offset(), new Cursor()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit, offset and cursor', true)
->param('queries', [], new DevKeys(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit, offset and cursor', true)
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->inject('response')
->inject('dbForPlatform')
@@ -0,0 +1,21 @@
<?php
namespace Appwrite\Utopia\Database\Validator\Queries;
class DevKeys extends Base
{
public const ALLOWED_ATTRIBUTES = [
'name',
'accessedAt',
'expire'
];
/**
* Expression constructor
*
*/
public function __construct()
{
parent::__construct('devKeys', self::ALLOWED_ATTRIBUTES);
}
}
@@ -134,7 +134,7 @@ trait ProjectsDevKeys
]);
$this->assertEquals(400, $response['headers']['status-code']);
$this->assertEquals('Invalid `queries` param: Invalid query method: search', $response['body']['message']);
$this->assertEquals('Searching by attribute "name" requires a fulltext index.', $response['body']['message']);
return $data;
}