diff --git a/app/config/collections.php b/app/config/collections.php index a61a6b4425..38568a01c3 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2518,7 +2518,6 @@ $collections = [ '$collection' => Database::METADATA, '$id' => 'buckets', 'name' => 'Buckets', - 'documentSecurity' => true, 'attributes' => [ [ '$id' => 'enabled', @@ -2540,6 +2539,16 @@ $collections = [ 'required' => true, 'array' => false, ], + [ + '$id' => 'fileSecurity', + 'type' => Database::VAR_BOOLEAN, + 'signed' => true, + 'size' => 1, + 'format' => '', + 'filters' => [], + 'required' => false, + 'array' => false, + ], [ '$id' => 'maximumFileSize', 'type' => Database::VAR_INTEGER, diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 84f70cd777..32b1db1b75 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -520,7 +520,6 @@ App::post('/v1/databases/:databaseId/collections') 'databaseInternalId' => $database->getInternalId(), 'databaseId' => $databaseId, '$permissions' => $permissions ?? [], - 'documentSecurity' => $documentSecurity, 'enabled' => true, 'name' => $name, 'search' => implode(' ', [$collectionId, $name]), @@ -770,8 +769,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId') throw new Exception('Collection not found', 404, Exception::COLLECTION_NOT_FOUND); } - $read ??= $collection->getRead() ?? []; // By default inherit read permissions - $write ??= $collection->getWrite() ?? []; // By default inherit write permissions + $permissions ??= $collection->getPermissions() ?? []; $enabled ??= $collection->getAttribute('enabled', true); try { diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 205815ae45..dcad8cc2a5 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -107,7 +107,6 @@ App::post('/v1/storage/buckets') '$id' => $bucketId, '$collection' => 'buckets', 'name' => $name, - 'documentSecurity' => $fileSecurity, 'maximumFileSize' => $maximumFileSize, 'allowedFileExtensions' => $allowedFileExtensions, 'enabled' => (bool) filter_var($enabled, FILTER_VALIDATE_BOOLEAN), @@ -254,7 +253,6 @@ App::put('/v1/storage/buckets/:bucketId') ->setAttribute('allowedFileExtensions', $allowedFileExtensions) ->setAttribute('enabled', (bool) filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) ->setAttribute('encryption', (bool) filter_var($encryption, FILTER_VALIDATE_BOOLEAN)) - ->setAttribute('documentSecurity', $fileSecurity) ->setAttribute('antivirus', (bool) filter_var($antivirus, FILTER_VALIDATE_BOOLEAN))); $audits diff --git a/app/http.php b/app/http.php index f7dfbc5cff..68bf3959d8 100644 --- a/app/http.php +++ b/app/http.php @@ -129,8 +129,6 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { $attributes = []; $indexes = []; - $permissions = $collection['$permissions'] ?? ['read(any)', 'write(any)']; - $documentSecurity = $collection['documentSecurity'] ?? false; foreach ($collection['attributes'] as $attribute) { $attributes[] = new Document([ @@ -156,7 +154,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) { ]); } - $dbForConsole->createCollection($key, $attributes, $indexes, $permissions, $documentSecurity); + $dbForConsole->createCollection($key, $attributes, $indexes); } if ($dbForConsole->getDocument('buckets', 'default')->isEmpty()) { diff --git a/composer.json b/composer.json index a04d46e4e8..3eeed0609e 100644 --- a/composer.json +++ b/composer.json @@ -76,7 +76,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "0.19.5", + "appwrite/sdk-generator": "dev-feat-nested-array-types as 0.19.5", "phpunit/phpunit": "9.5.20", "squizlabs/php_codesniffer": "^3.6", "swoole/ide-helper": "4.8.9", diff --git a/composer.lock b/composer.lock index 2b6c6e6e60..6f2899f72d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "677b1b47c8567f0b7b05645e2bbc7bc7", + "content-hash": "20238d621c3fb8e86859c07a47ea22ad", "packages": [ { "name": "adhocore/jwt", @@ -2051,16 +2051,16 @@ }, { "name": "utopia-php/database", - "version": "0.18.9", + "version": "dev-refactor-permissions", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "227b3ca919149b7b0d6556c8effe9ee46ed081e6" + "reference": "ea890cc8bf53bd379f74f6f9a444a18d817ec67d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/227b3ca919149b7b0d6556c8effe9ee46ed081e6", - "reference": "227b3ca919149b7b0d6556c8effe9ee46ed081e6", + "url": "https://api.github.com/repos/utopia-php/database/zipball/ea890cc8bf53bd379f74f6f9a444a18d817ec67d", + "reference": "ea890cc8bf53bd379f74f6f9a444a18d817ec67d", "shasum": "" }, "require": { @@ -2109,9 +2109,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.18.9" + "source": "https://github.com/utopia-php/database/tree/refactor-permissions" }, - "time": "2022-07-19T09:42:53+00:00" + "time": "2022-08-02T06:51:50+00:00" }, { "name": "utopia-php/domains", @@ -2828,29 +2828,29 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.19.5", + "version": "dev-feat-nested-array-types", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "04de540cf683e2b08b3192c137dde7f2c37003d9" + "reference": "60f742e50d92cc89b5cf529edee98d8b5b4896b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/04de540cf683e2b08b3192c137dde7f2c37003d9", - "reference": "04de540cf683e2b08b3192c137dde7f2c37003d9", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/60f742e50d92cc89b5cf529edee98d8b5b4896b3", + "reference": "60f742e50d92cc89b5cf529edee98d8b5b4896b3", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "matthiasmullie/minify": "^1.3", + "matthiasmullie/minify": "^1.3.68", "php": ">=7.0.0", - "twig/twig": "^3.3" + "twig/twig": "^3.4.1" }, "require-dev": { "brianium/paratest": "^6.4", - "phpunit/phpunit": "^9.5.13" + "phpunit/phpunit": "^9.5.21" }, "type": "library", "autoload": { @@ -2872,9 +2872,9 @@ "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/0.19.5" + "source": "https://github.com/appwrite/sdk-generator/tree/feat-nested-array-types" }, - "time": "2022-07-06T11:05:57+00:00" + "time": "2022-08-03T03:46:31+00:00" }, { "name": "doctrine/instantiator", @@ -5346,9 +5346,25 @@ "time": "2022-05-17T05:48:52+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "appwrite/sdk-generator", + "version": "dev-feat-nested-array-types", + "alias": "0.19.5", + "alias_normalized": "0.19.5.0" + }, + { + "package": "utopia-php/database", + "version": "dev-refactor-permissions", + "alias": "0.18.9", + "alias_normalized": "0.18.9.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20, + "appwrite/sdk-generator": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 444611e07a..2b47bbfb26 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -47,8 +47,8 @@ class FunctionsCustomServerTest extends Scope $this->assertNotEmpty($response1['body']['$id']); $this->assertEquals('Test', $response1['body']['name']); $this->assertEquals('php-8.0', $response1['body']['runtime']); - $this->assertIsInt($response1['body']['$createdAt']); - $this->assertIsInt($response1['body']['$updatedAt']); + $this->assertIsString($response1['body']['$createdAt']); + $this->assertIsString($response1['body']['$updatedAt']); $this->assertEquals('', $response1['body']['deployment']); $this->assertEquals([ 'funcKey1' => 'funcValue1', @@ -248,8 +248,8 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $response1['headers']['status-code']); $this->assertNotEmpty($response1['body']['$id']); $this->assertEquals('Test1', $response1['body']['name']); - $this->assertIsInt($response1['body']['$createdAt']); - $this->assertIsInt($response1['body']['$updatedAt']); + $this->assertIsString($response1['body']['$createdAt']); + $this->assertIsString($response1['body']['$updatedAt']); $this->assertEquals('', $response1['body']['deployment']); $this->assertEquals([ 'key4' => 'value4', @@ -365,8 +365,8 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertIsInt($response['body']['$createdAt']); - $this->assertIsInt($response['body']['$updatedAt']); + $this->assertIsString($response['body']['$createdAt']); + $this->assertIsString($response['body']['$updatedAt']); $this->assertEquals($data['deploymentId'], $response['body']['deployment']); /** diff --git a/tests/e2e/Services/Teams/TeamsBase.php b/tests/e2e/Services/Teams/TeamsBase.php index e626124058..70fc41dee4 100644 --- a/tests/e2e/Services/Teams/TeamsBase.php +++ b/tests/e2e/Services/Teams/TeamsBase.php @@ -25,7 +25,7 @@ trait TeamsBase $this->assertEquals('Arsenal', $response1['body']['name']); $this->assertGreaterThan(-1, $response1['body']['total']); $this->assertIsInt($response1['body']['total']); - $this->assertIsInt($response1['body']['$createdAt']); + $this->assertIsString($response1['body']['$createdAt']); $teamUid = $response1['body']['$id']; $teamName = $response1['body']['name'];