diff --git a/.env b/.env index 30bacb2a8..581af6d97 100644 --- a/.env +++ b/.env @@ -16,7 +16,7 @@ _APP_DB_PORT=3306 _APP_DB_SCHEMA=appwrite _APP_DB_USER=user _APP_DB_PASS=password -_APP_STORAGE_ANTIVIRUS=disabled +_APP_STORAGE_ANTIVIRUS=enabled _APP_STORAGE_ANTIVIRUS_HOST=clamav _APP_STORAGE_ANTIVIRUS_PORT=3310 _APP_INFLUXDB_HOST=influxdb diff --git a/CHANGES.md b/CHANGES.md index cc086bb10..99e480f78 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,9 +2,25 @@ - Anonymous login +# Version 0.7.2 (Not Released Yet) + +## Features + +- When creating new resources from the client API, the current user gets both read & write permissions by default. (#1007) +- Added timestamp to errors logs on the HTTP API container (#1002) +- Added verbose tests output on the terminal and CI (#1006) + ## Upgrades -- Upgraded ClamAV to version 1.3.0 +- Upgraded utopia-php/abuse to version 0.4.0 +- Upgraded utopia-php/analytics to version 0.2.0 + +## Bugs + +- Fixed certificates worker error on successful operations (#1010) +- Fixed head requests not responding (#998) +- Fixed bug when using auth credential for the Redis container (#993) +- Fixed server warning logs on 3** redirect endpoints (#1013) # Version 0.7.1 diff --git a/README.md b/README.md index 9c2efcda8..84d47883f 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.7.2 ``` ### Windows @@ -65,7 +65,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.7.2 ``` #### PowerShell @@ -75,7 +75,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.7.1 + appwrite/appwrite:0.7.2 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. diff --git a/app/config/variables.php b/app/config/variables.php index 369a860fe..cd7db9ba6 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -143,7 +143,7 @@ return [ ], [ 'name' => '_APP_REDIS_USER', - 'description' => 'Redis server user.', + 'description' => 'Redis server user. This is an optional variable. Default value is an empty string.', 'introduction' => '0.7', 'default' => '', 'required' => false, @@ -151,7 +151,7 @@ return [ ], [ 'name' => '_APP_REDIS_PASS', - 'description' => 'Redis server password.', + 'description' => 'Redis server password. This is an optional variable. Default value is an empty string.', 'introduction' => '0.7', 'default' => '', 'required' => false, diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index c386749ca..2c32ae981 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -169,8 +169,8 @@ App::put('/v1/database/collections/:collectionId') ->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', [], new ArrayList(new Text(64)), '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', [], new ArrayList(new Text(64)), '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.') + ->param('read', null, new ArrayList(new Text(64)), '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 ArrayList(new Text(64)), '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) ->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true, ['projectDB']) ->inject('response') ->inject('projectDB') @@ -187,6 +187,8 @@ App::put('/v1/database/collections/:collectionId') } $parsedRules = []; + $read = (is_null($read)) ? ($collection->getPermissions()['read'] ?? []) : $read; // By default inherit read permissions + $write = (is_null($write)) ? ($collection->getPermissions()['write'] ?? []) : $write; // By default inherit write permissions foreach ($rules as &$rule) { $parsedRules[] = \array_merge([ @@ -295,17 +297,19 @@ App::post('/v1/database/collections/:collectionId/documents') ->label('sdk.response.model', Response::MODEL_ANY) ->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') ->param('data', [], new JSON(), 'Document data as JSON object.') - ->param('read', [], new ArrayList(new Text(64)), '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', [], new ArrayList(new Text(64)), '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.') + ->param('read', null, new ArrayList(new Text(64)), 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) + ->param('write', null, new ArrayList(new Text(64)), 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) ->param('parentDocument', '', new UID(), 'Parent document unique ID. Use when you want your new document to be a child of a parent document.', true) ->param('parentProperty', '', new Key(), 'Parent document property name. Use when you want your new document to be a child of a parent document.', true) ->param('parentPropertyType', Document::SET_TYPE_ASSIGN, new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND], true), 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true) ->inject('response') ->inject('projectDB') + ->inject('user') ->inject('audits') - ->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $audits) { + ->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $user, $audits) { /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Event\Event $audits */ $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array @@ -326,8 +330,8 @@ App::post('/v1/database/collections/:collectionId/documents') $data['$collection'] = $collectionId; // Adding this param to make API easier for developers $data['$permissions'] = [ - 'read' => $read, - 'write' => $write, + 'read' => (is_null($read) && !$user->isEmpty()) ? ['user:'.$user->getId()] : $read ?? [], // By default set read permissions for user + 'write' => (is_null($write) && !$user->isEmpty()) ? ['user:'.$user->getId()] : $write ?? [], // By default set write permissions for user ]; // Read parent document + validate not 404 + validate read / write permission like patch method @@ -508,8 +512,8 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') ->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') ->param('documentId', null, new UID(), 'Document unique ID.') ->param('data', [], new JSON(), 'Document data as JSON object.') - ->param('read', [], new ArrayList(new Text(64)), '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', [], new ArrayList(new Text(64)), '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.') + ->param('read', null, new ArrayList(new Text(64)), '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 ArrayList(new Text(64)), '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('projectDB') ->inject('audits') @@ -522,7 +526,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') $document = $projectDB->getDocument($documentId, false); $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array - + if (!\is_array($data)) { throw new Exception('Data param should be a valid JSON object', 400); } @@ -539,8 +543,8 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') $data['$collection'] = $collection->getId(); // Make sure user don't switch collectionID $data['$id'] = $document->getId(); // Make sure user don't switch document unique ID - $data['$permissions']['read'] = $read; - $data['$permissions']['write'] = $write; + $data['$permissions']['read'] = (is_null($read)) ? ($document->getPermissions()['read'] ?? []) : $read; // By default inherit read permissions + $data['$permissions']['write'] = (is_null($write)) ? ($document->getPermissions()['write'] ?? []) : $write; // By default inherit write permissions if (empty($data)) { throw new Exception('Missing payload', 400); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7a6b11bcd..92708527a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -435,7 +435,7 @@ App::post('/v1/functions/:functionId/tags') ->label('sdk.response.model', Response::MODEL_TAG) ->param('functionId', '', new UID(), 'Function unique ID.') ->param('command', '', new Text('1028'), 'Code execution command.') - ->param('code', null, new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', false) + ->param('code', [], new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', false) ->inject('request') ->inject('response') ->inject('projectDB') diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index d4500e95a..f0ce2e405 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -38,17 +38,19 @@ App::post('/v1/storage/files') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_FILE) ->param('file', [], new File(), 'Binary file.', false) - ->param('read', [], new ArrayList(new Text(64)), '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', [], new ArrayList(new Text(64)), '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.') + ->param('read', null, new ArrayList(new Text(64)), 'An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) + ->param('write', null, new ArrayList(new Text(64)), 'An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.', true) ->inject('request') ->inject('response') ->inject('projectDB') + ->inject('user') ->inject('audits') ->inject('usage') - ->action(function ($file, $read, $write, $request, $response, $projectDB, $audits, $usage) { + ->action(function ($file, $read, $write, $request, $response, $projectDB, $user, $audits, $usage) { /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ + /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Event\Event $audits */ /** @var Appwrite\Event\Event $usage */ @@ -122,8 +124,8 @@ App::post('/v1/storage/files') $file = $projectDB->createDocument([ '$collection' => Database::SYSTEM_COLLECTION_FILES, '$permissions' => [ - 'read' => $read, - 'write' => $write, + 'read' => (is_null($read) && !$user->isEmpty()) ? ['user:'.$user->getId()] : $read ?? [], // By default set read permissions for user + 'write' => (is_null($write) && !$user->isEmpty()) ? ['user:'.$user->getId()] : $write ?? [], // By default set write permissions for user ], 'dateCreated' => \time(), 'folderId' => '', diff --git a/app/controllers/general.php b/app/controllers/general.php index fe0016038..18e1ab1bb 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -256,6 +256,8 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) { $template = ($route) ? $route->getLabel('error', null) : null; if (php_sapi_name() === 'cli') { + Console::error('[Error] Timestamp: '.date('c', time())); + if($route) { Console::error('[Error] Method: '.$route->getMethod()); Console::error('[Error] URL: '.$route->getURL()); diff --git a/app/init.php b/app/init.php index 86f172ed4..2aa5fb020 100644 --- a/app/init.php +++ b/app/init.php @@ -40,7 +40,7 @@ const APP_MODE_DEFAULT = 'default'; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 12; const APP_CACHE_BUSTER = 145; -const APP_VERSION_STABLE = '0.7.1'; +const APP_VERSION_STABLE = '0.7.2'; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_CACHE = '/storage/cache'; diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 2c555d894..da9d2ae74 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -67,6 +67,8 @@ $cli $target = \realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/'; $readme = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/README.md'); $readme = ($readme) ? \file_get_contents($readme) : ''; + $gettingStarted = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/GETTING_STARTED.md'); + $gettingStarted = ($gettingStarted) ? \file_get_contents($gettingStarted) : ''; $examples = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/EXAMPLES.md'); $examples = ($examples) ? \file_get_contents($examples) : ''; $changelog = \realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/CHANGELOG.md'); @@ -187,6 +189,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setShareVia('appwrite_io') ->setWarning($warning) ->setReadme($readme) + ->setGettingStarted($gettingStarted) ->setChangelog($changelog) ->setExamples($examples) ; diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index fdbfff2c5..1c0c98108 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -352,7 +352,7 @@ services: - appwrite-redis:/data:rw clamav: - image: appwrite/clamav:1.3.0 + image: appwrite/clamav:1.2.0 container_name: appwrite-clamav restart: unless-stopped networks: diff --git a/app/workers/certificates.php b/app/workers/certificates.php index e8693e356..90907204a 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -124,7 +124,7 @@ class CertificatesV1 ." -w ".APP_STORAGE_CERTIFICATES ." -d {$domain->get()}", '', $stdout, $stderr); - if($stderr || $exit !== 0) { + if($exit !== 0) { throw new Exception('Failed to issue a certificate with message: '.$stderr); } diff --git a/bin/schedule b/bin/schedule index 857ec9f6f..6300d97ed 100644 --- a/bin/schedule +++ b/bin/schedule @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-audits b/bin/worker-audits index e411aa386..8e99481d2 100644 --- a/bin/worker-audits +++ b/bin/worker-audits @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-certificates b/bin/worker-certificates index 7d474e1ea..9214af513 100755 --- a/bin/worker-certificates +++ b/bin/worker-certificates @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-deletes b/bin/worker-deletes index 9c2fb3118..517f75530 100644 --- a/bin/worker-deletes +++ b/bin/worker-deletes @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-functions b/bin/worker-functions index b41c01994..29cd4b85c 100644 --- a/bin/worker-functions +++ b/bin/worker-functions @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-mails b/bin/worker-mails index 64d10f609..a66394262 100644 --- a/bin/worker-mails +++ b/bin/worker-mails @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-tasks b/bin/worker-tasks index fc395b34a..bac1f54a8 100644 --- a/bin/worker-tasks +++ b/bin/worker-tasks @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-usage b/bin/worker-usage index 4176f54b8..9cb9b5ed8 100644 --- a/bin/worker-usage +++ b/bin/worker-usage @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/bin/worker-webhooks b/bin/worker-webhooks index 13029ecbd..4ae2fadaa 100644 --- a/bin/worker-webhooks +++ b/bin/worker-webhooks @@ -1,6 +1,6 @@ #!/bin/sh -if [ -z "$_APP_REDIS_USER" ] || [ -z "$_APP_REDIS_PASS" ] +if [ -z "$_APP_REDIS_USER" ] && [ -z "$_APP_REDIS_PASS" ] then REDIS_BACKEND="${_APP_REDIS_HOST}:${_APP_REDIS_PORT}" else diff --git a/composer.json b/composer.json index 66bb66f51..f7e589480 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,10 @@ } }, "autoload-dev": { - "psr-4": {"Tests\\E2E\\": "tests/e2e"} + "psr-4": { + "Tests\\E2E\\": "tests/e2e", + "Appwrite\\Tests\\": "tests/extensions" + } }, "require": { "php": ">=7.4.0", @@ -35,8 +38,8 @@ "appwrite/php-clamav": "1.0.*", "utopia-php/framework": "0.12.*", - "utopia-php/abuse": "0.3.*", - "utopia-php/analytics": "0.1.*", + "utopia-php/abuse": "0.4.*", + "utopia-php/analytics": "0.2.*", "utopia-php/audit": "0.5.*", "utopia-php/cache": "0.2.*", "utopia-php/cli": "0.10.0", diff --git a/composer.lock b/composer.lock index 5a90ba3b6..2d4e127a0 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": "00a80774fb5a4984181b29f2f037a0e5", + "content-hash": "69222438c59581b58de7052befa6ac00", "packages": [ { "name": "adhocore/jwt", @@ -364,18 +364,18 @@ "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "01129f635f45659fd4764a533777d069a978bc9d" + "reference": "de6f1e58e735754b888649495ed4cb9ae3b19589" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/01129f635f45659fd4764a533777d069a978bc9d", - "reference": "01129f635f45659fd4764a533777d069a978bc9d", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/de6f1e58e735754b888649495ed4cb9ae3b19589", + "reference": "de6f1e58e735754b888649495ed4cb9ae3b19589", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/promises": "^1.4", - "guzzlehttp/psr7": "^1.7", + "guzzlehttp/psr7": "^1.7 || ^2.0", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0" }, @@ -383,6 +383,7 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", "ext-curl": "*", "php-http/client-integration-tests": "^3.0", "phpunit/phpunit": "^8.5.5 || ^9.3.5", @@ -397,7 +398,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.3-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -459,7 +460,7 @@ "type": "github" } ], - "time": "2021-03-15T07:56:29+00:00" + "time": "2021-03-23T14:07:59+00:00" }, { "name": "guzzlehttp/promises", @@ -519,46 +520,47 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "a67cdbf85690e54a7b92fe91c297b20d2607c0b2" + "reference": "c0dcda9f54d145bd4d062a6d15f54931a67732f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/a67cdbf85690e54a7b92fe91c297b20d2607c0b2", - "reference": "a67cdbf85690e54a7b92fe91c297b20d2607c0b2", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c0dcda9f54d145bd4d062a6d15f54931a67732f9", + "reference": "c0dcda9f54d145bd4d062a6d15f54931a67732f9", "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7-dev" + "dev-master": "2.0-dev" } }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -573,6 +575,11 @@ { "name": "Tobias Schultze", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "PSR-7 message implementation that also provides common utility methods", @@ -588,9 +595,9 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.x" + "source": "https://github.com/guzzle/psr7/tree/2.0.0-beta1" }, - "time": "2021-03-15T11:15:53+00:00" + "time": "2021-03-21T17:21:36+00:00" }, { "name": "influxdb/influxdb-php", @@ -906,6 +913,62 @@ }, "time": "2020-09-19T09:12:31+00:00" }, + { + "name": "psr/http-factory", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "36fa03d50ff82abcae81860bdaf4ed9a1510c7cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/36fa03d50ff82abcae81860bdaf4ed9a1510c7cd", + "reference": "36fa03d50ff82abcae81860bdaf4ed9a1510c7cd", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2020-09-17T16:52:55+00:00" + }, { "name": "psr/http-message", "version": "dev-master", @@ -1273,21 +1336,21 @@ }, { "name": "utopia-php/abuse", - "version": "0.3.1", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "23c2eb533bca8f3ef5548ae265398fa7d4d39a1c" + "reference": "2b8cc40a67c045c137b44d1a11326f494acf50a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/23c2eb533bca8f3ef5548ae265398fa7d4d39a1c", - "reference": "23c2eb533bca8f3ef5548ae265398fa7d4d39a1c", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/2b8cc40a67c045c137b44d1a11326f494acf50a4", + "reference": "2b8cc40a67c045c137b44d1a11326f494acf50a4", "shasum": "" }, "require": { "ext-pdo": "*", - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "^9.4", @@ -1319,22 +1382,22 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.3.1" + "source": "https://github.com/utopia-php/abuse/tree/0.4.0" }, - "time": "2020-12-21T17:28:03+00:00" + "time": "2021-03-17T20:21:24+00:00" }, { "name": "utopia-php/analytics", - "version": "0.1.0", + "version": "0.2.0", "source": { "type": "git", "url": "https://github.com/utopia-php/analytics.git", - "reference": "a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f" + "reference": "adfc2d057a7f6ab618a77c8a20ed3e35485ff416" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/analytics/zipball/a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f", - "reference": "a1f2a1672a927bef8cd4d9b47e5cfbc856a3c72f", + "url": "https://api.github.com/repos/utopia-php/analytics/zipball/adfc2d057a7f6ab618a77c8a20ed3e35485ff416", + "reference": "adfc2d057a7f6ab618a77c8a20ed3e35485ff416", "shasum": "" }, "require": { @@ -1374,9 +1437,9 @@ ], "support": { "issues": "https://github.com/utopia-php/analytics/issues", - "source": "https://github.com/utopia-php/analytics/tree/0.1.0" + "source": "https://github.com/utopia-php/analytics/tree/0.2.0" }, - "time": "2021-02-03T17:07:09+00:00" + "time": "2021-03-23T21:33:07+00:00" }, { "name": "utopia-php/audit", @@ -1643,16 +1706,16 @@ }, { "name": "utopia-php/framework", - "version": "0.12.1", + "version": "0.12.3", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "ba17789a16527d24b4fb11ddc359901a295fbf2f" + "reference": "78be43a0eb711f3677769dfb445e5111bfafaa88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/ba17789a16527d24b4fb11ddc359901a295fbf2f", - "reference": "ba17789a16527d24b4fb11ddc359901a295fbf2f", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/78be43a0eb711f3677769dfb445e5111bfafaa88", + "reference": "78be43a0eb711f3677769dfb445e5111bfafaa88", "shasum": "" }, "require": { @@ -1686,9 +1749,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.12.1" + "source": "https://github.com/utopia-php/framework/tree/0.12.3" }, - "time": "2021-03-17T22:14:05+00:00" + "time": "2021-03-22T22:02:23+00:00" }, { "name": "utopia-php/image", @@ -1953,16 +2016,16 @@ }, { "name": "utopia-php/swoole", - "version": "0.2.2", + "version": "0.2.3", "source": { "type": "git", "url": "https://github.com/utopia-php/swoole.git", - "reference": "17510e90499e73273245c534a05bca522d4ffb37" + "reference": "45c42aae7e7d3f9f82bf194c2cfa5499b674aefe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/swoole/zipball/17510e90499e73273245c534a05bca522d4ffb37", - "reference": "17510e90499e73273245c534a05bca522d4ffb37", + "url": "https://api.github.com/repos/utopia-php/swoole/zipball/45c42aae7e7d3f9f82bf194c2cfa5499b674aefe", + "reference": "45c42aae7e7d3f9f82bf194c2cfa5499b674aefe", "shasum": "" }, "require": { @@ -2003,9 +2066,9 @@ ], "support": { "issues": "https://github.com/utopia-php/swoole/issues", - "source": "https://github.com/utopia-php/swoole/tree/0.2.2" + "source": "https://github.com/utopia-php/swoole/tree/0.2.3" }, - "time": "2021-03-17T22:51:07+00:00" + "time": "2021-03-22T22:39:24+00:00" }, { "name": "utopia-php/system", @@ -4933,12 +4996,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "36e4ff2188cb5af6e6e94560b4aaa8042933aa58" + "reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/36e4ff2188cb5af6e6e94560b4aaa8042933aa58", - "reference": "36e4ff2188cb5af6e6e94560b4aaa8042933aa58", + "url": "https://api.github.com/repos/symfony/console/zipball/5da8b675121f9f4419b7052caa0cc6118a3ccd47", + "reference": "5da8b675121f9f4419b7052caa0cc6118a3ccd47", "shasum": "" }, "require": { @@ -5024,7 +5087,7 @@ "type": "tidelift" } ], - "time": "2021-03-17T16:56:09+00:00" + "time": "2021-03-23T14:20:07+00:00" }, { "name": "symfony/deprecation-contracts", @@ -5032,12 +5095,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "49dc45a74cbac5fffc6417372a9f5ae1682ca0b4" + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/49dc45a74cbac5fffc6417372a9f5ae1682ca0b4", - "reference": "49dc45a74cbac5fffc6417372a9f5ae1682ca0b4", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", "shasum": "" }, "require": { @@ -5092,7 +5155,7 @@ "type": "tidelift" } ], - "time": "2021-02-25T16:38:04+00:00" + "time": "2021-03-23T23:28:01+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -5512,12 +5575,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "3d72b4bfab3e991aa66906aa301aa479de4ca6ee" + "reference": "1309413986521646bb0ba91140afdc2a61ed8cfe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/3d72b4bfab3e991aa66906aa301aa479de4ca6ee", - "reference": "3d72b4bfab3e991aa66906aa301aa479de4ca6ee", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/1309413986521646bb0ba91140afdc2a61ed8cfe", + "reference": "1309413986521646bb0ba91140afdc2a61ed8cfe", "shasum": "" }, "require": { @@ -5584,7 +5647,7 @@ "type": "tidelift" } ], - "time": "2021-03-16T09:10:58+00:00" + "time": "2021-03-23T23:28:01+00:00" }, { "name": "symfony/string", @@ -5726,12 +5789,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a" + "reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", - "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/116bfb0bc9ec2a39db93431b7fe67144164d251e", + "reference": "116bfb0bc9ec2a39db93431b7fe67144164d251e", "shasum": "" }, "require": { @@ -5797,7 +5860,7 @@ "type": "tidelift" } ], - "time": "2021-03-10T10:07:14+00:00" + "time": "2021-03-22T08:23:49+00:00" }, { "name": "vimeo/psalm", diff --git a/docker-compose.yml b/docker-compose.yml index 217d67a70..c4ad29c64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -414,7 +414,7 @@ services: - appwrite-redis:/data:rw clamav: - image: appwrite/clamav:1.3.0 + image: appwrite/clamav:1.2.0 container_name: appwrite-clamav networks: - appwrite diff --git a/docs/sdks/dart/GETTING_STARTED.md b/docs/sdks/dart/GETTING_STARTED.md new file mode 100644 index 000000000..7a5e8340d --- /dev/null +++ b/docs/sdks/dart/GETTING_STARTED.md @@ -0,0 +1,31 @@ +## Getting Started + +### Initialize & Make API Request +Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: + +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +void main() async { + Client client = Client(); + .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible + .setProject('5ff3379a01d25') // Your project ID + .setKey('cd868c7af8bdc893b4...93b7535db89') + + Users users = Users(client); + + try { + final response = await users.create(email: ‘email@example.com’,password: ‘password’, name: ‘name’); + print(response.data); + } on AppwriteException catch(e) { + print(e.message); + } +} +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Dart Playground](https://github.com/appwrite/playground-for-dart) diff --git a/docs/sdks/deno/GETTING_STARTED.md b/docs/sdks/deno/GETTING_STARTED.md new file mode 100644 index 000000000..f0b10ed37 --- /dev/null +++ b/docs/sdks/deno/GETTING_STARTED.md @@ -0,0 +1,60 @@ +## Getting Started + +### Init your SDK +Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. + +```typescript +let client = new sdk.Client(); + +client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +``` + +### Make your first request + +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```typescript +let users = new sdk.Users(client); + +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); +``` + +### Full Example +```typescript +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +let client = new sdk.Client(); +let users = new sdk.Users(client); + +client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Deno Playground](https://github.com/appwrite/playground-for-deno) diff --git a/docs/sdks/dotnet/CHANGELOG.md b/docs/sdks/dotnet/CHANGELOG.md new file mode 100644 index 000000000..fa4d35e68 --- /dev/null +++ b/docs/sdks/dotnet/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/dotnet/GETTING_STARTED.md b/docs/sdks/dotnet/GETTING_STARTED.md new file mode 100644 index 000000000..584d571a1 --- /dev/null +++ b/docs/sdks/dotnet/GETTING_STARTED.md @@ -0,0 +1,36 @@ +## Getting Started + +### Initialize & Make API Request +Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example: + +```csharp +using Appwrite; + +static async Task Main(string[] args) +{ + var client = Client(); + + client + .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible + .setProject('5ff3379a01d25') // Your project ID + .setKey('cd868c7af8bdc893b4...93b7535db89') + ; + + var users = Users(client); + + try { + var request = await users.create('email@example.com', 'password', 'name'); + var response = await request.Content.ReadAsStringAsync(); + Console.WriteLine(response); + } catch (AppwriteException e) { + Console.WriteLine(e.Message); + } +} +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Dart Playground](https://github.com/appwrite/playground-for-dotnet) diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md new file mode 100644 index 000000000..9dae492f7 --- /dev/null +++ b/docs/sdks/flutter/GETTING_STARTED.md @@ -0,0 +1,114 @@ +## Getting Started + +### Add your Flutter Platform +To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. + +From the options, choose to add a new **Flutter** platform and add your app credentials. Appwrite Flutter SDK currently supports building apps for both iOS and Android. + +If you are building your Flutter application for multiple devices, you have to follow this process for each different device. + +#### iOS +For **iOS** add your app name and Bundle ID, You can find your Bundle Identifier in the General tab for your app's primary target in Xcode. + +#### Android +For **Android** add your app name and package name, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API. + +### iOS + +The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthenticationSession on iOS 11 to allow OAuth authentication. You have to change your iOS Deployment Target in Xcode to be iOS >= 11 to be able to build your app on an emulator or a real device. + +1. In Xcode, open Runner.xcworkspace in your app's ios folder. +2. To view your app's settings, select the Runner project in the Xcode project navigator. Then, in the main view sidebar, select the Runner target. +3. Select the General tab. +4. In Deployment Info, 'Target' select iOS 11.0 + +### Android +In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console. + +```xml + + + + + + + + + + + + +``` + +### Web +Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API. + +#### Flutter Web Cross-Domain Communication & Cookies +While running Flutter Web, make sure your Appwrite server and your Flutter client are using the same top-level domain and the same protocol (HTTP or HTTPS) to communicate. When trying to communicate between different domains or protocols, you may receive HTTP status error 401 because some modern browsers block cross-site or insecure cookies for enhanced privacy. In production, Appwrite allows you set multiple [custom-domains](https://appwrite.io/docs/custom-domains) for each project. + +### Init your SDK + +

Initialize your SDK code with your project ID, which can be found in your project settings page. + +```dart +import 'package:appwrite/appwrite.dart'; +Client client = Client(); + + +client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production +; +``` + +Before starting to send any API calls to your new Appwrite instance, make sure your Android or iOS emulators has network access to the Appwrite server hostname or IP address. + +When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API. + +### Make Your First Request + +

Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```dart +// Register User +Account account = Account(client); +Response user = await account + .create( + email: 'me@appwrite.io', + password: 'password', + name: 'My Name' + ); +``` + +### Full Example + +```dart +import 'package:appwrite/appwrite.dart'; +Client client = Client(); + + +client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production + ; + + +// Register User +Account account = Account(client); + +Response user = await account + .create( + email: 'me@appwrite.io', + password: 'password', + name: 'My Name' + ); +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Flutter Playground](https://github.com/appwrite/playground-for-flutter) \ No newline at end of file diff --git a/docs/sdks/nodejs/GETTING_STARTED.md b/docs/sdks/nodejs/GETTING_STARTED.md new file mode 100644 index 000000000..af2564e21 --- /dev/null +++ b/docs/sdks/nodejs/GETTING_STARTED.md @@ -0,0 +1,60 @@ +## Getting Started + +### Init your SDK +Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key project API keys section. + +```js +const sdk = require('node-appwrite'); + +let client = new sdk.Client(); + +client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; +``` + +### Make Your First Request +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```js +let users = new sdk.Users(client); + +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); +``` + +### Full Example +```js +const sdk = require('node-appwrite'); + +let client = new sdk.Client(); + +client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let users = new sdk.Users(client); +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Node Playground](https://github.com/appwrite/playground-for-node) diff --git a/docs/sdks/php/GETTING_STARTED.md b/docs/sdks/php/GETTING_STARTED.md new file mode 100644 index 000000000..1fcfa35f6 --- /dev/null +++ b/docs/sdks/php/GETTING_STARTED.md @@ -0,0 +1,48 @@ +## Getting Started + +### Init your SDK +Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. + +```php +$client = new Client(); + +$client + ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; +``` + +### Make Your First Request +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```php +$users = new Users($client); + +$result = $users->create('email@example.com', 'password'); +``` + +### Full Example +```php +use Appwrite\Client; +use Appwrite\Services\Users; + +$client = new Client(); + +$client + ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + ->setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$users = new Users($client); + +$result = $users->create('email@example.com', 'password'); +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite PHP Playground](https://github.com/appwrite/playground-for-php) diff --git a/docs/sdks/python/GETTING_STARTED.md b/docs/sdks/python/GETTING_STARTED.md new file mode 100644 index 000000000..6b16fa3a9 --- /dev/null +++ b/docs/sdks/python/GETTING_STARTED.md @@ -0,0 +1,51 @@ +## Getting Started + +### Init your SDK +Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. + +```python +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) +``` + +### Make Your First Request +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```python +users = Users(client) + +result = users.create('email@example.com', 'password') +``` + +### Full Example +```python +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.create('email@example.com', 'password') +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Python Playground](https://github.com/appwrite/playground-for-python) diff --git a/docs/sdks/ruby/GETTING_STARTED.md b/docs/sdks/ruby/GETTING_STARTED.md new file mode 100644 index 000000000..d353ee196 --- /dev/null +++ b/docs/sdks/ruby/GETTING_STARTED.md @@ -0,0 +1,49 @@ +## Getting Started + +### Init your SDK +Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. + +```ruby +require 'appwrite' + +client = Appwrite::Client.new() + +client + .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint + .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID + .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key +; +``` + +### Make Your First Request +Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section. + +```ruby +users = Appwrite::Users.new(client); + +result = users.create(email: 'email@example.com', password: 'password'); +``` + +### Full Example +```ruby +require 'appwrite' + +client = Appwrite::Client.new() + +client + .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint + .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID + .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key +; + +users = Appwrite::Users.new(client); + +result = users.create(email: 'email@example.com', password: 'password'); +``` + +### Learn more +You can use followng resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Ruby Playground](https://github.com/appwrite/playground-for-ruby) diff --git a/phpunit.xml b/phpunit.xml index b0c837272..ba4f4f496 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -8,6 +8,9 @@ processIsolation="false" stopOnFailure="false" > + + + ./tests/e2e/ diff --git a/tests/e2e/Services/Database/DatabaseBase.php b/tests/e2e/Services/Database/DatabaseBase.php index 2b93485f1..eedd312fe 100644 --- a/tests/e2e/Services/Database/DatabaseBase.php +++ b/tests/e2e/Services/Database/DatabaseBase.php @@ -501,6 +501,133 @@ trait DatabaseBase $this->assertEquals($document['headers']['status-code'], 404); - return []; + return $data; + } + + /** + * @depends testDeleteDocument + */ + public function testDefaultPermissions(array $data):array + { + $document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'name' => 'Captain America', + 'releaseYear' => 1944, + 'actors' => [], + ], + ]); + + $id = $document['body']['$id']; + + $this->assertEquals($document['headers']['status-code'], 201); + $this->assertEquals($document['body']['$collection'], $data['moviesId']); + $this->assertEquals($document['body']['name'], 'Captain America'); + $this->assertEquals($document['body']['releaseYear'], 1944); + $this->assertIsArray($document['body']['$permissions']); + $this->assertIsArray($document['body']['$permissions']['read']); + $this->assertIsArray($document['body']['$permissions']['write']); + + if($this->getSide() == 'client') { + $this->assertCount(1, $document['body']['$permissions']['read']); + $this->assertCount(1, $document['body']['$permissions']['write']); + $this->assertEquals(['user:'.$this->getUser()['$id']], $document['body']['$permissions']['read']); + $this->assertEquals(['user:'.$this->getUser()['$id']], $document['body']['$permissions']['write']); + } + + if($this->getSide() == 'server') { + $this->assertCount(0, $document['body']['$permissions']['read']); + $this->assertCount(0, $document['body']['$permissions']['write']); + $this->assertEquals([], $document['body']['$permissions']['read']); + $this->assertEquals([], $document['body']['$permissions']['write']); + } + + // Updated and Inherit Permissions + + $document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'name' => 'Captain America 2', + 'releaseYear' => 1945, + 'actors' => [], + ], + 'read' => ['*'], + ]); + + $this->assertEquals($document['headers']['status-code'], 200); + $this->assertEquals($document['body']['name'], 'Captain America 2'); + $this->assertEquals($document['body']['releaseYear'], 1945); + + if($this->getSide() == 'client') { + $this->assertCount(1, $document['body']['$permissions']['read']); + $this->assertCount(1, $document['body']['$permissions']['write']); + $this->assertEquals(['*'], $document['body']['$permissions']['read']); + $this->assertEquals(['user:'.$this->getUser()['$id']], $document['body']['$permissions']['write']); + } + + if($this->getSide() == 'server') { + $this->assertCount(1, $document['body']['$permissions']['read']); + $this->assertCount(0, $document['body']['$permissions']['write']); + $this->assertEquals(['*'], $document['body']['$permissions']['read']); + $this->assertEquals([], $document['body']['$permissions']['write']); + } + + $document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals($document['headers']['status-code'], 200); + $this->assertEquals($document['body']['name'], 'Captain America 2'); + $this->assertEquals($document['body']['releaseYear'], 1945); + + if($this->getSide() == 'client') { + $this->assertCount(1, $document['body']['$permissions']['read']); + $this->assertCount(1, $document['body']['$permissions']['write']); + $this->assertEquals(['*'], $document['body']['$permissions']['read']); + $this->assertEquals(['user:'.$this->getUser()['$id']], $document['body']['$permissions']['write']); + } + + if($this->getSide() == 'server') { + $this->assertCount(1, $document['body']['$permissions']['read']); + $this->assertCount(0, $document['body']['$permissions']['write']); + $this->assertEquals(['*'], $document['body']['$permissions']['read']); + $this->assertEquals([], $document['body']['$permissions']['write']); + } + + // Reset Permissions + + $document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $data['moviesId'] . '/documents/' . $id, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'name' => 'Captain America 3', + 'releaseYear' => 1946, + 'actors' => [], + ], + 'read' => [], + 'write' => [], + ]); + + if($this->getSide() == 'client') { + $this->assertEquals($document['headers']['status-code'], 401); + } + + if($this->getSide() == 'server') { + $this->assertEquals($document['headers']['status-code'], 200); + $this->assertEquals($document['body']['name'], 'Captain America 3'); + $this->assertEquals($document['body']['releaseYear'], 1946); + $this->assertCount(0, $document['body']['$permissions']['read']); + $this->assertCount(0, $document['body']['$permissions']['write']); + $this->assertEquals([], $document['body']['$permissions']['read']); + $this->assertEquals([], $document['body']['$permissions']['write']); + } + + return $data; } } \ No newline at end of file diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 9dded8fdd..b04a635cf 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -628,7 +628,7 @@ class FunctionsCustomServerTest extends Scope ], $this->getHeaders()), [ 'tag' => $tagId, ]); - + $this->assertEquals(200, $tag['headers']['status-code']); $execution = $this->client->call(Client::METHOD_POST, '/functions/'.$functionId.'/executions', array_merge([ diff --git a/tests/extensions/TestHook.php b/tests/extensions/TestHook.php new file mode 100644 index 000000000..a8d86304e --- /dev/null +++ b/tests/extensions/TestHook.php @@ -0,0 +1,15 @@ +