From 0460b59cdc0d3e19298a9619e6924bb4c2636fe4 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 27 Apr 2023 14:59:05 +0300 Subject: [PATCH] Namespace Changes --- app/controllers/api/databases.php | 8 ++- composer.lock | 8 +-- src/Appwrite/GraphQL/Types/Mapper.php | 4 +- .../Specification/Format/OpenAPI3.php | 4 +- .../Specification/Format/Swagger2.php | 4 +- .../Database/Validator/Queries/Document.php | 41 --------------- .../Database/Validator/Queries/Documents.php | 52 ------------------- 7 files changed, 13 insertions(+), 108 deletions(-) delete mode 100644 src/Appwrite/Utopia/Database/Validator/Queries/Document.php delete mode 100644 src/Appwrite/Utopia/Database/Validator/Queries/Documents.php diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index a0048773e4..c997ae6315 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -46,10 +46,8 @@ use Appwrite\Event\Event; use Utopia\Database\Validator\Queries; use Appwrite\Utopia\Database\Validator\Queries\Collections; use Appwrite\Utopia\Database\Validator\Queries\Databases; -//use Appwrite\Utopia\Database\Validator\Queries\Document as DocumentValidator; -//use Appwrite\Utopia\Database\Validator\Queries\Documents; -use Utopia\Database\Validator\Documents; -use Utopia\Database\Validator\DocumentValidator; +use Utopia\Database\Validator\Queries\Documents as DocumentsValidator; +use Utopia\Database\Validator\Queries\Document as DocumentValidator; use Utopia\Config\Config; use MaxMind\Db\Reader; use Utopia\Validator\Nullable; @@ -2875,7 +2873,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') } // Validate queries - $queriesValidator = new Documents($collection->getAttribute('attributes'), $collection->getAttribute('indexes')); + $queriesValidator = new DocumentsValidator($collection->getAttribute('attributes'), $collection->getAttribute('indexes')); $validQueries = $queriesValidator->isValid($queries); if (!$validQueries) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $queriesValidator->getDescription()); diff --git a/composer.lock b/composer.lock index eabb545ebc..d795f012dd 100644 --- a/composer.lock +++ b/composer.lock @@ -2113,12 +2113,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "94bca644f3ff418e6742e89fcf571c2c342adcd6" + "reference": "e56f580f304c70a55f3d75c6d3ab554c7e687789" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/94bca644f3ff418e6742e89fcf571c2c342adcd6", - "reference": "94bca644f3ff418e6742e89fcf571c2c342adcd6", + "url": "https://api.github.com/repos/utopia-php/database/zipball/e56f580f304c70a55f3d75c6d3ab554c7e687789", + "reference": "e56f580f304c70a55f3d75c6d3ab554c7e687789", "shasum": "" }, "require": { @@ -2163,7 +2163,7 @@ "issues": "https://github.com/utopia-php/database/issues", "source": "https://github.com/utopia-php/database/tree/appwrite-validators" }, - "time": "2023-04-27T06:57:58+00:00" + "time": "2023-04-27T08:18:20+00:00" }, { "name": "utopia-php/domains", diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index 9a6eb123c5..9d2705baa7 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -254,14 +254,14 @@ class Mapper case 'Appwrite\Utopia\Database\Validator\Queries\Collections': case 'Appwrite\Utopia\Database\Validator\Queries\Databases': case 'Appwrite\Utopia\Database\Validator\Queries\Deployments': - case 'Appwrite\Utopia\Database\Validator\Queries\Documents': + case 'Utopia\Database\Validator\Queries\Documents': case 'Appwrite\Utopia\Database\Validator\Queries\Executions': case 'Appwrite\Utopia\Database\Validator\Queries\Files': case 'Appwrite\Utopia\Database\Validator\Queries\Functions': case 'Appwrite\Utopia\Database\Validator\Queries\Memberships': case 'Utopia\Database\Validator\Permissions': case 'Appwrite\Utopia\Database\Validator\Queries\Projects': - case 'Appwrite\Utopia\Database\Validator\Queries': + case 'Utopia\Database\Validator\Queries': case 'Utopia\Database\Validator\Roles': case 'Appwrite\Utopia\Database\Validator\Queries\Teams': case 'Appwrite\Utopia\Database\Validator\Queries\Users': diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index 46db262d3b..bf0293d5af 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -345,7 +345,7 @@ class OpenAPI3 extends Format case 'Appwrite\Utopia\Database\Validator\Queries\Collections': case 'Appwrite\Utopia\Database\Validator\Queries\Databases': case 'Appwrite\Utopia\Database\Validator\Queries\Deployments': - case 'Appwrite\Utopia\Database\Validator\Queries\Documents': + case 'Utopia\Database\Validator\Queries\Documents': case 'Appwrite\Utopia\Database\Validator\Queries\Executions': case 'Appwrite\Utopia\Database\Validator\Queries\Files': case 'Appwrite\Utopia\Database\Validator\Queries\Functions': @@ -354,7 +354,7 @@ class OpenAPI3 extends Format case 'Appwrite\Utopia\Database\Validator\Queries\Teams': case 'Appwrite\Utopia\Database\Validator\Queries\Users': case 'Appwrite\Utopia\Database\Validator\Queries\Variables': - case 'Appwrite\Utopia\Database\Validator\Queries': + case 'Utopia\Database\Validator\Queries': $node['schema']['type'] = 'array'; $node['schema']['items'] = [ 'type' => 'string', diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 422f164fa6..60974bef85 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -344,7 +344,7 @@ class Swagger2 extends Format case 'Appwrite\Utopia\Database\Validator\Queries\Collections': case 'Appwrite\Utopia\Database\Validator\Queries\Databases': case 'Appwrite\Utopia\Database\Validator\Queries\Deployments': - case 'Appwrite\Utopia\Database\Validator\Queries\Documents': + case 'Utopia\Database\Validator\Queries\Documents': case 'Appwrite\Utopia\Database\Validator\Queries\Executions': case 'Appwrite\Utopia\Database\Validator\Queries\Files': case 'Appwrite\Utopia\Database\Validator\Queries\Functions': @@ -353,7 +353,7 @@ class Swagger2 extends Format case 'Appwrite\Utopia\Database\Validator\Queries\Teams': case 'Appwrite\Utopia\Database\Validator\Queries\Users': case 'Appwrite\Utopia\Database\Validator\Queries\Variables': - case 'Appwrite\Utopia\Database\Validator\Queries': + case 'Utopia\Database\Validator\Queries': $node['type'] = 'array'; $node['collectionFormat'] = 'multi'; $node['items'] = [ diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Document.php b/src/Appwrite/Utopia/Database/Validator/Queries/Document.php deleted file mode 100644 index f8e0e2f065..0000000000 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Document.php +++ /dev/null @@ -1,41 +0,0 @@ - '$id', - 'type' => Database::VAR_STRING, - 'array' => false, - ]); - $attributes[] = new \Utopia\Database\Document([ - 'key' => '$createdAt', - 'type' => Database::VAR_DATETIME, - 'array' => false, - ]); - $attributes[] = new \Utopia\Database\Document([ - 'key' => '$updatedAt', - 'type' => Database::VAR_DATETIME, - 'array' => false, - ]); - - $validators = [ - new Select($attributes), - ]; - - parent::__construct(...$validators); - } -} diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Documents.php b/src/Appwrite/Utopia/Database/Validator/Queries/Documents.php deleted file mode 100644 index d7caf7cdea..0000000000 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Documents.php +++ /dev/null @@ -1,52 +0,0 @@ - '$id', - 'type' => Database::VAR_STRING, - 'array' => false, - ]); - $attributes[] = new Document([ - 'key' => '$createdAt', - 'type' => Database::VAR_DATETIME, - 'array' => false, - ]); - $attributes[] = new Document([ - 'key' => '$updatedAt', - 'type' => Database::VAR_DATETIME, - 'array' => false, - ]); - - $validators = [ - new Limit(), - new Offset(), - new Cursor(), - new Filter($attributes), - new Order($attributes), - new Select($attributes), - ]; - - parent::__construct($attributes, $indexes, ...$validators); - } -}