diff --git a/composer.lock b/composer.lock index b9176fe53e..f31e5efe52 100644 --- a/composer.lock +++ b/composer.lock @@ -2874,7 +2874,7 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/master" + "source": "https://github.com/appwrite/sdk-generator/tree/feat-change-default-functionID" }, "time": "2022-08-19T10:03:22+00:00" }, diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Collection.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php similarity index 95% rename from src/Appwrite/Utopia/Database/Validator/Queries/Collection.php rename to src/Appwrite/Utopia/Database/Validator/Queries/Base.php index 0c29ecd2ff..42c60dbec4 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Collection.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -12,7 +12,7 @@ use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -class Collection extends IndexedQueries +class Base extends IndexedQueries { /** * Expression constructor @@ -49,12 +49,12 @@ class Collection extends IndexedQueries 'array' => false, ]); $attributes[] = new Document([ - '$id' => '$createdAt', + 'key' => '$createdAt', 'type' => Database::VAR_DATETIME, 'array' => false, ]); $attributes[] = new Document([ - '$id' => '$updatedAt', + 'key' => '$updatedAt', 'type' => Database::VAR_DATETIME, 'array' => false, ]); diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Buckets.php b/src/Appwrite/Utopia/Database/Validator/Queries/Buckets.php index af7f7d4380..b52c0456a4 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Buckets.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Buckets.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Buckets extends Collection +class Buckets extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'enabled', 'name', 'fileSecurity', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Collections.php b/src/Appwrite/Utopia/Database/Validator/Queries/Collections.php index ea1a4ef548..579e80ceab 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Collections.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Collections.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Collections extends Collection +class Collections extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name', 'enabled', 'documentSecurity' diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Databases.php b/src/Appwrite/Utopia/Database/Validator/Queries/Databases.php index aa6af85c1a..3278b140bf 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Databases.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Databases.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Databases extends Collection +class Databases extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name' ]; diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php index dec54311c3..b33a6ac5a4 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Deployments extends Collection +class Deployments extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'entrypoint', 'size', 'buildId', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php b/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php index 2da974942f..ae26b26337 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Executions extends Collection +class Executions extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'trigger', 'status', 'statusCode', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Files.php b/src/Appwrite/Utopia/Database/Validator/Queries/Files.php index d66ec04a33..8c2cf653b8 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Files.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Files.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Files extends Collection +class Files extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name', 'signature', 'mimeType', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php b/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php index ae3e4086c9..6ecf76d7ab 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Functions extends Collection +class Functions extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name', 'status', 'runtime', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php b/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php index 08acba40e8..eff5016e6c 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/TeamMemberships.php @@ -2,21 +2,13 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class TeamMemberships extends Collection +class TeamMemberships extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'userId', - 'userName', - 'userName', - 'userEmail', 'teamId', - 'teamName', 'invited', 'joined', 'confirm' diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Teams.php b/src/Appwrite/Utopia/Database/Validator/Queries/Teams.php index 7924d2784c..e51c565190 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Teams.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Teams.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Teams extends Collection +class Teams extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name', 'total' ]; diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Users.php b/src/Appwrite/Utopia/Database/Validator/Queries/Users.php index e8f2507cda..a19cbfc415 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Users.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Users.php @@ -2,15 +2,11 @@ namespace Appwrite\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; -class Users extends Collection +class Users extends Base { public const ALLOWED_ATTRIBUTES = [ - '$id', - '$createdAt', - '$updatedAt', - 'name', 'email', 'phone', diff --git a/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php b/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php index 198fc2895d..a32acc4a95 100644 --- a/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php +++ b/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php @@ -2,7 +2,7 @@ namespace Tests\Unit\Utopia\Database\Validator\Queries; -use Appwrite\Utopia\Database\Validator\Queries\Collection; +use Appwrite\Utopia\Database\Validator\Queries\Base; use PHPUnit\Framework\TestCase; class CollectionTest extends TestCase @@ -17,14 +17,14 @@ class CollectionTest extends TestCase public function testEmptyQueries(): void { - $validator = new Collection('users', []); + $validator = new Base('users', []); $this->assertEquals($validator->isValid([]), true); } public function testValid(): void { - $validator = new Collection('users', ['name', 'search']); + $validator = new Base('users', ['name', 'search']); $this->assertEquals(true, $validator->isValid(['cursorAfter("asdf")']), $validator->getDescription()); $this->assertEquals(true, $validator->isValid(['equal("name", "value")']), $validator->getDescription()); $this->assertEquals(true, $validator->isValid(['limit(10)']), $validator->getDescription()); @@ -35,7 +35,7 @@ class CollectionTest extends TestCase public function testMissingIndex(): void { - $validator = new Collection('users', ['name']); + $validator = new Base('users', ['name']); $this->assertEquals(false, $validator->isValid(['equal("dne", "value")']), $validator->getDescription()); $this->assertEquals(false, $validator->isValid(['orderAsc("dne")']), $validator->getDescription()); $this->assertEquals(false, $validator->isValid(['search("search", "value")']), $validator->getDescription());