diff --git a/CHANGES.md b/CHANGES.md index b57ae948b1..5c3ab7703a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,31 @@ +# Version 0.6.0 (PRE-RELEASE) + +## Features + +* New collections UI with ability to create and update a collection +* New documents UI with ability to create and update a document +* Added support for Flutter iOS & Android apps +* Added support for default DB document values +* Exposed health API to all the server SDKs +* New locale for Khmer +* Added TypeScript type hinting to the JS SDK (@zevektor) +* Added LTR/RTL support for markdown editor +* Added cachebuster to version number on footer +* New OAuth logos +* Minor fixes to the dark mode theme +* Added JSON view for a project user +* Removed setKey and setMode methods from all client SDKs + +## Breaking Changes + +* Updated all the REST API query params to be in camelCase +* Normalized locale phone codes response body + +## Bug Fixes + +* Fixed project users logout button +* Fixed wrong target in database back link + # Version 0.5.3 (PRE-RELEASE) ## Bug Fixes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f585217755..83321193d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -158,7 +158,7 @@ Before running the command, make sure you have proper write permissions to the A To run tests manually, run phpunit from your command line: ```bash -docker exec appwrite /bin/bash -c '/usr/share/nginx/html/vendor/bin/phpunit' +docker exec appwrite test ``` ## Tutorials diff --git a/Dockerfile b/Dockerfile index f170a09575..25269eae08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -126,8 +126,12 @@ COPY --from=builder /usr/local/src/vendor /usr/share/nginx/html/vendor RUN mkdir -p /storage/uploads && \ mkdir -p /storage/cache && \ + mkdir -p /storage/config && \ + mkdir -p /storage/certificates && \ chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ - chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache + chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ + chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ + chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates # Supervisord Conf COPY ./docker/supervisord.conf /etc/supervisord.conf diff --git a/README.md b/README.md index e80338aca0..717d5548ec 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The easiest way to start running your Appwrite server is by running our docker-c docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/install/appwrite:rw \ - -e version=0.5.3 \ + -e version=0.6.0 \ appwrite/install ``` diff --git a/app/app.php b/app/app.php index 613707bb5b..e22d5dc24b 100644 --- a/app/app.php +++ b/app/app.php @@ -16,6 +16,7 @@ use Appwrite\Database\Database; use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; +use Appwrite\Network\Validators\Origin; /* * Configuration files @@ -51,11 +52,11 @@ $clients = array_unique(array_merge($clientsConsole, array_map(function ($node) return false; })))); -$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $roles, $webhook, $audit, $usage, $clients) { +$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $roles, $webhook, $audit, $usage, $clients) { $route = $utopia->match($request); - if(!empty($route->getLabel('sdk.platform', [])) && empty($project->getId())) { + if(!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) { throw new Exception('Missing or unknown project ID', 400); } @@ -96,16 +97,15 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ * Adding Appwrite API domains to allow XDOMAIN communication * Skip this check for non-web platforms which are not requiredto send an origin header */ - $origin = parse_url($request->getServer('HTTP_ORIGIN', $request->getServer('HTTP_REFERER', '')), PHP_URL_HOST); - - if (!empty($origin) - && !in_array($origin, $clients) - && in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE]) - && empty($request->getHeader('X-Appwrite-Key', '')) - ) { - throw new Exception('Access from this client host is forbidden', 403); - } + $origin = $request->getServer('HTTP_ORIGIN', $request->getServer('HTTP_REFERER', '')); + $originValidator = new Origin(array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); + if(!$originValidator->isValid($origin) + && in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE]) + && empty($request->getHeader('X-Appwrite-Key', ''))) { + throw new Exception($originValidator->getDescription(), 403); + } + /* * ACL Check */ @@ -410,12 +410,6 @@ $utopia->get('/.well-known/acme-challenge') } ); - - - - - - $name = APP_NAME; if (array_key_exists($service, $services)) { /** @noinspection PhpIncludeInspection */ diff --git a/app/config/platforms.php b/app/config/platforms.php index 98ab79633d..9cccf9872a 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -1,60 +1,45 @@ [ - 'key' => APP_PLATFORM_WEB, - 'name' => 'Web', - 'description' => 'Client libraries for integrating with '.APP_NAME.' to build web-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) tutorial to start building your first web application.', + APP_PLATFORM_CLIENT => [ + 'key' => APP_PLATFORM_CLIENT, + 'name' => 'Client', + 'description' => 'Client libraries for integrating with '.APP_NAME.' to build client-based applications and websites. Read the [getting started for web](/docs/getting-started-for-web) or [getting started for Flutter](/docs/getting-started-for-flutter) tutorials to start building your first application.', 'enabled' => true, 'beta' => false, - 'languages' => [ + 'languages' => [ // TODO change key to 'sdks' [ - 'key' => 'javascript', - 'name' => 'JavaScript', + 'key' => 'web', + 'name' => 'Web', 'version' => '1.0.29', 'url' => 'https://github.com/appwrite/sdk-for-js', 'enabled' => true, 'beta' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'javascript', - 'source' => realpath(__DIR__ . '/../sdks/web-javascript'), + 'source' => realpath(__DIR__ . '/../sdks/client-web'), 'gitUrl' => 'git@github.com:appwrite/sdk-for-js.git', 'gitRepoName' => 'sdk-for-js', 'gitUserName' => 'appwrite', ], [ - 'key' => 'typescript', - 'name' => 'TypeScript', - 'url' => '', - 'enabled' => false, + 'key' => 'flutter', + 'name' => 'Flutter', + 'version' => '0.2.1', + 'url' => 'https://github.com/appwrite/sdk-for-flutter', + 'enabled' => true, 'beta' => true, 'family' => APP_PLATFORM_CLIENT, - 'prism' => 'typescript', - 'source' => false, - 'gitUrl' => 'git@github.com:appwrite/sdk-for-typescript.git', - 'gitRepoName' => 'sdk-for-typescript', + 'prism' => 'dart', + 'source' => realpath(__DIR__ . '/../sdks/client-flutter'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter.git', + 'gitRepoName' => 'sdk-for-flutter', 'gitUserName' => 'appwrite', ], - ], - ], - - APP_PLATFORM_IOS => [ - 'key' => APP_PLATFORM_IOS, - 'name' => 'iOS', - 'description' => 'Client libraries for integrating with '.APP_NAME.' to build iOS applications. Read the [getting started for iOS](/docs/getting-started-for-ios) tutorial to start building your first iOS application.', - 'enabled' => false, - 'beta' => false, - 'languages' => [ [ 'key' => 'swift', 'name' => 'Swift', @@ -81,16 +66,6 @@ return [ 'gitRepoName' => 'sdk-for-objective-c', 'gitUserName' => 'appwrite', ], - ], - ], - - APP_PLATFORM_ANDROID => [ - 'key' => APP_PLATFORM_ANDROID, - 'name' => 'Android', - 'description' => 'Client libraries for integrating with '.APP_NAME.' to build Android applications. Read the [getting started for Android](/docs/getting-started-for-android) tutorial to start building your first Android application.', - 'enabled' => false, - 'beta' => false, - 'languages' => [ [ 'key' => 'kotlin', 'name' => 'Kotlin', @@ -104,62 +79,38 @@ return [ 'gitRepoName' => 'sdk-for-kotlin', 'gitUserName' => 'appwrite', ], - [ - 'key' => 'java', - 'name' => 'Java', - 'url' => '', - 'enabled' => false, - 'beta' => false, - 'family' => APP_PLATFORM_CLIENT, - 'prism' => 'java', - 'source' => false, - 'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git', - 'gitRepoName' => 'sdk-for-java', - 'gitUserName' => 'appwrite', - ], + // [ + // 'key' => 'java', + // 'name' => 'Java', + // 'url' => '', + // 'enabled' => false, + // 'beta' => false, + // 'family' => APP_PLATFORM_CLIENT, + // 'prism' => 'java', + // 'source' => false, + // 'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git', + // 'gitRepoName' => 'sdk-for-java', + // 'gitUserName' => 'appwrite', + // ], ], ], - - APP_PLATFORM_FLUTTER => [ - 'key' => APP_PLATFORM_FLUTTER, - 'name' => 'Flutter', - 'description' => 'Client libraries for integrating with '.APP_NAME.' to build cross-platform Flutter applications. Read the [getting started for Flutter](/docs/getting-started-for-flutter) tutorial to start building your first Flutter application.', - 'enabled' => false, - 'beta' => true, - 'languages' => [ - [ - 'key' => 'dart', - 'name' => 'Dart', - 'version' => '0.0.8', - 'url' => 'https://github.com/appwrite/sdk-for-dart', - 'enabled' => true, - 'beta' => true, - 'family' => APP_PLATFORM_CLIENT, - 'prism' => 'dart', - 'source' => realpath(__DIR__ . '/../sdks/flutter-dart'), - 'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git', - 'gitRepoName' => 'sdk-for-dart', - 'gitUserName' => 'appwrite', - ], - ], - ], - + APP_PLATFORM_CONSOLE => [ 'key' => APP_PLATFORM_CONSOLE, 'name' => 'Console', 'enabled' => false, 'beta' => false, - 'languages' => [ + 'languages' => [ // TODO change key to 'sdks' [ - 'key' => 'javascript', - 'name' => 'JS', + 'key' => 'web', + 'name' => 'Console', 'version' => '1.0.0', 'url' => 'https://github.com/appwrite/sdk-for-console', 'enabled' => true, 'beta' => false, 'family' => APP_PLATFORM_CONSOLE, 'prism' => 'console', - 'source' => realpath(__DIR__ . '/../sdks/console-javascript'), + 'source' => realpath(__DIR__ . '/../sdks/console-web'), 'gitUrl' => null, 'gitRepoName' => 'sdk-for-console', 'gitUserName' => 'appwrite', @@ -173,7 +124,7 @@ return [ 'description' => 'Libraries for integrating with '.APP_NAME.' to build server side integrations. Read the [getting started for server](/docs/getting-started-for-server) tutorial to start building your first server integration.', 'enabled' => true, 'beta' => false, - 'languages' => [ + 'languages' => [ // TODO change key to 'sdks' [ 'key' => 'nodejs', 'name' => 'Node.js', @@ -235,7 +186,7 @@ return [ 'name' => 'Go', 'version' => '0.0.6', 'url' => 'https://github.com/appwrite/sdk-for-go', - 'enabled' => true, + 'enabled' => false, 'beta' => true, 'family' => APP_PLATFORM_SERVER, 'prism' => 'go', @@ -244,7 +195,34 @@ return [ 'gitRepoName' => 'sdk-for-go', 'gitUserName' => 'appwrite', ], + [ + 'key' => 'java', + 'name' => 'Java', + 'version' => '0.0.1', + 'url' => 'https://github.com/appwrite/sdk-for-java', + 'enabled' => false, + 'beta' => true, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'java', + 'source' => realpath(__DIR__ . '/../sdks/server-java'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-java.git', + 'gitRepoName' => 'sdk-for-java', + 'gitUserName' => 'appwrite', + ], + [ + 'key' => 'dart', + 'name' => 'Dart', + 'version' => '0.0.1', + 'url' => 'https://github.com/appwrite/sdk-for-dart', + 'enabled' => false, + 'beta' => true, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'java', + 'source' => realpath(__DIR__ . '/../sdks/server-dart'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-dart.git', + 'gitRepoName' => 'sdk-for-dart', + 'gitUserName' => 'appwrite', + ], ], ], - ]; diff --git a/app/config/scopes.php b/app/config/scopes.php index 53b71dd78f..59ad2a0859 100644 --- a/app/config/scopes.php +++ b/app/config/scopes.php @@ -21,4 +21,5 @@ return [ // List of publicly visible scopes // 'webhooks.write', 'locale.read', 'avatars.read', + 'health.read', ];; \ No newline at end of file diff --git a/app/config/services.php b/app/config/services.php index be0679153f..cc5df8c8e2 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -43,8 +43,9 @@ return [ ], 'v1/health' => [ 'name' => 'Health', + 'description' => '/docs/services/health.md', 'controller' => 'controllers/api/health.php', - 'sdk' => false, + 'sdk' => true, 'tests' => false, ], 'v1/projects' => [ diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 8d92e1d662..ce19865264 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -30,8 +30,8 @@ use GeoIp2\Database\Reader; include_once __DIR__ . '/../shared/api.php'; -$oauthDefaultSuccess = Config::getParam('protocol').'://'.Config::getParam('domain').'/auth/oauth2/success'; -$oauthDefaultFailure = Config::getParam('protocol').'://'.Config::getParam('domain').'/auth/oauth2/failure'; +$oauthDefaultSuccess = $request->getServer('_APP_HOME').'/auth/oauth2/success'; +$oauthDefaultFailure = $request->getServer('_APP_HOME').'/auth/oauth2/failure'; $oauth2Keys = []; @@ -483,6 +483,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect') if($state['success'] === $oauthDefaultSuccess) { // Add keys for non-web platforms $state['success'] = URLParser::parse($state['success']); $query = URLParser::parseQuery($state['success']['query']); + $query['project'] = $project->getId(); $query['domain'] = COOKIE_DOMAIN; $query['key'] = Auth::$cookieName; $query['secret'] = Auth::encodeSession($user->getId(), $secret); @@ -721,7 +722,7 @@ $utopia->patch('/v1/account/password') ->label('sdk.method', 'updatePassword') ->label('sdk.description', '/docs/references/account/update-password.md') ->param('password', '', function () { return new Password(); }, 'New user password.') - ->param('old-password', '', function () { return new Password(); }, 'Old user password.') + ->param('oldPassword', '', function () { return new Password(); }, 'Old user password.') ->action( function ($password, $oldPassword) use ($response, $user, $projectDB, $audit, $oauth2Keys) { if (!Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password @@ -1119,11 +1120,11 @@ $utopia->put('/v1/account/recovery') ->label('abuse-key', 'url:{url},userId:{param-userId}') ->param('userId', '', function () { return new UID(); }, 'User account UID address.') ->param('secret', '', function () { return new Text(256); }, 'Valid reset token.') - ->param('password-a', '', function () { return new Password(); }, 'New password.') - ->param('password-b', '', function () {return new Password(); }, 'New password again.') + ->param('password', '', function () { return new Password(); }, 'New password.') + ->param('passwordAgain', '', function () {return new Password(); }, 'New password again.') ->action( - function ($userId, $secret, $passwordA, $passwordB) use ($response, $projectDB, $audit) { - if ($passwordA !== $passwordB) { + function ($userId, $secret, $password, $passwordAgain) use ($response, $projectDB, $audit) { + if ($password !== $passwordAgain) { throw new Exception('Passwords must match', 400); } @@ -1149,7 +1150,7 @@ $utopia->put('/v1/account/recovery') Authorization::setRole('user:'.$profile->getId()); $profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [ - 'password' => Auth::passwordHash($passwordA), + 'password' => Auth::passwordHash($password), 'password-update' => time(), 'emailVerification' => true, ])); diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 84689814d8..0e62ba9c6e 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -99,6 +99,7 @@ $utopia->get('/v1/avatars/credit-cards/:code') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getCreditCard') + ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-credit-card.md') ->action(function ($code, $width, $height, $quality) use ($avatarCallback) { return $avatarCallback('credit-cards', $code, $width, $height, $quality); }); @@ -127,6 +128,7 @@ $utopia->get('/v1/avatars/flags/:code') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFlag') + ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-flag.md') ->action(function ($code, $width, $height, $quality) use ($avatarCallback) { return $avatarCallback('flags', $code, $width, $height, $quality); }); @@ -140,6 +142,7 @@ $utopia->get('/v1/avatars/image') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getImage') + ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-image.md') ->action( function ($url, $width, $height) use ($response) { @@ -206,6 +209,7 @@ $utopia->get('/v1/avatars/favicon') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getFavicon') + ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-favicon.md') ->action( function ($url) use ($response, $request) { @@ -356,12 +360,13 @@ $utopia->get('/v1/avatars/qr') ->desc('Get QR Code') ->param('text', '', function () { return new Text(512); }, 'Plain text to be converted to QR code image.') ->param('size', 400, function () { return new Range(0, 1000); }, 'QR code size. Pass an integer between 0 to 1000. Defaults to 400.', true) - ->param('margin', 1, function () { return new Range(0, 10); }, 'Margin From Edge. Pass an integer between 0 to 10. Defaults to 1.', true) + ->param('margin', 1, function () { return new Range(0, 10); }, 'Margin from edge. Pass an integer between 0 to 10. Defaults to 1.', true) ->param('download', 0, function () { return new Range(0, 1); }, 'Return resulting image with \'Content-Disposition: attachment \' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.', true) ->label('scope', 'avatars.read') ->label('sdk.platform', [APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'avatars') ->label('sdk.method', 'getQR') + ->label('sdk.methodType', 'location') ->label('sdk.description', '/docs/references/avatars/get-qr.md') ->action( function ($text, $size, $margin, $download) use ($response) { diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 0cd5e7f572..69d01e9dc7 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -9,6 +9,9 @@ use Utopia\Validator\Range; use Utopia\Validator\WhiteList; use Utopia\Validator\Text; use Utopia\Validator\ArrayList; +use Utopia\Locale\Locale; +use Utopia\Audit\Audit; +use Utopia\Audit\Adapters\MySQL as AuditAdapter; use Appwrite\Database\Database; use Appwrite\Database\Document; use Appwrite\Database\Validator\UID; @@ -18,6 +21,8 @@ use Appwrite\Database\Validator\Collection; use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Exception\Authorization as AuthorizationException; use Appwrite\Database\Exception\Structure as StructureException; +use DeviceDetector\DeviceDetector; +use GeoIp2\Database\Reader; include_once __DIR__ . '/../shared/api.php'; @@ -70,6 +75,10 @@ $utopia->post('/v1/database/collections') throw new Exception('Failed saving document to DB', 500); } + if (false === $data) { + throw new Exception('Failed saving collection to DB', 500); + } + $data = $data->getArrayCopy(); $webhook @@ -160,6 +169,70 @@ $utopia->get('/v1/database/collections/:collectionId') } ); +$utopia->get('/v1/database/collections/:collectionId/logs') + ->desc('Get Collection Logs') + ->label('scope', 'collections.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'database') + ->label('sdk.method', 'getCollectionLogs') + ->label('sdk.description', '/docs/references/database/get-collection-logs.md') + ->param('collectionId', '', function () { return new UID(); }, 'Collection unique ID.') + ->action( + function ($collectionId) use ($response, $register, $projectDB, $project) { + $collection = $projectDB->getDocument($collectionId); + + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $adapter = new AuditAdapter($register->get('db')); + $adapter->setNamespace('app_'.$project->getId()); + + $audit = new Audit($adapter); + + $countries = Locale::getText('countries'); + + $logs = $audit->getLogsByResource('database/collection/'.$collection->getId()); + + $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); + $output = []; + + foreach ($logs as $i => &$log) { + $log['userAgent'] = (!empty($log['userAgent'])) ? $log['userAgent'] : 'UNKNOWN'; + + $dd = new DeviceDetector($log['userAgent']); + + $dd->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) + + $dd->parse(); + + $output[$i] = [ + 'event' => $log['event'], + 'ip' => $log['ip'], + 'time' => strtotime($log['time']), + 'OS' => $dd->getOs(), + 'client' => $dd->getClient(), + 'device' => $dd->getDevice(), + 'brand' => $dd->getBrand(), + 'model' => $dd->getModel(), + 'geo' => [], + ]; + + try { + $record = $reader->country($log['ip']); + $output[$i]['geo']['isoCode'] = strtolower($record->country->isoCode); + $output[$i]['geo']['country'] = $record->country->name; + $output[$i]['geo']['country'] = (isset($countries[$record->country->isoCode])) ? $countries[$record->country->isoCode] : Locale::getText('locale.country.unknown'); + } catch (\Exception $e) { + $output[$i]['geo']['isoCode'] = '--'; + $output[$i]['geo']['country'] = Locale::getText('locale.country.unknown'); + } + } + + $response->json($output); + } + ); + $utopia->put('/v1/database/collections/:collectionId') ->desc('Update Collection') ->label('scope', 'collections.write') @@ -193,16 +266,24 @@ $utopia->put('/v1/database/collections/:collectionId') ], $rule); } - $collection = $projectDB->updateDocument(array_merge($collection->getArrayCopy(), [ - 'name' => $name, - 'structure' => true, - 'dateUpdated' => time(), - '$permissions' => [ - 'read' => $read, - 'write' => $write, - ], - 'rules' => $rules, - ])); + try { + $collection = $projectDB->updateDocument(array_merge($collection->getArrayCopy(), [ + 'name' => $name, + 'structure' => true, + 'dateUpdated' => time(), + '$permissions' => [ + 'read' => $read, + 'write' => $write, + ], + 'rules' => $parsedRules, + ])); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized action', 401); + } catch (StructureException $exception) { + throw new Exception('Bad structure. '.$exception->getMessage(), 400); + } catch (\Exception $exception) { + throw new Exception('Failed saving document to DB', 500); + } if (false === $collection) { throw new Exception('Failed saving collection to DB', 500); @@ -336,6 +417,18 @@ $utopia->post('/v1/database/collections/:collectionId/documents') $data = $parentDocument->getArrayCopy(); } + /** + * Set default collection values + */ + foreach ($collection->getAttribute('rules') as $key => $rule) { + $key = (isset($rule['key'])) ? $rule['key'] : ''; + $default = (isset($rule['default'])) ? $rule['default'] : null; + + if(!isset($data[$key])) { + $data[$key] = $default; + } + } + try { $data = $projectDB->createDocument($data); } catch (AuthorizationException $exception) { @@ -379,9 +472,9 @@ $utopia->get('/v1/database/collections/:collectionId/documents') ->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$id>=5bed2d152c362\'.', true) ->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true) ->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true) - ->param('order-field', '$id', function () { return new Text(128); }, 'Document field that results will be sorted by.', true) - ->param('order-type', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) - ->param('order-cast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) + ->param('orderField', '$id', function () { return new Text(128); }, 'Document field that results will be sorted by.', true) + ->param('orderType', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true) + ->param('orderCast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) ->param('search', '', function () { return new Text(256); }, 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children.', true) ->param('first', 0, function () { return new Range(0, 1); }, 'Return only the first document. Pass 1 for true or 0 for false. The default value is 0.', true) ->param('last', 0, function () { return new Range(0, 1); }, 'Return only the last document. Pass 1 for true or 0 for false. The default value is 0.', true) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 60685024f1..9e9ea09635 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -8,12 +8,12 @@ use Appwrite\Storage\Storage; use Appwrite\ClamAV\Network; $utopia->get('/v1/health') - ->desc('Check API HTTP Health') + ->desc('Get HTTP') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'get') - ->label('docs', false) + ->label('sdk.description', '/docs/references/health/get.md') ->action( function () use ($response) { $response->json(['status' => 'OK']); @@ -21,12 +21,12 @@ $utopia->get('/v1/health') ); $utopia->get('/v1/health/db') - ->desc('Check DB Health') + ->desc('Get DB') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getDB') - ->label('docs', false) + ->label('sdk.description', '/docs/references/health/get-db.md') ->action( function () use ($response, $register) { $register->get('db'); /* @var $db PDO */ @@ -36,12 +36,12 @@ $utopia->get('/v1/health/db') ); $utopia->get('/v1/health/cache') - ->desc('Check Cache Health') + ->desc('Get Cache') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getCache') - ->label('docs', false) + ->label('sdk.description', '/docs/references/health/get-cache.md') ->action( function () use ($response, $register) { $register->get('cache'); /* @var $cache Predis\Client */ @@ -51,12 +51,12 @@ $utopia->get('/v1/health/cache') ); $utopia->get('/v1/health/time') - ->desc('Check Time Health') + ->desc('Get Time') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getTime') - ->label('docs', false) + ->label('sdk.description', '/docs/references/health/get-time.md') ->action( function () use ($response) { /* @@ -97,26 +97,91 @@ $utopia->get('/v1/health/time') } ); -$utopia->get('/v1/health/webhooks') - ->desc('Check Webhooks Health') +$utopia->get('/v1/health/queue/webhooks') + ->desc('Get Webhooks Queue') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getWebhooks') - ->label('docs', false) + ->label('sdk.method', 'getQueueWebhooks') + ->label('sdk.description', '/docs/references/health/get-queue-webhooks.md') ->action( function () use ($response) { $response->json(['size' => Resque::size('v1-webhooks')]); } ); +$utopia->get('/v1/health/queue/tasks') + ->desc('Get Tasks Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueTasks') + ->label('sdk.description', '/docs/references/health/get-queue-tasks.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-tasks')]); + } + ); + +$utopia->get('/v1/health/queue/logs') +->desc('Get Logs Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueLogs') + ->label('sdk.description', '/docs/references/health/get-queue-logs.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-audit')]); + } + ); + +$utopia->get('/v1/health/queue/usage') + ->desc('Get Usage Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueUsage') + ->label('sdk.description', '/docs/references/health/get-queue-usage.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-usage')]); + } + ); + +$utopia->get('/v1/health/queue/certificates') + ->desc('Get Certificate Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueCertificates') + ->label('sdk.description', '/docs/references/health/get-queue-certificates.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-usage')]); + } + ); + +$utopia->get('/v1/health/queue/functions') + ->desc('Get Functions Queue') + ->label('scope', 'health.read') + ->label('sdk.platform', [APP_PLATFORM_SERVER]) + ->label('sdk.namespace', 'health') + ->label('sdk.method', 'getQueueFunctions') + ->label('sdk.description', '/docs/references/health/get-queue-functions.md') + ->action( + function () use ($response) { + $response->json(['size' => Resque::size('v1-functions')]); + } + ); + $utopia->get('/v1/health/storage/local') - ->desc('Check File System Health') + ->desc('Get Local Storage') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') ->label('sdk.method', 'getStorageLocal') - ->label('docs', false) + ->label('sdk.description', '/docs/references/health/get-storage-local.md') ->action( function () use ($response) { $device = new Local(APP_STORAGE_UPLOADS.'/'); @@ -124,22 +189,34 @@ $utopia->get('/v1/health/storage/local') if (!is_readable($device->getRoot().'/..')) { throw new Exception('Device is not readable'); } + + if (!is_writable($device->getRoot().'/../uploads')) { + throw new Exception('Device uploads dir is not writable'); + } + + if (!is_writable($device->getRoot().'/../cache')) { + throw new Exception('Device cache dir is not writable'); + } - if (!is_writable($device->getRoot().'/..')) { - throw new Exception('Device is not writable'); + if (!is_writable($device->getRoot().'/../config')) { + throw new Exception('Device config dir is not writable'); + } + + if (!is_writable($device->getRoot().'/../certificates')) { + throw new Exception('Device certificates dir is not writable'); } $response->json(['status' => 'OK']); } ); -$utopia->get('/v1/health/storage/anti-virus') - ->desc('Check Anti virus Health') +$utopia->get('/v1/health/anti-virus') + ->desc('Get Anti virus') ->label('scope', 'health.read') ->label('sdk.platform', [APP_PLATFORM_SERVER]) ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getStorageAntiVirus') - ->label('docs', false) + ->label('sdk.method', 'getAntiVirus') + ->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md') ->action( function () use ($response) { $antiVirus = new Network('clamav', 3310); @@ -151,12 +228,12 @@ $utopia->get('/v1/health/storage/anti-virus') } ); -$utopia->get('/v1/health/stats') - ->desc('System Stats') +$utopia->get('/v1/health/stats') // Currently only used internally + ->desc('Get System Stats') ->label('scope', 'god') - ->label('sdk.platform', [APP_PLATFORM_SERVER]) - ->label('sdk.namespace', 'health') - ->label('sdk.method', 'getStats') + // ->label('sdk.platform', [APP_PLATFORM_SERVER]) + // ->label('sdk.namespace', 'health') + // ->label('sdk.method', 'getStats') ->label('docs', false) ->action( function () use ($response, $register) { diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index fe1fcc386e..dc1b8a27c0 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -153,28 +153,55 @@ $utopia->get('/v1/projects/:projectId/usage') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'getUsage') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') + ->param('range', 'last30', function () { return new WhiteList(['daily', 'monthly', 'last30', 'last90']); }, 'Date range.', true) ->action( - function ($projectId) use ($response, $consoleDB, $projectDB, $register) { + function ($projectId, $range) use ($response, $consoleDB, $projectDB, $register) { $project = $consoleDB->getDocument($projectId); if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) { throw new Exception('Project not found', 404); } + $period = [ + 'daily' => [ + 'start' => DateTime::createFromFormat('U', strtotime('today')), + 'end' => DateTime::createFromFormat('U', strtotime('tomorrow')), + 'group' => '1m', + ], + 'monthly' => [ + 'start' => DateTime::createFromFormat('U', strtotime('midnight first day of this month')), + 'end' => DateTime::createFromFormat('U', strtotime('midnight last day of this month')), + 'group' => '1d', + ], + 'last30' => [ + 'start' => DateTime::createFromFormat('U', strtotime('-30 days')), + 'end' => DateTime::createFromFormat('U', strtotime('tomorrow')), + 'group' => '1d', + ], + 'last90' => [ + 'start' => DateTime::createFromFormat('U', strtotime('-90 days')), + 'end' => DateTime::createFromFormat('U', strtotime('today')), + 'group' => '1d', + ], + // 'yearly' => [ + // 'start' => DateTime::createFromFormat('U', strtotime('midnight first day of january')), + // 'end' => DateTime::createFromFormat('U', strtotime('midnight last day of december')), + // 'group' => '4w', + // ], + ]; + $client = $register->get('influxdb'); $requests = []; $network = []; if ($client) { - $start = DateTime::createFromFormat('U', strtotime('last day of last month')); - $start = $start->format(DateTime::RFC3339); - $end = DateTime::createFromFormat('U', strtotime('last day of this month')); - $end = $end->format(DateTime::RFC3339); + $start = $period[$range]['start']->format(DateTime::RFC3339); + $end = $period[$range]['end']->format(DateTime::RFC3339); $database = $client->selectDB('telegraf'); // Requests - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)'); + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); $points = $result->getPoints(); foreach ($points as $point) { @@ -185,7 +212,7 @@ $utopia->get('/v1/projects/:projectId/usage') } // Network - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)'); + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); $points = $result->getPoints(); foreach ($points as $point) { @@ -1030,7 +1057,7 @@ $utopia->post('/v1/projects/:projectId/platforms') ->label('sdk.namespace', 'projects') ->label('sdk.method', 'createPlatform') ->param('projectId', null, function () { return new UID(); }, 'Project unique ID.') - ->param('type', null, function () { return new WhiteList(['web', 'ios', 'android', 'unity']); }, 'Platform type.') + ->param('type', null, function () { return new WhiteList(['web', 'flutter-ios', 'flutter-android', 'ios', 'android', 'unity']); }, 'Platform type.') ->param('name', null, function () { return new Text(256); }, 'Platform name.') ->param('key', '', function () { return new Text(256); }, 'Package name for android or bundle ID for iOS.', true) ->param('store', '', function () { return new Text(256); }, 'App store or Google Play store ID.', true) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index e1153a7af9..3c0c6a40ca 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -302,7 +302,23 @@ $utopia->get('/v1/users/:userId/logs') $countries = Locale::getText('countries'); - $logs = $audit->getLogsByUser($user->getId()); + $logs = $audit->getLogsByUserAndActions($user->getId(), [ + 'account.create', + 'account.delete', + 'account.update.name', + 'account.update.email', + 'account.update.password', + 'account.update.prefs', + 'account.sessions.create', + 'account.sessions.delete', + 'account.recovery.create', + 'account.recovery.update', + 'account.verification.create', + 'account.verification.update', + 'teams.membership.create', + 'teams.membership.update', + 'teams.membership.delete', + ]); $reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb'); $output = []; @@ -433,7 +449,7 @@ $utopia->patch('/v1/users/:userId/prefs') ); -$utopia->delete('/v1/users/:userId/sessions/:session') +$utopia->delete('/v1/users/:userId/sessions/:sessionId') ->desc('Delete User Session') ->label('scope', 'users.write') ->label('sdk.platform', [APP_PLATFORM_SERVER]) diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 8aea506642..70f32693f3 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -8,10 +8,11 @@ use Utopia\View; use Utopia\Config\Config; use Utopia\Domains\Domain; use Appwrite\Database\Database; +use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Validator\UID; use Appwrite\Storage\Storage; -$utopia->init(function () use ($layout, $utopia) { +$utopia->init(function () use ($layout) { $layout ->setParam('analytics', 'UA-26264668-5') ; @@ -178,12 +179,14 @@ $utopia->get('/console/database') }); $utopia->get('/console/database/collection') - ->desc('Platform console project settings') + ->desc('Platform console project database collection') ->label('permission', 'public') ->label('scope', 'console') ->param('id', '', function () { return new UID(); }, 'Collection unique ID.') ->action(function ($id) use ($layout, $projectDB) { + Authorization::disable(); $collection = $projectDB->getDocument($id, false); + Authorization::reset(); if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { throw new Exception('Collection not found', 404); @@ -192,11 +195,41 @@ $utopia->get('/console/database/collection') $page = new View(__DIR__.'/../../views/console/database/collection.phtml'); $page - ->setParam('collection', $collection->getArrayCopy()) + ->setParam('collection', $collection) ; $layout - ->setParam('title', APP_NAME.' - Database') + ->setParam('title', APP_NAME.' - Database Collection') + ->setParam('body', $page); + }); + +$utopia->get('/console/database/document') + ->desc('Platform console project database document') + ->label('permission', 'public') + ->label('scope', 'console') + ->param('collection', '', function () { return new UID(); }, 'Collection unique ID.') + ->action(function ($collection) use ($layout, $projectDB) { + Authorization::disable(); + $collection = $projectDB->getDocument($collection, false); + Authorization::reset(); + + if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) { + throw new Exception('Collection not found', 404); + } + + $page = new View(__DIR__.'/../../views/console/database/document.phtml'); + $searchFiles = new View(__DIR__.'/../../views/console/database/search/files.phtml'); + $searchDocuments = new View(__DIR__.'/../../views/console/database/search/documents.phtml'); + + $page + ->setParam('db', $projectDB) + ->setParam('collection', $collection) + ->setParam('searchFiles', $searchFiles) + ->setParam('searchDocuments', $searchDocuments) + ; + + $layout + ->setParam('title', APP_NAME.' - Database Document') ->setParam('body', $page); }); diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 0871e8c252..f3e4fd72c8 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -6,6 +6,8 @@ global $utopia, $response, $request, $layout; use Utopia\View; use Utopia\Config\Config; +use Utopia\Validator\WhiteList; +use Utopia\Validator\Range; $header = new View(__DIR__.'/../../views/home/comps/header.phtml'); $footer = new View(__DIR__.'/../../views/home/comps/footer.phtml'); @@ -155,3 +157,401 @@ $utopia->get('/error/:code') ->setParam('title', 'Error'.' - '.APP_NAME) ->setParam('body', $page); }); + +$utopia->get('/open-api-2.json') + ->label('scope', 'public') + ->label('docs', false) + ->param('platform', APP_PLATFORM_CLIENT, function () {return new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE]);}, 'Choose target platform.', true) + ->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true) + ->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true) + ->action( + function ($platform, $extensions, $tests) use ($response, $request, $utopia, $services) { + function fromCamelCase($input) + { + preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); + $ret = $matches[0]; + foreach ($ret as &$match) { + $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match); + } + + return implode('_', $ret); + } + + function fromCamelCaseToDash($input) + { + return str_replace([' ', '_'], '-', strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $input))); + } + + foreach ($services as $service) { /* @noinspection PhpIncludeInspection */ + if($tests && !isset($service['tests'])) { + continue; + } + + if($tests && !$service['tests']) { + continue; + } + + if (!$tests && !$service['sdk']) { + continue; + } + + /** @noinspection PhpIncludeInspection */ + include_once realpath(__DIR__.'/../../'.$service['controller']); + } + + $security = [ + APP_PLATFORM_CLIENT => ['Project' => []], + APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []], + APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []], + ]; + + $platforms = [ + 'client' => APP_PLATFORM_CLIENT, + 'server' => APP_PLATFORM_SERVER, + 'all' => APP_PLATFORM_CONSOLE, + ]; + + $keys = [ + APP_PLATFORM_CLIENT => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + ], + APP_PLATFORM_SERVER => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Key' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Key', + 'description' => 'Your secret API key', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + ], + APP_PLATFORM_CONSOLE => [ + 'Project' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Project', + 'description' => 'Your project ID', + 'in' => 'header', + ], + 'Key' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Key', + 'description' => 'Your secret API key', + 'in' => 'header', + ], + 'Locale' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Locale', + 'description' => '', + 'in' => 'header', + ], + 'Mode' => [ + 'type' => 'apiKey', + 'name' => 'X-Appwrite-Mode', + 'description' => '', + 'in' => 'header', + ], + ], + ]; + + /* + * Specifications (v3.0.0): + * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md + */ + $output = [ + 'swagger' => '2.0', + 'info' => [ + 'version' => APP_VERSION_STABLE, + 'title' => APP_NAME, + 'description' => 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)', + 'termsOfService' => 'https://appwrite.io/policy/terms', + 'contact' => [ + 'name' => 'Appwrite Team', + 'url' => 'https://appwrite.io/support', + 'email' => $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), + ], + 'license' => [ + 'name' => 'BSD-3-Clause', + 'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE', + ], + ], + 'host' => parse_url($request->getServer('_APP_HOME', Config::getParam('domain')), PHP_URL_HOST), + 'basePath' => '/v1', + 'schemes' => ['https'], + 'consumes' => ['application/json', 'multipart/form-data'], + 'produces' => ['application/json'], + 'securityDefinitions' => $keys[$platform], + 'paths' => [], + 'definitions' => [ + // 'Pet' => [ + // 'required' => ['id', 'name'], + // 'properties' => [ + // 'id' => [ + // 'type' => 'integer', + // 'format' => 'int64', + // ], + // 'name' => [ + // 'type' => 'string', + // ], + // 'tag' => [ + // 'type' => 'string', + // ], + // ], + // ], + // 'Pets' => array( + // 'type' => 'array', + // 'items' => array( + // '$ref' => '#/definitions/Pet', + // ), + // ), + 'Error' => array( + 'required' => array( + 0 => 'code', + 1 => 'message', + ), + 'properties' => array( + 'code' => array( + 'type' => 'integer', + 'format' => 'int32', + ), + 'message' => array( + 'type' => 'string', + ), + ), + ), + ], + 'externalDocs' => [ + 'description' => 'Full API docs, specs and tutorials', + 'url' => Config::getParam('protocol').'://'.Config::getParam('domain').'/docs', + ], + ]; + + if ($extensions) { + if(isset($output['securityDefinitions']['Project'])) { + $output['securityDefinitions']['Project']['extensions'] = ['demo' => '5df5acd0d48c2']; + } + + if(isset($output['securityDefinitions']['Key'])) { + $output['securityDefinitions']['Key']['extensions'] = ['demo' => '919c2d18fb5d4...a2ae413da83346ad2']; + } + + if(isset($output['securityDefinitions']['Locale'])) { + $output['securityDefinitions']['Locale']['extensions'] = ['demo' => 'en']; + } + + if(isset($output['securityDefinitions']['Mode'])) { + $output['securityDefinitions']['Mode']['extensions'] = ['demo' => '']; + } + } + + foreach ($utopia->getRoutes() as $key => $method) { + foreach ($method as $route) { /* @var $route \Utopia\Route */ + if (!$route->getLabel('docs', true)) { + continue; + } + + if (empty($route->getLabel('sdk.namespace', null))) { + continue; + } + + if($platform !== APP_PLATFORM_CONSOLE && !in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) { + continue; + } + + $url = str_replace('/v1', '', $route->getURL()); + $scope = $route->getLabel('scope', ''); + $hide = $route->getLabel('sdk.hide', false); + $consumes = ['application/json']; + + if ($hide) { + continue; + } + + $desc = (!empty($route->getLabel('sdk.description', ''))) ? realpath('../'.$route->getLabel('sdk.description', '')) : null; + + $temp = [ + 'summary' => $route->getDesc(), + 'operationId' => $route->getLabel('sdk.method', uniqid()), + 'consumes' => [], + 'tags' => [$route->getLabel('sdk.namespace', 'default')], + 'description' => ($desc) ? file_get_contents($desc) : '', + + // 'responses' => [ + // 200 => [ + // 'description' => 'An paged array of pets', + // 'schema' => [ + // '$ref' => '#/definitions/Pet', + // ], + // ], + // ], + ]; + + if ($extensions) { + $platformList = $route->getLabel('sdk.platform', []); + + $temp['extensions'] = [ + 'weight' => $route->getOrder(), + 'cookies' => $route->getLabel('sdk.cookies', false), + 'type' => $route->getLabel('sdk.methodType', ''), + 'demo' => 'docs/examples/'.fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.fromCamelCaseToDash($temp['operationId']).'.md', + 'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''), + 'rate-limit' => $route->getLabel('abuse-limit', 0), + 'rate-time' => $route->getLabel('abuse-time', 3600), + 'scope' => $route->getLabel('scope', ''), + 'platforms' => $platformList, + ]; + } + + if ((!empty($scope))) { // && 'public' != $scope + $temp['security'][] = $route->getLabel('sdk.security', $security[$platform]); + } + + $requestBody = [ + 'content' => [ + 'application/x-www-form-urlencoded' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [], + ], + 'required' => [], + ], + ], + ]; + + foreach ($route->getParams() as $name => $param) { + $validator = (is_callable($param['validator'])) ? $param['validator']() : $param['validator']; /* @var $validator \Utopia\Validator */ + + $node = [ + 'name' => $name, + 'description' => $param['description'], + 'required' => !$param['optional'], + ]; + + switch ((!empty($validator)) ? get_class($validator) : '') { + case 'Utopia\Validator\Text': + $node['type'] = 'string'; + $node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']'; + break; + case 'Appwrite\Database\Validator\UID': + $node['type'] = 'string'; + $node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']'; + break; + case 'Utopia\Validator\Email': + $node['type'] = 'string'; + $node['format'] = 'email'; + $node['x-example'] = 'email@example.com'; + break; + case 'Utopia\Validator\URL': + $node['type'] = 'string'; + $node['format'] = 'url'; + $node['x-example'] = 'https://example.com'; + break; + case 'Utopia\Validator\JSON': + case 'Utopia\Validator\Mock': + case 'Utopia\Validator\Assoc': + $node['type'] = 'object'; + $node['type'] = 'object'; + $node['x-example'] = '{}'; + //$node['format'] = 'json'; + break; + case 'Appwrite\Storage\Validators\File': + $consumes = ['multipart/form-data']; + $node['type'] = 'file'; + break; + case 'Utopia\Validator\ArrayList': + $node['type'] = 'array'; + $node['collectionFormat'] = 'multi'; + $node['items'] = [ + 'type' => 'string', + ]; + break; + case 'Appwrite\Auth\Validator\Password': + $node['type'] = 'string'; + $node['format'] = 'format'; + $node['x-example'] = 'password'; + break; + case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */ + $node['type'] = 'integer'; + $node['format'] = 'int32'; + $node['x-example'] = $validator->getMin(); + break; + case 'Utopia\Validator\Numeric': + $node['type'] = 'integer'; + $node['format'] = 'int32'; + break; + case 'Utopia\Validator\Length': + $node['type'] = 'string'; + break; + case 'Utopia\Validator\Host': + $node['type'] = 'string'; + $node['format'] = 'url'; + $node['x-example'] = 'https://example.com'; + break; + case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */ + $node['type'] = 'string'; + $node['x-example'] = $validator->getList()[0]; + break; + default: + $node['type'] = 'string'; + break; + } + + if ($param['optional'] && !is_null($param['default'])) { // Param has default value + $node['default'] = $param['default']; + } + + if (false !== strpos($url, ':'.$name)) { // Param is in URL path + $node['in'] = 'path'; + $temp['parameters'][] = $node; + } elseif ($key == 'GET') { // Param is in query + $node['in'] = 'query'; + $temp['parameters'][] = $node; + } else { // Param is in payload + $node['in'] = 'formData'; + $temp['parameters'][] = $node; + $requestBody['content']['application/x-www-form-urlencoded']['schema']['properties'][] = $node; + + if (!$param['optional']) { + $requestBody['content']['application/x-www-form-urlencoded']['required'][] = $name; + } + } + + $url = str_replace(':'.$name, '{'.$name.'}', $url); + } + + $temp['consumes'] = $consumes; + + $output['paths'][$url][strtolower($route->getMethod())] = $temp; + } + } + + /*foreach ($consoleDB->getMocks() as $mock) { + var_dump($mock['name']); + }*/ + + ksort($output['paths']); + + $response + ->json($output); + } + ); \ No newline at end of file diff --git a/app/init.php b/app/init.php index 2ed4f32c23..a30787c54a 100644 --- a/app/init.php +++ b/app/init.php @@ -32,8 +32,8 @@ const APP_EMAIL_SECURITY = 'security@localhost.test'; // Default security email const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s'; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 15; -const APP_CACHE_BUSTER = 56; -const APP_VERSION_STABLE = '0.5.3'; +const APP_CACHE_BUSTER = 125; +const APP_VERSION_STABLE = '0.6.0'; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_CACHE = '/storage/cache'; const APP_STORAGE_CERTIFICATES = '/storage/certificates'; @@ -45,6 +45,7 @@ const APP_SOCIAL_LINKEDIN = 'https://www.linkedin.com/company/appwrite'; const APP_SOCIAL_INSTAGRAM = 'https://www.instagram.com/appwrite.io'; const APP_SOCIAL_GITHUB = 'https://github.com/appwrite'; const APP_SOCIAL_DISCORD = 'https://discord.gg/GSeTUeA'; +const APP_SOCIAL_DEV = 'https://dev.to/appwrite'; $register = new Registry(); $request = new Request(); diff --git a/app/sdks/client-flutter/CHANGELOG.md b/app/sdks/client-flutter/CHANGELOG.md new file mode 100644 index 0000000000..0bb441e953 --- /dev/null +++ b/app/sdks/client-flutter/CHANGELOG.md @@ -0,0 +1,42 @@ +## 0.2.1 + +- Fixed callback scheme + +## 0.2.0 + +- Updated flutter_web_auth plugin to version 0.2.4 +- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects + +## 0.1.1 + +- Updated flutter_web_auth version + +## 0.1.0 + +- Added examples file +- Some minor style fixes + +## 0.0.14 + +- Using MultipartFile for file uploads + +## 0.0.13 + +- Fix for file upload method + +## 0.0.12 + +- Added file upload support for storage service + +## 0.0.11 + +- Added integration with web auth plugin to support Appwrite OAuth API + +## 0.0.9 + +- Updated deafult params + +## 0.0.8 + +- Fixed compilation error in Client class +- Shorter description for package \ No newline at end of file diff --git a/app/sdks/console-javascript/LICENSE b/app/sdks/client-flutter/LICENSE similarity index 100% rename from app/sdks/console-javascript/LICENSE rename to app/sdks/client-flutter/LICENSE diff --git a/app/sdks/flutter-dart/README.md b/app/sdks/client-flutter/README.md similarity index 50% rename from app/sdks/flutter-dart/README.md rename to app/sdks/client-flutter/README.md index 861d150ba8..8c17a5b4a4 100644 --- a/app/sdks/flutter-dart/README.md +++ b/app/sdks/client-flutter/README.md @@ -1,11 +1,14 @@ -# Appwrite SDK for Dart +# Appwrite Flutter SDK -![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite) +![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.** -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -17,7 +20,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^0.0.8 + appwrite: ^0.2.1 ``` You can install packages from the command line: diff --git a/app/sdks/client-flutter/docs/examples/account/create-o-auth2session.md b/app/sdks/client-flutter/docs/examples/account/create-o-auth2session.md new file mode 100644 index 0000000000..2745fc48bd --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/create-o-auth2session.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.createOAuth2Session( + provider: 'bitbucket', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/create-recovery.md b/app/sdks/client-flutter/docs/examples/account/create-recovery.md new file mode 100644 index 0000000000..f381743e10 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/create-recovery.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/create-session.md b/app/sdks/client-flutter/docs/examples/account/create-session.md new file mode 100644 index 0000000000..65584ae62a --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/create-session.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.createSession( + email: 'email@example.com', + password: 'password', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/create-verification.md b/app/sdks/client-flutter/docs/examples/account/create-verification.md new file mode 100644 index 0000000000..735c53f4dd --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/create-verification.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.createVerification( + url: 'https://example.com', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/create.md b/app/sdks/client-flutter/docs/examples/account/create.md new file mode 100644 index 0000000000..596c8e8fcf --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/create.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.create( + email: 'email@example.com', + password: 'password', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/delete-session.md b/app/sdks/client-flutter/docs/examples/account/delete-session.md new file mode 100644 index 0000000000..a1c4fe58c0 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/delete-session.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.deleteSession( + sessionId: '[SESSION_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/delete-sessions.md b/app/sdks/client-flutter/docs/examples/account/delete-sessions.md new file mode 100644 index 0000000000..e0e0f9d6ea --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/delete-sessions.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.deleteSessions(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/delete.md b/app/sdks/client-flutter/docs/examples/account/delete.md new file mode 100644 index 0000000000..6566687b96 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/delete.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.delete(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/get-logs.md b/app/sdks/client-flutter/docs/examples/account/get-logs.md new file mode 100644 index 0000000000..00d0d95eee --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/get-logs.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.getLogs(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/get-prefs.md b/app/sdks/client-flutter/docs/examples/account/get-prefs.md new file mode 100644 index 0000000000..ac9af996e8 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/get-prefs.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.getPrefs(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/get-sessions.md b/app/sdks/client-flutter/docs/examples/account/get-sessions.md new file mode 100644 index 0000000000..136b349bbc --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/get-sessions.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.getSessions(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/get.md b/app/sdks/client-flutter/docs/examples/account/get.md new file mode 100644 index 0000000000..7a3fab6ae3 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/get.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.get(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-email.md b/app/sdks/client-flutter/docs/examples/account/update-email.md new file mode 100644 index 0000000000..0e3783719b --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-email.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updateEmail( + email: 'email@example.com', + password: 'password', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-name.md b/app/sdks/client-flutter/docs/examples/account/update-name.md new file mode 100644 index 0000000000..f36e747d80 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-name.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updateName( + name: '[NAME]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-password.md b/app/sdks/client-flutter/docs/examples/account/update-password.md new file mode 100644 index 0000000000..dbc873634f --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-password.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updatePassword( + password: 'password', + oldPassword: 'password', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-prefs.md b/app/sdks/client-flutter/docs/examples/account/update-prefs.md new file mode 100644 index 0000000000..6a687b63f4 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-prefs.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updatePrefs( + prefs: {}, +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-recovery.md b/app/sdks/client-flutter/docs/examples/account/update-recovery.md new file mode 100644 index 0000000000..07c892deb6 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-recovery.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updateRecovery( + userId: '[USER_ID]', + secret: '[SECRET]', + password: 'password', + passwordAgain: 'password', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/account/update-verification.md b/app/sdks/client-flutter/docs/examples/account/update-verification.md new file mode 100644 index 0000000000..7b080556b2 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/account/update-verification.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Account account = Account(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = account.updateVerification( + userId: '[USER_ID]', + secret: '[SECRET]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-browser.md b/app/sdks/client-flutter/docs/examples/avatars/get-browser.md new file mode 100644 index 0000000000..4e057dd753 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-browser.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = avatars.getBrowser( + code: 'aa', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-credit-card.md b/app/sdks/client-flutter/docs/examples/avatars/get-credit-card.md new file mode 100644 index 0000000000..76d8613c57 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = avatars.getCreditCard( + code: 'amex', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-favicon.md b/app/sdks/client-flutter/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..00ea1e9c68 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-favicon.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = avatars.getFavicon( + url: 'https://example.com', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-flag.md b/app/sdks/client-flutter/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..83d0ed3fb8 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-flag.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = avatars.getFlag( + code: 'af', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-image.md b/app/sdks/client-flutter/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..1b0542df8b --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-image.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = avatars.getImage( + url: 'https://example.com', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/avatars/get-q-r.md b/app/sdks/client-flutter/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..825bf00de5 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/avatars/get-q-r.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Avatars avatars = Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = avatars.getQR( + text: '[TEXT]', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/database/create-document.md b/app/sdks/client-flutter/docs/examples/database/create-document.md new file mode 100644 index 0000000000..9eea7b677c --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/database/create-document.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Database database = Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = database.createDocument( + collectionId: '[COLLECTION_ID]', + data: {}, + read: [], + write: [], +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/database/delete-document.md b/app/sdks/client-flutter/docs/examples/database/delete-document.md new file mode 100644 index 0000000000..5e41ff0a41 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/database/delete-document.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Database database = Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = database.deleteDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/database/get-document.md b/app/sdks/client-flutter/docs/examples/database/get-document.md new file mode 100644 index 0000000000..e410508fb1 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/database/get-document.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Database database = Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = database.getDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/database/list-documents.md b/app/sdks/client-flutter/docs/examples/database/list-documents.md new file mode 100644 index 0000000000..b4270d909b --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/database/list-documents.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Database database = Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = database.listDocuments( + collectionId: '[COLLECTION_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/database/update-document.md b/app/sdks/client-flutter/docs/examples/database/update-document.md new file mode 100644 index 0000000000..e9c584e066 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/database/update-document.md @@ -0,0 +1,24 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Database database = Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = database.updateDocument( + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + data: {}, + read: [], + write: [], +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get-continents.md b/app/sdks/client-flutter/docs/examples/locale/get-continents.md new file mode 100644 index 0000000000..743635f053 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get-continents.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.getContinents(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get-countries-e-u.md b/app/sdks/client-flutter/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 0000000000..c46b95ec07 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.getCountriesEU(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get-countries-phones.md b/app/sdks/client-flutter/docs/examples/locale/get-countries-phones.md new file mode 100644 index 0000000000..a406f184f9 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.getCountriesPhones(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get-countries.md b/app/sdks/client-flutter/docs/examples/locale/get-countries.md new file mode 100644 index 0000000000..c83c02b60c --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get-countries.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.getCountries(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get-currencies.md b/app/sdks/client-flutter/docs/examples/locale/get-currencies.md new file mode 100644 index 0000000000..b34f4c7162 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get-currencies.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.getCurrencies(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/locale/get.md b/app/sdks/client-flutter/docs/examples/locale/get.md new file mode 100644 index 0000000000..fed81b836e --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/locale/get.md @@ -0,0 +1,18 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Locale locale = Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = locale.get(); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/storage/create-file.md b/app/sdks/client-flutter/docs/examples/storage/create-file.md new file mode 100644 index 0000000000..b7ee0857ae --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/create-file.md @@ -0,0 +1,23 @@ +import 'dart:io'; +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = storage.createFile( + file: await MultipartFile.fromFile('./path-to-files/image.jpg', 'image.jpg'), + read: [], + write: [], +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/storage/delete-file.md b/app/sdks/client-flutter/docs/examples/storage/delete-file.md new file mode 100644 index 0000000000..9a2ed98b96 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/delete-file.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = storage.deleteFile( + fileId: '[FILE_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/storage/get-file-download.md b/app/sdks/client-flutter/docs/examples/storage/get-file-download.md new file mode 100644 index 0000000000..e00cdc9022 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/get-file-download.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = storage.getFileDownload( + fileId: '[FILE_ID]', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/storage/get-file-preview.md b/app/sdks/client-flutter/docs/examples/storage/get-file-preview.md new file mode 100644 index 0000000000..5297ab8342 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/get-file-preview.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = storage.getFilePreview( + fileId: '[FILE_ID]', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/storage/get-file-view.md b/app/sdks/client-flutter/docs/examples/storage/get-file-view.md new file mode 100644 index 0000000000..13b1de4822 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/get-file-view.md @@ -0,0 +1,15 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +String result = storage.getFileView( + fileId: '[FILE_ID]', +); + +print(result); // Resource URL string diff --git a/app/sdks/client-flutter/docs/examples/storage/get-file.md b/app/sdks/client-flutter/docs/examples/storage/get-file.md new file mode 100644 index 0000000000..bdeaf55130 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/get-file.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = storage.getFile( + fileId: '[FILE_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/storage/list-files.md b/app/sdks/client-flutter/docs/examples/storage/list-files.md new file mode 100644 index 0000000000..9ef25d8a01 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/list-files.md @@ -0,0 +1,19 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = storage.listFiles( +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/storage/update-file.md b/app/sdks/client-flutter/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..44955c224f --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/storage/update-file.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Storage storage = Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = storage.updateFile( + fileId: '[FILE_ID]', + read: [], + write: [], +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/create-membership.md b/app/sdks/client-flutter/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..b06200f66d --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/create-membership.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.createMembership( + teamId: '[TEAM_ID]', + email: 'email@example.com', + roles: [], + url: 'https://example.com', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/create.md b/app/sdks/client-flutter/docs/examples/teams/create.md new file mode 100644 index 0000000000..71bb6219a2 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/create.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.create( + name: '[NAME]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/delete-membership.md b/app/sdks/client-flutter/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..4baddf5f9d --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/delete-membership.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.deleteMembership( + teamId: '[TEAM_ID]', + inviteId: '[INVITE_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/delete.md b/app/sdks/client-flutter/docs/examples/teams/delete.md new file mode 100644 index 0000000000..c88521f2a2 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/delete.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.delete( + teamId: '[TEAM_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/get-memberships.md b/app/sdks/client-flutter/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..27e0971de7 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/get-memberships.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.getMemberships( + teamId: '[TEAM_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/get.md b/app/sdks/client-flutter/docs/examples/teams/get.md new file mode 100644 index 0000000000..ef9c01002c --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/get.md @@ -0,0 +1,20 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.get( + teamId: '[TEAM_ID]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/list.md b/app/sdks/client-flutter/docs/examples/teams/list.md new file mode 100644 index 0000000000..a9e4313b83 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/list.md @@ -0,0 +1,19 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.list( +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/update-membership-status.md b/app/sdks/client-flutter/docs/examples/teams/update-membership-status.md new file mode 100644 index 0000000000..a33ecd4c18 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/update-membership-status.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.updateMembershipStatus( + teamId: '[TEAM_ID]', + inviteId: '[INVITE_ID]', + userId: '[USER_ID]', + secret: '[SECRET]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/docs/examples/teams/update.md b/app/sdks/client-flutter/docs/examples/teams/update.md new file mode 100644 index 0000000000..b1cc7e2391 --- /dev/null +++ b/app/sdks/client-flutter/docs/examples/teams/update.md @@ -0,0 +1,21 @@ +import 'package:appwrite/appwrite.dart'; + +// Init SDK +Client client = Client(); +Teams teams = Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID +; + +Future result = teams.update( + teamId: '[TEAM_ID]', + name: '[NAME]', +); + +result + .then((response) { + print(response); + }).catchError((error) { + print(error); + }); \ No newline at end of file diff --git a/app/sdks/client-flutter/example/README.md b/app/sdks/client-flutter/example/README.md new file mode 100644 index 0000000000..f6768a5f85 --- /dev/null +++ b/app/sdks/client-flutter/example/README.md @@ -0,0 +1,55 @@ +# Examples + +Init your Appwrite client: + +```dart + Client client = Client(); + + client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production + ; + +``` + +Create a new user and session: + +```dart +Account account = Account(client); + +Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name'); + +Response session = await account.createSession(email: 'me@appwrite.io', password: 'password'); + +``` + +Fetch user profile: + +```dart +Account account = Account(client); + +Response profile = await account.get(); +``` + +Upload File: + +```dart +Storage storage = Storage(client); + +MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg'); + +storage.createFile( + file: file, + read: ['*'], + write: [] +) +.then((response) { + print(response); // File uploaded! +}) +.catchError((error) { + print(error.response); +}); +``` + +All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/appwrite.dart b/app/sdks/client-flutter/lib/appwrite.dart similarity index 83% rename from app/sdks/flutter-dart/lib/appwrite.dart rename to app/sdks/client-flutter/lib/appwrite.dart index e6508e9077..95d0b72cfe 100644 --- a/app/sdks/flutter-dart/lib/appwrite.dart +++ b/app/sdks/client-flutter/lib/appwrite.dart @@ -1,9 +1,10 @@ +export 'package:dio/dio.dart' show Response; + +export 'client.dart'; +export 'enums.dart'; export 'services/account.dart'; export 'services/avatars.dart'; export 'services/database.dart'; export 'services/locale.dart'; export 'services/storage.dart'; export 'services/teams.dart'; -export 'client.dart'; -export 'enums.dart'; -export 'package:dio/dio.dart' show Response; \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/client.dart b/app/sdks/client-flutter/lib/client.dart new file mode 100644 index 0000000000..3798a0852e --- /dev/null +++ b/app/sdks/client-flutter/lib/client.dart @@ -0,0 +1,120 @@ +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:dio/adapter.dart'; +import 'package:dio_cookie_manager/dio_cookie_manager.dart'; +import 'package:cookie_jar/cookie_jar.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:package_info/package_info.dart'; + +import 'enums.dart'; + +class Client { + String endPoint; + String type = 'unknown'; + Map headers; + Map config; + bool selfSigned; + bool init = false; + Dio http; + PersistCookieJar cookieJar; + + Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() { + + type = (Platform.isIOS) ? 'ios' : type; + type = (Platform.isMacOS) ? 'macos' : type; + type = (Platform.isAndroid) ? 'android' : type; + type = (Platform.isLinux) ? 'linux' : type; + type = (Platform.isWindows) ? 'windows' : type; + type = (Platform.isFuchsia) ? 'fuchsia' : type; + + this.headers = { + 'content-type': 'application/json', + 'x-sdk-version': 'appwrite:dart:0.2.1', + }; + + this.config = {}; + + assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'"); + } + + Future _getCookiePath() async { + final directory = await getApplicationDocumentsDirectory(); + final path = directory.path; + final Directory dir = new Directory('$path/cookies'); + await dir.create(); + return dir; + } + + /// Your project ID + Client setProject(value) { + config['project'] = value; + addHeader('X-Appwrite-Project', value); + return this; + } + + Client setLocale(value) { + config['locale'] = value; + addHeader('X-Appwrite-Locale', value); + return this; + } + + Client setSelfSigned({bool status = true}) { + selfSigned = status; + return this; + } + + Client setEndpoint(String endPoint) { + this.endPoint = endPoint; + this.http.options.baseUrl = this.endPoint; + return this; + } + + Client addHeader(String key, String value) { + headers[key] = value; + + return this; + } + + Future call(HttpMethod method, {String path = '', Map headers = const {}, Map params = const {}}) async { + if(selfSigned) { + // Allow self signed requests + (http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { + client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; + return client; + }; + } + + if(!init) { + final Directory cookieDir = await _getCookiePath(); + + cookieJar = new PersistCookieJar(dir:cookieDir.path); + + this.http.options.baseUrl = this.endPoint; + this.http.options.validateStatus = (status) => status < 400; + this.http.interceptors.add(CookieManager(cookieJar)); + + PackageInfo packageInfo = await PackageInfo.fromPlatform(); + + addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName); + + init = true; + } + + // Origin is hardcoded for testing + Options options = Options( + headers: {...this.headers, ...headers}, + method: method.name(), + ); + + if(headers['content-type'] == 'multipart/form-data') { + return http.request(path, data: FormData.fromMap(params), options: options); + } + + if (method == HttpMethod.get) { + return http.get(path, queryParameters: params, options: options); + } else { + return http.request(path, data: params, options: options); + } + } +} \ No newline at end of file diff --git a/app/sdks/client-flutter/lib/enums.dart b/app/sdks/client-flutter/lib/enums.dart new file mode 100644 index 0000000000..2757f6073e --- /dev/null +++ b/app/sdks/client-flutter/lib/enums.dart @@ -0,0 +1,15 @@ +enum HttpMethod { get, post, put, delete, patch } + +extension HttpMethodString on HttpMethod { + String name() { + return this.toString().split('.').last.toUpperCase(); + } +} + +enum OrderType { asc, desc } + +extension OrderTypeString on OrderType { + String name() { + return this.toString().split('.').last.toUpperCase(); + } +} diff --git a/app/sdks/client-flutter/lib/service.dart b/app/sdks/client-flutter/lib/service.dart new file mode 100644 index 0000000000..1ae319b705 --- /dev/null +++ b/app/sdks/client-flutter/lib/service.dart @@ -0,0 +1,7 @@ +import 'client.dart'; + +class Service { + final Client client; + + const Service(this.client); +} diff --git a/app/sdks/flutter-dart/lib/services/account.dart b/app/sdks/client-flutter/lib/services/account.dart similarity index 61% rename from app/sdks/flutter-dart/lib/services/account.dart rename to app/sdks/client-flutter/lib/services/account.dart index 69b1aab4c7..b191791ab3 100644 --- a/app/sdks/flutter-dart/lib/services/account.dart +++ b/app/sdks/client-flutter/lib/services/account.dart @@ -1,31 +1,44 @@ +import 'dart:io'; + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; +import 'package:flutter_web_auth/flutter_web_auth.dart'; import "../client.dart"; import '../enums.dart'; import "../service.dart"; class Account extends Service { - Account(Client client): super(client); + /// Get Account + /// /// Get currently logged in user data as JSON object. + /// Future get() { final String path = '/account'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create Account + /// /// Use this endpoint to allow a new user to register a new account in your /// project. After the user registration completes successfully, you can use /// the [/account/verfication](/docs/account#createVerification) route to start /// verifying the user email address. To allow your new user to login to his /// new account, you need to create a new [account /// session](/docs/account#createSession). - Future create({@required String email, @required String password, String name = null}) { + /// + Future create({@required String email, @required String password, String name = ''}) { final String path = '/account'; final Map params = { @@ -34,25 +47,41 @@ class Account extends Service { 'name': name, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Delete Account + /// /// Delete a currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. This is done /// to avoid deleted accounts being overtaken by new users with the same email /// address. Any user-related resources like documents or storage files should /// be deleted separately. + /// Future delete() { final String path = '/account'; final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Update Account Email + /// /// Update currently logged in user account email address. After changing user /// address, user confirmation status is being reset and a new confirmation /// mail is sent. For security measures, user password is required to complete /// this request. + /// Future updateEmail({@required String email, @required String password}) { final String path = '/account/email'; @@ -61,19 +90,35 @@ class Account extends Service { 'password': password, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } + + /// Get Account Logs + /// /// Get currently logged in user list of latest security activity logs. Each /// log returns user IP address, location and date and time of log. + /// Future getLogs() { final String path = '/account/logs'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Update Account Name + /// /// Update currently logged in user account name. + /// Future updateName({@required String name}) { final String path = '/account/name'; @@ -81,31 +126,55 @@ class Account extends Service { 'name': name, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } + + /// Update Account Password + /// /// Update currently logged in user password. For validation, user is required /// to pass the password twice. + /// Future updatePassword({@required String password, @required String oldPassword}) { final String path = '/account/password'; final Map params = { 'password': password, - 'old-password': oldPassword, + 'oldPassword': oldPassword, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } + + /// Get Account Preferences + /// /// Get currently logged in user preferences as a key-value object. + /// Future getPrefs() { final String path = '/account/prefs'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Update Account Preferences + /// /// Update currently logged in user account preferences. You can pass only the /// specific settings you wish to update. + /// Future updatePrefs({@required dynamic prefs}) { final String path = '/account/prefs'; @@ -113,14 +182,22 @@ class Account extends Service { 'prefs': prefs, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } + + /// Create Password Recovery + /// /// Sends the user an email with a temporary secret key for password reset. /// When the user clicks the confirmation link he is redirected back to your /// app password reset URL with the secret key and email address values /// attached to the URL query string. Use the query string params to submit a /// request to the [PUT /account/recovery](/docs/account#updateRecovery) /// endpoint to complete the process. + /// Future createRecovery({@required String email, @required String url}) { final String path = '/account/recovery'; @@ -129,8 +206,15 @@ class Account extends Service { 'url': url, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Complete Password Recovery + /// /// Use this endpoint to complete the user account password reset. Both the /// **userId** and **secret** arguments will be passed as query parameters to /// the redirect URL you have provided when sending your request to the [POST @@ -140,30 +224,47 @@ class Account extends Service { /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({@required String userId, @required String secret, @required String passwordA, @required String passwordB}) { + /// + Future updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) { final String path = '/account/recovery'; final Map params = { 'userId': userId, 'secret': secret, - 'password-a': passwordA, - 'password-b': passwordB, + 'password': password, + 'passwordAgain': passwordAgain, }; - return this.client.call(HttpMethod.put, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); } + + /// Get Account Sessions + /// /// Get currently logged in user list of active sessions across different /// devices. + /// Future getSessions() { final String path = '/account/sessions'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create Account Session + /// /// Allow the user to login into his account by providing a valid email and /// password combination. This route will create a new session for the user. + /// Future createSession({@required String email, @required String password}) { final String path = '/account/sessions'; @@ -172,43 +273,86 @@ class Account extends Service { 'password': password, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Delete All Account Sessions + /// /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. + /// Future deleteSessions() { final String path = '/account/sessions'; final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Create Account Session with OAuth2 + /// /// Allow the user to login to his account using the OAuth2 provider of his /// choice. Each OAuth2 provider should be enabled from the Appwrite console /// first. Use the success and failure arguments to provide a redirect URL's /// back to your app when login is completed. - Future createOAuth2Session({@required String provider, @required String success, @required String failure}) { + /// + Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) { final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider); final Map params = { 'success': success, 'failure': failure, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return FlutterWebAuth.authenticate( + url: url.toString(), + callbackUrlScheme: "appwrite-callback-" + client.config['project'] + ).then((value) { + Uri url = Uri.parse(value); + List cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])]; + client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies); + }); } + + /// Delete Account Session + /// /// Use this endpoint to log out the currently logged in user from all his /// account sessions across all his different devices. When using the option id /// argument, only the session unique ID provider will be deleted. + /// Future deleteSession({@required String sessionId}) { final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId); final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Create Email Verification + /// /// Use this endpoint to send a verification message to your user email address /// to confirm they are the valid owners of that address. Both the **userId** /// and **secret** arguments will be passed as query parameters to the URL you @@ -222,6 +366,7 @@ class Account extends Service { /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. + /// Future createVerification({@required String url}) { final String path = '/account/verification'; @@ -229,12 +374,20 @@ class Account extends Service { 'url': url, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Complete Email Verification + /// /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. + /// Future updateVerification({@required String userId, @required String secret}) { final String path = '/account/verification'; @@ -243,6 +396,10 @@ class Account extends Service { 'secret': secret, }; - return this.client.call(HttpMethod.put, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/avatars.dart b/app/sdks/client-flutter/lib/services/avatars.dart similarity index 53% rename from app/sdks/flutter-dart/lib/services/avatars.dart rename to app/sdks/client-flutter/lib/services/avatars.dart index 420c19765c..2ce6ed2633 100644 --- a/app/sdks/flutter-dart/lib/services/avatars.dart +++ b/app/sdks/client-flutter/lib/services/avatars.dart @@ -1,4 +1,5 @@ + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -7,13 +8,15 @@ import '../enums.dart'; import "../service.dart"; class Avatars extends Service { - Avatars(Client client): super(client); + /// Get Browser Icon + /// /// You can use this endpoint to show different browser icons to your users. /// The code argument receives the browser code as it appears in your user /// /account/sessions endpoint. Use width, height and quality arguments to /// change the output settings. + /// Future getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) { final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code); @@ -23,66 +26,126 @@ class Avatars extends Service { 'quality': quality, }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Get Credit Card Icon + /// /// Need to display your users with your billing method or their payment /// methods? The credit card endpoint will return you the icon of the credit /// card provider you need. Use width, height and quality arguments to change /// the output settings. - Future getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) { + /// + String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) { final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code); final Map params = { 'width': width, 'height': height, 'quality': quality, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get Favicon + /// /// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote /// website URL. - Future getFavicon({@required String url}) { + /// + String getFavicon({@required String url}) { final String path = '/avatars/favicon'; final Map params = { 'url': url, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get Country Flag + /// /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, /// height and quality arguments to change the output settings. - Future getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) { + /// + String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) { final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code); final Map params = { 'width': width, 'height': height, 'quality': quality, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get Image from URL + /// /// Use this endpoint to fetch a remote image URL and crop it to any image size /// you want. This endpoint is very useful if you need to crop and display /// remote images in your app or in case you want to make sure a 3rd party /// image is properly served using a TLS protocol. - Future getImage({@required String url, int width = 400, int height = 400}) { + /// + String getImage({@required String url, int width = 400, int height = 400}) { final String path = '/avatars/image'; final Map params = { 'url': url, 'width': width, 'height': height, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get QR Code + /// /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. - Future getQR({@required String text, int size = 400, int margin = 1, int download = null}) { + /// + String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) { final String path = '/avatars/qr'; final Map params = { @@ -90,8 +153,17 @@ class Avatars extends Service { 'size': size, 'margin': margin, 'download': download, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/database.dart b/app/sdks/client-flutter/lib/services/database.dart similarity index 65% rename from app/sdks/flutter-dart/lib/services/database.dart rename to app/sdks/client-flutter/lib/services/database.dart index 5b9741553b..1163c9dbb5 100644 --- a/app/sdks/flutter-dart/lib/services/database.dart +++ b/app/sdks/client-flutter/lib/services/database.dart @@ -1,4 +1,5 @@ + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -7,32 +8,42 @@ import '../enums.dart'; import "../service.dart"; class Database extends Service { - Database(Client client): super(client); + /// List Documents + /// /// Get a list of all the user documents. You can use the query params to /// filter your results. On admin mode, this endpoint will return a list of all /// of the project documents. [Learn more about different API /// modes](/docs/admin). - Future listDocuments({@required String collectionId, List filters = const [], int offset = null, int limit = 50, String orderField = '\$id', String orderType = 'ASC', String orderCast = 'string', String search = null, int first = null, int last = null}) { + /// + Future listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = '', int first = 0, int last = 0}) { final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); final Map params = { 'filters': filters, 'offset': offset, 'limit': limit, - 'order-field': orderField, - 'order-type': orderType, - 'order-cast': orderCast, + 'orderField': orderField, + 'orderType': orderType.name(), + 'orderCast': orderCast, 'search': search, 'first': first, 'last': last, }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create Document + /// /// Create a new Document. - Future createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = null, String parentProperty = null, String parentPropertyType = 'assign'}) { + /// + Future createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) { final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId); final Map params = { @@ -44,18 +55,32 @@ class Database extends Service { 'parentPropertyType': parentPropertyType, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Get Document + /// /// Get document by its unique ID. This endpoint response returns a JSON object /// with the document data. + /// Future getDocument({@required String collectionId, @required String documentId}) { final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Update Document Future updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) { final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); @@ -65,17 +90,29 @@ class Database extends Service { 'write': write, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } + + /// Delete Document + /// /// Delete document by its unique ID. This endpoint deletes only the parent /// documents, his attributes and relations to other documents. Child documents /// **will not** be deleted. + /// Future deleteDocument({@required String collectionId, @required String documentId}) { final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId); final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/locale.dart b/app/sdks/client-flutter/lib/services/locale.dart similarity index 60% rename from app/sdks/flutter-dart/lib/services/locale.dart rename to app/sdks/client-flutter/lib/services/locale.dart index 5f08b93c2c..91ea1567ef 100644 --- a/app/sdks/flutter-dart/lib/services/locale.dart +++ b/app/sdks/client-flutter/lib/services/locale.dart @@ -1,4 +1,5 @@ + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -7,72 +8,118 @@ import '../enums.dart'; import "../service.dart"; class Locale extends Service { - Locale(Client client): super(client); + /// Get User Locale + /// /// Get the current user location based on IP. Returns an object with user /// country code, country name, continent name, continent code, ip address and /// suggested currency. You can use the locale header to get the data in a /// supported language. /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) + /// Future get() { final String path = '/locale'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// List Continents + /// /// List of all continents. You can use the locale header to get the data in a /// supported language. + /// Future getContinents() { final String path = '/locale/continents'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// List Countries + /// /// List of all countries. You can use the locale header to get the data in a /// supported language. + /// Future getCountries() { final String path = '/locale/countries'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// List EU Countries + /// /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. + /// Future getCountriesEU() { final String path = '/locale/countries/eu'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// List Countries Phone Codes + /// /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. + /// Future getCountriesPhones() { final String path = '/locale/countries/phones'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// List Currencies + /// /// List of all currencies, including currency symol, name, plural, and decimal /// digits for all major and minor currencies. You can use the locale header to /// get the data in a supported language. + /// Future getCurrencies() { final String path = '/locale/currencies'; final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/storage.dart b/app/sdks/client-flutter/lib/services/storage.dart similarity index 56% rename from app/sdks/flutter-dart/lib/services/storage.dart rename to app/sdks/client-flutter/lib/services/storage.dart index 041bb6576f..47497c7699 100644 --- a/app/sdks/flutter-dart/lib/services/storage.dart +++ b/app/sdks/client-flutter/lib/services/storage.dart @@ -1,4 +1,5 @@ + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -7,13 +8,15 @@ import '../enums.dart'; import "../service.dart"; class Storage extends Service { - Storage(Client client): super(client); + /// List Files + /// /// Get a list of all the user files. You can use the query params to filter /// your results. On admin mode, this endpoint will return a list of all of the /// project files. [Learn more about different API modes](/docs/admin). - Future listFiles({String search = null, int limit = 25, int offset = null, OrderType orderType = OrderType.asc}) { + /// + Future listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { final String path = '/storage/files'; final Map params = { @@ -23,12 +26,20 @@ class Storage extends Service { 'orderType': orderType.name(), }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create File + /// /// Create a new file. The user who creates the file will automatically be /// assigned to read and write access unless he has passed custom values for /// read and write arguments. - Future createFile({@required file, @required List read, @required List write}) { + /// + Future createFile({@required MultipartFile file, @required List read, @required List write}) { final String path = '/storage/files'; final Map params = { @@ -37,20 +48,36 @@ class Storage extends Service { 'write': write, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'multipart/form-data', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Get File + /// /// Get file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. + /// Future getFile({@required String fileId}) { final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Update File + /// /// Update file by its unique ID. Only users with write permissions have access /// to update this resource. + /// Future updateFile({@required String fileId, @required List read, @required List write}) { final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); @@ -59,34 +86,63 @@ class Storage extends Service { 'write': write, }; - return this.client.call(HttpMethod.put, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); } + + /// Delete File + /// /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. + /// Future deleteFile({@required String fileId}) { final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId); final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Get File for Download + /// /// Get file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - Future getFileDownload({@required String fileId}) { + /// + String getFileDownload({@required String fileId}) { final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId); final Map params = { + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get File Preview + /// /// Get a file preview image. Currently, this method supports preview for image /// files (jpg, png, and gif), other supported formats, like pdf, docs, slides, /// and spreadsheets, will return the file icon image. You can also pass query /// string arguments for cutting and resizing your preview image. - Future getFilePreview({@required String fileId, int width = null, int height = null, int quality = 100, String background = null, String output = null}) { + /// + String getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) { final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId); final Map params = { @@ -95,19 +151,41 @@ class Storage extends Service { 'quality': quality, 'background': background, 'output': output, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } + + /// Get File for View + /// /// Get file content by its unique ID. This endpoint is similar to the download /// method but returns with no 'Content-Disposition: attachment' header. - Future getFileView({@required String fileId, String as = null}) { + /// + String getFileView({@required String fileId, String as = ''}) { final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId); final Map params = { 'as': as, + 'project': client.config['project'], }; - return this.client.call(HttpMethod.get, path: path, params: params); + Uri endpoint = Uri.parse(client.endPoint); + Uri url = new Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + path, + queryParameters:params, + ); + + return url.toString(); } } \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/services/teams.dart b/app/sdks/client-flutter/lib/services/teams.dart similarity index 68% rename from app/sdks/flutter-dart/lib/services/teams.dart rename to app/sdks/client-flutter/lib/services/teams.dart index 483efd3b33..56e0731687 100644 --- a/app/sdks/flutter-dart/lib/services/teams.dart +++ b/app/sdks/client-flutter/lib/services/teams.dart @@ -1,4 +1,5 @@ + import 'package:dio/dio.dart'; import 'package:meta/meta.dart'; @@ -7,13 +8,15 @@ import '../enums.dart'; import "../service.dart"; class Teams extends Service { - Teams(Client client): super(client); + /// List Teams + /// /// Get a list of all the current user teams. You can use the query params to /// filter your results. On admin mode, this endpoint will return a list of all /// of the project teams. [Learn more about different API modes](/docs/admin). - Future list({String search = null, int limit = 25, int offset = null, OrderType orderType = OrderType.asc}) { + /// + Future list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) { final String path = '/teams'; final Map params = { @@ -23,12 +26,20 @@ class Teams extends Service { 'orderType': orderType.name(), }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create Team + /// /// Create a new team. The user who creates the team will automatically be /// assigned as the owner of the team. The team owner can invite new members, /// who will be able add new owners and update or delete the team from your /// project. + /// Future create({@required String name, List roles = const ["owner"]}) { final String path = '/teams'; @@ -37,20 +48,36 @@ class Teams extends Service { 'roles': roles, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Get Team + /// /// Get team by its unique ID. All team members have read access for this /// resource. + /// Future get({@required String teamId}) { final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Update Team + /// /// Update team by its unique ID. Only team owners have write access for this /// resource. + /// Future update({@required String teamId, @required String name}) { final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); @@ -58,28 +85,51 @@ class Teams extends Service { 'name': name, }; - return this.client.call(HttpMethod.put, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.put, path: path, params: params, headers: headers); } + + /// Delete Team + /// /// Delete team by its unique ID. Only team owners have write access for this /// resource. + /// Future delete({@required String teamId}) { final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId); final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Get Team Memberships + /// /// Get team members by the team unique ID. All team members have read access /// for this list of resources. + /// Future getMemberships({@required String teamId}) { final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); final Map params = { }; - return this.client.call(HttpMethod.get, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.get, path: path, params: params, headers: headers); } + + /// Create Team Membership + /// /// Use this endpoint to invite a new member to join your team. An email with a /// link to join the team will be sent to the new member email address if the /// member doesn't exist in the project it will be created automatically. @@ -93,7 +143,8 @@ class Teams extends Service { /// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URL's are the once from domains you have set when /// added your platforms in the console interface. - Future createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = null}) { + /// + Future createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = ''}) { final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId); final Map params = { @@ -103,22 +154,38 @@ class Teams extends Service { 'url': url, }; - return this.client.call(HttpMethod.post, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.post, path: path, params: params, headers: headers); } + + /// Delete Team Membership + /// /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if he didn't accept it. + /// Future deleteMembership({@required String teamId, @required String inviteId}) { final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); final Map params = { }; - return this.client.call(HttpMethod.delete, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.delete, path: path, params: params, headers: headers); } + + /// Update Team Membership Status + /// /// Use this endpoint to allow a user to accept an invitation to join a team /// after he is being redirected back to your app from the invitation email he /// was sent. + /// Future updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) { final String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId); @@ -127,6 +194,10 @@ class Teams extends Service { 'secret': secret, }; - return this.client.call(HttpMethod.patch, path: path, params: params); + final Map headers = { + 'content-type': 'application/json', + }; + + return client.call(HttpMethod.patch, path: path, params: params, headers: headers); } } \ No newline at end of file diff --git a/app/sdks/client-flutter/pubspec.yaml b/app/sdks/client-flutter/pubspec.yaml new file mode 100644 index 0000000000..27d0115d09 --- /dev/null +++ b/app/sdks/client-flutter/pubspec.yaml @@ -0,0 +1,38 @@ +name: appwrite +version: 0.2.1 +description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API +homepage: https://appwrite.io +repository: https://github.com/appwrite/sdk-for-flutter +issue_tracker: https://github.com/appwrite/sdk-generator/issues +documentation: https://appwrite.io/support +environment: + sdk: '>=2.6.0 <3.0.0' +dependencies: + meta: ^1.1.8 + path_provider: ^1.6.5 + package_info: ^0.4.0+16 + dio: ^3.0.0 + cookie_jar: ^1.0.0 + dio_cookie_manager: ^1.0.0 + flutter_web_auth: ^0.2.4 + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.2 + +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true \ No newline at end of file diff --git a/app/sdks/console-javascript/CHANGELOG.md b/app/sdks/client-web/CHANGELOG.md similarity index 100% rename from app/sdks/console-javascript/CHANGELOG.md rename to app/sdks/client-web/CHANGELOG.md diff --git a/app/sdks/flutter-dart/LICENSE b/app/sdks/client-web/LICENSE similarity index 100% rename from app/sdks/flutter-dart/LICENSE rename to app/sdks/client-web/LICENSE diff --git a/app/sdks/web-javascript/README.md b/app/sdks/client-web/README.md similarity index 61% rename from app/sdks/web-javascript/README.md rename to app/sdks/client-web/README.md index 84912efd24..837c7d6bc8 100644 --- a/app/sdks/web-javascript/README.md +++ b/app/sdks/client-web/README.md @@ -1,9 +1,11 @@ -# Appwrite SDK for JavaScript +# Appwrite Web SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://appwrite.io/images/github.png) @@ -31,21 +33,6 @@ To install with a CDN (content delivery network) add the following scripts to th ``` -## Getting Started - -Initialise the Appwrite SDK in your code, and setup your API credentials: - -```js - -// Init your JS SDK -var appwrite = new Appwrite(); - -appwrite - .setEndpoint('http://localhost/v1') // Set only when using self-hosted solution - .setProject('455x34dfkj') // Your Appwrite Project UID -; - -``` ## Contribution diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-image.md b/app/sdks/client-web/docs/examples/account/create-o-auth2session.md similarity index 78% rename from app/sdks/web-javascript/docs/examples/avatars/get-image.md rename to app/sdks/client-web/docs/examples/account/create-o-auth2session.md index 7f5468d4a9..611df2173d 100644 --- a/app/sdks/web-javascript/docs/examples/avatars/get-image.md +++ b/app/sdks/client-web/docs/examples/account/create-o-auth2session.md @@ -4,7 +4,7 @@ sdk .setProject('5df5acd0d48c2') // Your project ID ; -let promise = sdk.avatars.getImage('https://example.com'); +let promise = sdk.account.createOAuth2Session('bitbucket'); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/web-javascript/docs/examples/account/create-recovery.md b/app/sdks/client-web/docs/examples/account/create-recovery.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/create-recovery.md rename to app/sdks/client-web/docs/examples/account/create-recovery.md diff --git a/app/sdks/web-javascript/docs/examples/account/create-session.md b/app/sdks/client-web/docs/examples/account/create-session.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/create-session.md rename to app/sdks/client-web/docs/examples/account/create-session.md diff --git a/app/sdks/web-javascript/docs/examples/account/create-verification.md b/app/sdks/client-web/docs/examples/account/create-verification.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/create-verification.md rename to app/sdks/client-web/docs/examples/account/create-verification.md diff --git a/app/sdks/web-javascript/docs/examples/account/create.md b/app/sdks/client-web/docs/examples/account/create.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/create.md rename to app/sdks/client-web/docs/examples/account/create.md diff --git a/app/sdks/web-javascript/docs/examples/account/delete-session.md b/app/sdks/client-web/docs/examples/account/delete-session.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/delete-session.md rename to app/sdks/client-web/docs/examples/account/delete-session.md diff --git a/app/sdks/web-javascript/docs/examples/account/delete-sessions.md b/app/sdks/client-web/docs/examples/account/delete-sessions.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/delete-sessions.md rename to app/sdks/client-web/docs/examples/account/delete-sessions.md diff --git a/app/sdks/web-javascript/docs/examples/account/delete.md b/app/sdks/client-web/docs/examples/account/delete.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/delete.md rename to app/sdks/client-web/docs/examples/account/delete.md diff --git a/app/sdks/web-javascript/docs/examples/account/get-logs.md b/app/sdks/client-web/docs/examples/account/get-logs.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/get-logs.md rename to app/sdks/client-web/docs/examples/account/get-logs.md diff --git a/app/sdks/web-javascript/docs/examples/account/get-prefs.md b/app/sdks/client-web/docs/examples/account/get-prefs.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/get-prefs.md rename to app/sdks/client-web/docs/examples/account/get-prefs.md diff --git a/app/sdks/web-javascript/docs/examples/account/get-sessions.md b/app/sdks/client-web/docs/examples/account/get-sessions.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/get-sessions.md rename to app/sdks/client-web/docs/examples/account/get-sessions.md diff --git a/app/sdks/web-javascript/docs/examples/account/get.md b/app/sdks/client-web/docs/examples/account/get.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/get.md rename to app/sdks/client-web/docs/examples/account/get.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-email.md b/app/sdks/client-web/docs/examples/account/update-email.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-email.md rename to app/sdks/client-web/docs/examples/account/update-email.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-name.md b/app/sdks/client-web/docs/examples/account/update-name.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-name.md rename to app/sdks/client-web/docs/examples/account/update-name.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-password.md b/app/sdks/client-web/docs/examples/account/update-password.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-password.md rename to app/sdks/client-web/docs/examples/account/update-password.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-prefs.md b/app/sdks/client-web/docs/examples/account/update-prefs.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-prefs.md rename to app/sdks/client-web/docs/examples/account/update-prefs.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-recovery.md b/app/sdks/client-web/docs/examples/account/update-recovery.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-recovery.md rename to app/sdks/client-web/docs/examples/account/update-recovery.md diff --git a/app/sdks/web-javascript/docs/examples/account/update-verification.md b/app/sdks/client-web/docs/examples/account/update-verification.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/account/update-verification.md rename to app/sdks/client-web/docs/examples/account/update-verification.md diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-browser.md b/app/sdks/client-web/docs/examples/avatars/get-browser.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/avatars/get-browser.md rename to app/sdks/client-web/docs/examples/avatars/get-browser.md diff --git a/app/sdks/web-javascript/docs/examples/account/create-o-auth2session.md b/app/sdks/client-web/docs/examples/avatars/get-credit-card.md similarity index 54% rename from app/sdks/web-javascript/docs/examples/account/create-o-auth2session.md rename to app/sdks/client-web/docs/examples/avatars/get-credit-card.md index ee4b20402d..7b1f980ebc 100644 --- a/app/sdks/web-javascript/docs/examples/account/create-o-auth2session.md +++ b/app/sdks/client-web/docs/examples/avatars/get-credit-card.md @@ -4,6 +4,6 @@ sdk .setProject('5df5acd0d48c2') // Your project ID ; -let result = sdk.account.createOAuth2Session('bitbucket', 'https://example.com', 'https://example.com'); +let result = sdk.avatars.getCreditCard('amex'); console.log(result); // Resource URL diff --git a/app/sdks/client-web/docs/examples/avatars/get-favicon.md b/app/sdks/client-web/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..ce04d0bab7 --- /dev/null +++ b/app/sdks/client-web/docs/examples/avatars/get-favicon.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.avatars.getFavicon('https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/client-web/docs/examples/avatars/get-flag.md b/app/sdks/client-web/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..71c3db8765 --- /dev/null +++ b/app/sdks/client-web/docs/examples/avatars/get-flag.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.avatars.getFlag('af'); + +console.log(result); // Resource URL diff --git a/app/sdks/client-web/docs/examples/avatars/get-image.md b/app/sdks/client-web/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..2c2b80a8e4 --- /dev/null +++ b/app/sdks/client-web/docs/examples/avatars/get-image.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.avatars.getImage('https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/client-web/docs/examples/avatars/get-q-r.md b/app/sdks/client-web/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..cbd0dc8c45 --- /dev/null +++ b/app/sdks/client-web/docs/examples/avatars/get-q-r.md @@ -0,0 +1,9 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID +; + +let result = sdk.avatars.getQR('[TEXT]'); + +console.log(result); // Resource URL diff --git a/app/sdks/web-javascript/docs/examples/database/create-document.md b/app/sdks/client-web/docs/examples/database/create-document.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/database/create-document.md rename to app/sdks/client-web/docs/examples/database/create-document.md diff --git a/app/sdks/web-javascript/docs/examples/database/delete-document.md b/app/sdks/client-web/docs/examples/database/delete-document.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/database/delete-document.md rename to app/sdks/client-web/docs/examples/database/delete-document.md diff --git a/app/sdks/web-javascript/docs/examples/database/get-document.md b/app/sdks/client-web/docs/examples/database/get-document.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/database/get-document.md rename to app/sdks/client-web/docs/examples/database/get-document.md diff --git a/app/sdks/web-javascript/docs/examples/database/list-documents.md b/app/sdks/client-web/docs/examples/database/list-documents.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/database/list-documents.md rename to app/sdks/client-web/docs/examples/database/list-documents.md diff --git a/app/sdks/web-javascript/docs/examples/database/update-document.md b/app/sdks/client-web/docs/examples/database/update-document.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/database/update-document.md rename to app/sdks/client-web/docs/examples/database/update-document.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get-continents.md b/app/sdks/client-web/docs/examples/locale/get-continents.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get-continents.md rename to app/sdks/client-web/docs/examples/locale/get-continents.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get-countries-e-u.md b/app/sdks/client-web/docs/examples/locale/get-countries-e-u.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get-countries-e-u.md rename to app/sdks/client-web/docs/examples/locale/get-countries-e-u.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get-countries-phones.md b/app/sdks/client-web/docs/examples/locale/get-countries-phones.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get-countries-phones.md rename to app/sdks/client-web/docs/examples/locale/get-countries-phones.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get-countries.md b/app/sdks/client-web/docs/examples/locale/get-countries.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get-countries.md rename to app/sdks/client-web/docs/examples/locale/get-countries.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get-currencies.md b/app/sdks/client-web/docs/examples/locale/get-currencies.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get-currencies.md rename to app/sdks/client-web/docs/examples/locale/get-currencies.md diff --git a/app/sdks/web-javascript/docs/examples/locale/get.md b/app/sdks/client-web/docs/examples/locale/get.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/locale/get.md rename to app/sdks/client-web/docs/examples/locale/get.md diff --git a/app/sdks/web-javascript/docs/examples/storage/create-file.md b/app/sdks/client-web/docs/examples/storage/create-file.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/create-file.md rename to app/sdks/client-web/docs/examples/storage/create-file.md diff --git a/app/sdks/web-javascript/docs/examples/storage/delete-file.md b/app/sdks/client-web/docs/examples/storage/delete-file.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/delete-file.md rename to app/sdks/client-web/docs/examples/storage/delete-file.md diff --git a/app/sdks/web-javascript/docs/examples/storage/get-file-download.md b/app/sdks/client-web/docs/examples/storage/get-file-download.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/get-file-download.md rename to app/sdks/client-web/docs/examples/storage/get-file-download.md diff --git a/app/sdks/web-javascript/docs/examples/storage/get-file-preview.md b/app/sdks/client-web/docs/examples/storage/get-file-preview.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/get-file-preview.md rename to app/sdks/client-web/docs/examples/storage/get-file-preview.md diff --git a/app/sdks/web-javascript/docs/examples/storage/get-file-view.md b/app/sdks/client-web/docs/examples/storage/get-file-view.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/get-file-view.md rename to app/sdks/client-web/docs/examples/storage/get-file-view.md diff --git a/app/sdks/web-javascript/docs/examples/storage/get-file.md b/app/sdks/client-web/docs/examples/storage/get-file.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/get-file.md rename to app/sdks/client-web/docs/examples/storage/get-file.md diff --git a/app/sdks/web-javascript/docs/examples/storage/list-files.md b/app/sdks/client-web/docs/examples/storage/list-files.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/list-files.md rename to app/sdks/client-web/docs/examples/storage/list-files.md diff --git a/app/sdks/web-javascript/docs/examples/storage/update-file.md b/app/sdks/client-web/docs/examples/storage/update-file.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/storage/update-file.md rename to app/sdks/client-web/docs/examples/storage/update-file.md diff --git a/app/sdks/web-javascript/docs/examples/teams/create-membership.md b/app/sdks/client-web/docs/examples/teams/create-membership.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/create-membership.md rename to app/sdks/client-web/docs/examples/teams/create-membership.md diff --git a/app/sdks/web-javascript/docs/examples/teams/create.md b/app/sdks/client-web/docs/examples/teams/create.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/create.md rename to app/sdks/client-web/docs/examples/teams/create.md diff --git a/app/sdks/web-javascript/docs/examples/teams/delete-membership.md b/app/sdks/client-web/docs/examples/teams/delete-membership.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/delete-membership.md rename to app/sdks/client-web/docs/examples/teams/delete-membership.md diff --git a/app/sdks/web-javascript/docs/examples/teams/delete.md b/app/sdks/client-web/docs/examples/teams/delete.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/delete.md rename to app/sdks/client-web/docs/examples/teams/delete.md diff --git a/app/sdks/web-javascript/docs/examples/teams/get-memberships.md b/app/sdks/client-web/docs/examples/teams/get-memberships.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/get-memberships.md rename to app/sdks/client-web/docs/examples/teams/get-memberships.md diff --git a/app/sdks/web-javascript/docs/examples/teams/get.md b/app/sdks/client-web/docs/examples/teams/get.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/get.md rename to app/sdks/client-web/docs/examples/teams/get.md diff --git a/app/sdks/web-javascript/docs/examples/teams/list.md b/app/sdks/client-web/docs/examples/teams/list.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/list.md rename to app/sdks/client-web/docs/examples/teams/list.md diff --git a/app/sdks/web-javascript/docs/examples/teams/update-membership-status.md b/app/sdks/client-web/docs/examples/teams/update-membership-status.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/update-membership-status.md rename to app/sdks/client-web/docs/examples/teams/update-membership-status.md diff --git a/app/sdks/web-javascript/docs/examples/teams/update.md b/app/sdks/client-web/docs/examples/teams/update.md similarity index 100% rename from app/sdks/web-javascript/docs/examples/teams/update.md rename to app/sdks/client-web/docs/examples/teams/update.md diff --git a/app/sdks/client-web/package.json b/app/sdks/client-web/package.json new file mode 100644 index 0000000000..c28785e89f --- /dev/null +++ b/app/sdks/client-web/package.json @@ -0,0 +1,17 @@ +{ + "name": "appwrite", + "homepage": "https://appwrite.io/support", + "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", + "version": "1.0.29", + "license": "BSD-3-Clause", + "main": "src/sdk.js", + "types": "types/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/appwrite/sdk-for-js" + }, + "devDependencies": { + "typescript": "^3.6.4" + }, + "dependencies": {} +} \ No newline at end of file diff --git a/app/sdks/web-javascript/src/sdk.js b/app/sdks/client-web/src/sdk.js similarity index 94% rename from app/sdks/web-javascript/src/sdk.js rename to app/sdks/client-web/src/sdk.js index 99726f5958..f962eaf10a 100644 --- a/app/sdks/web-javascript/src/sdk.js +++ b/app/sdks/client-web/src/sdk.js @@ -7,9 +7,7 @@ let config = { endpoint: 'https://appwrite.io/v1', project: '', - key: '', locale: '', - mode: '', }; /** @@ -40,24 +38,6 @@ return this; }; - /** - * Set Key - * - * Your secret API key - * - * @param value string - * - * @return this - */ - let setKey = function (value) - { - http.addGlobalHeader('X-Appwrite-Key', value); - - config.key = value; - - return this; - }; - /** * Set Locale * @@ -74,22 +54,6 @@ return this; }; - /** - * Set Mode - * - * @param value string - * - * @return this - */ - let setMode = function (value) - { - http.addGlobalHeader('X-Appwrite-Mode', value); - - config.mode = value; - - return this; - }; - let http = function(document) { let globalParams = [], globalHeaders = []; @@ -286,28 +250,6 @@ } }(window.document); - let iframe = function(method, url, params) { - let form = document.createElement('form'); - - form.setAttribute('method', method); - form.setAttribute('action', config.endpoint + url); - - for(let key in params) { - if(params.hasOwnProperty(key)) { - let hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", key); - hiddenField.setAttribute("value", params[key]); - - form.appendChild(hiddenField); - } - } - - document.body.appendChild(form); - - return form.submit(); - }; - let account = { /** @@ -516,7 +458,7 @@ } if(oldPassword) { - payload['old-password'] = oldPassword; + payload['oldPassword'] = oldPassword; } return http @@ -630,12 +572,12 @@ * * @param {string} userId * @param {string} secret - * @param {string} passwordA - * @param {string} passwordB + * @param {string} password + * @param {string} passwordAgain * @throws {Error} * @return {Promise} */ - updateRecovery: function(userId, secret, passwordA, passwordB) { + updateRecovery: function(userId, secret, password, passwordAgain) { if(userId === undefined) { throw new Error('Missing required parameter: "userId"'); } @@ -644,12 +586,12 @@ throw new Error('Missing required parameter: "secret"'); } - if(passwordA === undefined) { - throw new Error('Missing required parameter: "passwordA"'); + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); } - if(passwordB === undefined) { - throw new Error('Missing required parameter: "passwordB"'); + if(passwordAgain === undefined) { + throw new Error('Missing required parameter: "passwordAgain"'); } let path = '/account/recovery'; @@ -664,12 +606,12 @@ payload['secret'] = secret; } - if(passwordA) { - payload['password-a'] = passwordA; + if(password) { + payload['password'] = password; } - if(passwordB) { - payload['password-b'] = passwordB; + if(passwordAgain) { + payload['passwordAgain'] = passwordAgain; } return http @@ -768,21 +710,13 @@ * @param {string} success * @param {string} failure * @throws {Error} - * @return {string} + * @return {Promise} */ - createOAuth2Session: function(provider, success, failure) { + createOAuth2Session: function(provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure') { if(provider === undefined) { throw new Error('Missing required parameter: "provider"'); } - if(success === undefined) { - throw new Error('Missing required parameter: "success"'); - } - - if(failure === undefined) { - throw new Error('Missing required parameter: "failure"'); - } - let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); let payload = {}; @@ -798,8 +732,8 @@ payload['project'] = config.project; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - - return config.endpoint + path + ((query) ? '?' + query : ''); + + window.location = config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -966,7 +900,7 @@ * @param {number} height * @param {number} quality * @throws {Error} - * @return {Promise} + * @return {string} */ getCreditCard: function(code, width = 100, height = 100, quality = 100) { if(code === undefined) { @@ -989,10 +923,11 @@ payload['quality'] = quality; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1003,7 +938,7 @@ * * @param {string} url * @throws {Error} - * @return {Promise} + * @return {string} */ getFavicon: function(url) { if(url === undefined) { @@ -1018,10 +953,11 @@ payload['url'] = url; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1036,7 +972,7 @@ * @param {number} height * @param {number} quality * @throws {Error} - * @return {Promise} + * @return {string} */ getFlag: function(code, width = 100, height = 100, quality = 100) { if(code === undefined) { @@ -1059,10 +995,11 @@ payload['quality'] = quality; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1077,7 +1014,7 @@ * @param {number} width * @param {number} height * @throws {Error} - * @return {Promise} + * @return {string} */ getImage: function(url, width = 400, height = 400) { if(url === undefined) { @@ -1100,10 +1037,11 @@ payload['height'] = height; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1117,7 +1055,7 @@ * @param {number} margin * @param {number} download * @throws {Error} - * @return {Promise} + * @return {string} */ getQR: function(text, size = 400, margin = 1, download = 0) { if(text === undefined) { @@ -1144,10 +1082,11 @@ payload['download'] = download; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); } }; @@ -1162,7 +1101,7 @@ * modes](/docs/admin). * * @param {string} collectionId - * @param {array} filters + * @param {string[]} filters * @param {number} offset * @param {number} limit * @param {string} orderField @@ -1196,15 +1135,15 @@ } if(orderField) { - payload['order-field'] = orderField; + payload['orderField'] = orderField; } if(orderType) { - payload['order-type'] = orderType; + payload['orderType'] = orderType; } if(orderCast) { - payload['order-cast'] = orderCast; + payload['orderCast'] = orderCast; } if(search) { @@ -1232,8 +1171,8 @@ * * @param {string} collectionId * @param {object} data - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @param {string} parentDocument * @param {string} parentProperty * @param {string} parentPropertyType @@ -1328,8 +1267,8 @@ * @param {string} collectionId * @param {string} documentId * @param {object} data - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -1435,7 +1374,7 @@ }, /** - * List Countries + * List Continents * * List of all continents. You can use the locale header to get the data in a * supported language. @@ -1587,8 +1526,8 @@ * read and write arguments. * * @param {File} file - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -1659,8 +1598,8 @@ * to update this resource. * * @param {string} fileId - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -1743,7 +1682,7 @@ payload['project'] = config.project; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); }, @@ -1796,7 +1735,7 @@ payload['project'] = config.project; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); }, @@ -1827,7 +1766,7 @@ payload['project'] = config.project; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); } }; @@ -1884,7 +1823,7 @@ * project. * * @param {string} name - * @param {array} roles + * @param {string[]} roles * @throws {Error} * @return {Promise} */ @@ -2039,7 +1978,7 @@ * * @param {string} teamId * @param {string} email - * @param {array} roles + * @param {string[]} roles * @param {string} url * @param {string} name * @throws {Error} @@ -2172,9 +2111,7 @@ return { setEndpoint: setEndpoint, setProject: setProject, - setKey: setKey, setLocale: setLocale, - setMode: setMode, account: account, avatars: avatars, database: database, diff --git a/app/sdks/web-javascript/src/sdk.min.js b/app/sdks/client-web/src/sdk.min.js similarity index 81% rename from app/sdks/web-javascript/src/sdk.min.js rename to app/sdks/client-web/src/sdk.min.js index 338db55e7c..20feba31d9 100644 --- a/app/sdks/web-javascript/src/sdk.min.js +++ b/app/sdks/client-web/src/sdk.min.js @@ -1,4 +1,4 @@ -(function(window){'use strict';window.Appwrite=function(){let config={endpoint:'https://appwrite.io/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;index=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type')||'';contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case 'application/json':data=JSON.parse(data);break} let cookieFallback=this.getResponseHeader('X-Fallback-Cookies')||'';if(window.localStorage&&cookieFallback){window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');window.localStorage.setItem('cookieFallback',cookieFallback)} resolve(data)}else{reject(new Error(request.statusText))}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} -request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let iframe=function(method,url,params){let form=document.createElement('form');form.setAttribute('method',method);form.setAttribute('action',config.endpoint+url);for(let key in params){if(params.hasOwnProperty(key)){let hiddenField=document.createElement("input");hiddenField.setAttribute("type","hidden");hiddenField.setAttribute("name",key);hiddenField.setAttribute("value",params[key]);form.appendChild(hiddenField)}} -document.body.appendChild(form);return form.submit()};let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} +request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account';let payload={};if(email){payload.email=email} if(password){payload.password=password} @@ -27,31 +26,29 @@ let path='/account/name';let payload={};if(name){payload.name=name} return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} let path='/account/password';let payload={};if(password){payload.password=password} -if(oldPassword){payload['old-password']=oldPassword} +if(oldPassword){payload.oldPassword=oldPassword} return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} return http.patch(path,{'content-type':'application/json',},payload)},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/account/recovery';let payload={};if(email){payload.email=email} if(url){payload.url=url} -return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} if(secret===undefined){throw new Error('Missing required parameter: "secret"')} -if(passwordA===undefined){throw new Error('Missing required parameter: "passwordA"')} -if(passwordB===undefined){throw new Error('Missing required parameter: "passwordB"')} +if(password===undefined){throw new Error('Missing required parameter: "password"')} +if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"')} let path='/account/recovery';let payload={};if(userId){payload.userId=userId} if(secret){payload.secret=secret} -if(passwordA){payload['password-a']=passwordA} -if(passwordB){payload['password-b']=passwordB} +if(password){payload.password=password} +if(passwordAgain){payload.passwordAgain=passwordAgain} return http.put(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account/sessions';let payload={};if(email){payload.email=email} if(password){payload.password=password} -return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -if(success===undefined){throw new Error('Missing required parameter: "success"')} -if(failure===undefined){throw new Error('Missing required parameter: "failure"')} +return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} if(failure){payload.failure=failure} -payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} let path='/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createVerification:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/account/verification';let payload={};if(url){payload.url=url} return http.post(path,{'content-type':'application/json',},payload)},updateVerification:function(userId,secret){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} @@ -66,28 +63,28 @@ return http.get(path,{'content-type':'application/json',},payload)},getCreditCar let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} if(height){payload.height=height} if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/avatars/favicon';let payload={};if(url){payload.url=url} -return http.get(path,{'content-type':'application/json',},payload)},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} if(height){payload.height=height} if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/avatars/image';let payload={};if(url){payload.url=url} if(width){payload.width=width} if(height){payload.height=height} -return http.get(path,{'content-type':'application/json',},payload)},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')} let path='/avatars/qr';let payload={};if(text){payload.text=text} if(size){payload.size=size} if(margin){payload.margin=margin} if(download){payload.download=download} -return http.get(path,{'content-type':'application/json',},payload)}};let database={listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$id',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} +payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')}};let database={listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$id',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload.filters=filters} if(offset){payload.offset=offset} if(limit){payload.limit=limit} -if(orderField){payload['order-field']=orderField} -if(orderType){payload['order-type']=orderType} -if(orderCast){payload['order-cast']=orderCast} +if(orderField){payload.orderField=orderField} +if(orderType){payload.orderType=orderType} +if(orderCast){payload.orderCast=orderCast} if(search){payload.search=search} if(first){payload.first=first} if(last){payload.last=last} @@ -168,4 +165,4 @@ if(userId===undefined){throw new Error('Missing required parameter: "userId"')} if(secret===undefined){throw new Error('Missing required parameter: "secret"')} let path='/teams/{teamId}/memberships/{inviteId}/status'.replace(new RegExp('{teamId}','g'),teamId).replace(new RegExp('{inviteId}','g'),inviteId);let payload={};if(userId){payload.userId=userId} if(secret){payload.secret=secret} -return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,locale:locale,storage:storage,teams:teams}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file +return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setLocale:setLocale,account:account,avatars:avatars,database:database,locale:locale,storage:storage,teams:teams}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file diff --git a/app/sdks/client-web/tsconfig.json b/app/sdks/client-web/tsconfig.json new file mode 100644 index 0000000000..1e668ca62c --- /dev/null +++ b/app/sdks/client-web/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "ES6", + "lib": ["ES2015", "ES6", "dom"], + "module": "commonjs", + "sourceMap": true + } +} \ No newline at end of file diff --git a/app/sdks/client-web/types/index.d.ts b/app/sdks/client-web/types/index.d.ts new file mode 100644 index 0000000000..4b587e3920 --- /dev/null +++ b/app/sdks/client-web/types/index.d.ts @@ -0,0 +1,826 @@ +// Type definitions for appwrite 1.0.29 +// Project: Appwrite + + +/*~ This declaration specifies that the class constructor function + *~ is the exported object from the file + */ +export = Appwrite; + +/*~ Write your module's methods and properties in this class */ +declare class Appwrite { + constructor(); + + /** + * @param {string} endpoint + * @returns {this} + */ + setEndpoint(endpoint: string): this; + + /** + * Set Project + * + * Your project ID + * + * @param value string + * + * @return this + */ + setProject(project: string): this; + /** + * Set Locale + * + * @param value string + * + * @return this + */ + setLocale(locale: string): this; + + account:Appwrite.Account; + avatars:Appwrite.Avatars; + database:Appwrite.Database; + locale:Appwrite.Locale; + storage:Appwrite.Storage; + teams:Appwrite.Teams; + +} + +declare namespace Appwrite { + + export interface Account { + + /** + * Get Account + * + * Get currently logged in user data as JSON object. + * + * @throws {Error} + * @return {Promise} + */ + get(): Promise; + + /** + * Create Account + * + * Use this endpoint to allow a new user to register a new account in your + * project. After the user registration completes successfully, you can use + * the [/account/verfication](/docs/account#createVerification) route to start + * verifying the user email address. To allow your new user to login to his + * new account, you need to create a new [account + * session](/docs/account#createSession). + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + create(email: string, password: string, name: string): Promise; + + /** + * Delete Account + * + * Delete a currently logged in user account. Behind the scene, the user + * record is not deleted but permanently blocked from any access. This is done + * to avoid deleted accounts being overtaken by new users with the same email + * address. Any user-related resources like documents or storage files should + * be deleted separately. + * + * @throws {Error} + * @return {Promise} + */ + delete(): Promise; + + /** + * Update Account Email + * + * Update currently logged in user account email address. After changing user + * address, user confirmation status is being reset and a new confirmation + * mail is sent. For security measures, user password is required to complete + * this request. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + updateEmail(email: string, password: string): Promise; + + /** + * Get Account Logs + * + * Get currently logged in user list of latest security activity logs. Each + * log returns user IP address, location and date and time of log. + * + * @throws {Error} + * @return {Promise} + */ + getLogs(): Promise; + + /** + * Update Account Name + * + * Update currently logged in user account name. + * + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + updateName(name: string): Promise; + + /** + * Update Account Password + * + * Update currently logged in user password. For validation, user is required + * to pass the password twice. + * + * @param {string} password + * @param {string} oldPassword + * @throws {Error} + * @return {Promise} + */ + updatePassword(password: string, oldPassword: string): Promise; + + /** + * Get Account Preferences + * + * Get currently logged in user preferences as a key-value object. + * + * @throws {Error} + * @return {Promise} + */ + getPrefs(): Promise; + + /** + * Update Account Preferences + * + * Update currently logged in user account preferences. You can pass only the + * specific settings you wish to update. + * + * @param {object} prefs + * @throws {Error} + * @return {Promise} + */ + updatePrefs(prefs: object): Promise; + + /** + * Create Password Recovery + * + * Sends the user an email with a temporary secret key for password reset. + * When the user clicks the confirmation link he is redirected back to your + * app password reset URL with the secret key and email address values + * attached to the URL query string. Use the query string params to submit a + * request to the [PUT /account/recovery](/docs/account#updateRecovery) + * endpoint to complete the process. + * + * @param {string} email + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createRecovery(email: string, url: string): Promise; + + /** + * Complete Password Recovery + * + * Use this endpoint to complete the user account password reset. Both the + * **userId** and **secret** arguments will be passed as query parameters to + * the redirect URL you have provided when sending your request to the [POST + * /account/recovery](/docs/account#createRecovery) endpoint. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} userId + * @param {string} secret + * @param {string} password + * @param {string} passwordAgain + * @throws {Error} + * @return {Promise} + */ + updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise; + + /** + * Get Account Sessions + * + * Get currently logged in user list of active sessions across different + * devices. + * + * @throws {Error} + * @return {Promise} + */ + getSessions(): Promise; + + /** + * Create Account Session + * + * Allow the user to login into his account by providing a valid email and + * password combination. This route will create a new session for the user. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + createSession(email: string, password: string): Promise; + + /** + * Delete All Account Sessions + * + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. + * + * @throws {Error} + * @return {Promise} + */ + deleteSessions(): Promise; + + /** + * Create Account Session with OAuth2 + * + * Allow the user to login to his account using the OAuth2 provider of his + * choice. Each OAuth2 provider should be enabled from the Appwrite console + * first. Use the success and failure arguments to provide a redirect URL's + * back to your app when login is completed. + * + * @param {string} provider + * @param {string} success + * @param {string} failure + * @throws {Error} + * @return {Promise} + */ + createOAuth2Session(provider: string, success: string, failure: string): Promise; + + /** + * Delete Account Session + * + * Use this endpoint to log out the currently logged in user from all his + * account sessions across all his different devices. When using the option id + * argument, only the session unique ID provider will be deleted. + * + * @param {string} sessionId + * @throws {Error} + * @return {Promise} + */ + deleteSession(sessionId: string): Promise; + + /** + * Create Email Verification + * + * Use this endpoint to send a verification message to your user email address + * to confirm they are the valid owners of that address. Both the **userId** + * and **secret** arguments will be passed as query parameters to the URL you + * have provider to be attached to the verification email. The provided URL + * should redirect the user back for your app and allow you to complete the + * verification process by verifying both the **userId** and **secret** + * parameters. Learn more about how to [complete the verification + * process](/docs/account#updateAccountVerification). + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createVerification(url: string): Promise; + + /** + * Complete Email Verification + * + * Use this endpoint to complete the user email verification process. Use both + * the **userId** and **secret** parameters that were attached to your app URL + * to verify the user email ownership. If confirmed this route will return a + * 200 status code. + * + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateVerification(userId: string, secret: string): Promise; + + } + + export interface Avatars { + + /** + * Get Browser Icon + * + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user + * /account/sessions endpoint. Use width, height and quality arguments to + * change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {Promise} + */ + getBrowser(code: string, width: number, height: number, quality: number): Promise; + + /** + * Get Credit Card Icon + * + * Need to display your users with your billing method or their payment + * methods? The credit card endpoint will return you the icon of the credit + * card provider you need. Use width, height and quality arguments to change + * the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {string} + */ + getCreditCard(code: string, width: number, height: number, quality: number): string; + + /** + * Get Favicon + * + * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + * website URL. + * + * @param {string} url + * @throws {Error} + * @return {string} + */ + getFavicon(url: string): string; + + /** + * Get Country Flag + * + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {string} + */ + getFlag(code: string, width: number, height: number, quality: number): string; + + /** + * Get Image from URL + * + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {Error} + * @return {string} + */ + getImage(url: string, width: number, height: number): string; + + /** + * Get QR Code + * + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {number} download + * @throws {Error} + * @return {string} + */ + getQR(text: string, size: number, margin: number, download: number): string; + + } + + export interface Database { + + /** + * List Documents + * + * Get a list of all the user documents. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project documents. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} collectionId + * @param {string[]} filters + * @param {number} offset + * @param {number} limit + * @param {string} orderField + * @param {string} orderType + * @param {string} orderCast + * @param {string} search + * @param {number} first + * @param {number} last + * @throws {Error} + * @return {Promise} + */ + listDocuments(collectionId: string, filters: string[], offset: number, limit: number, orderField: string, orderType: string, orderCast: string, search: string, first: number, last: number): Promise; + + /** + * Create Document + * + * Create a new Document. + * + * @param {string} collectionId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @param {string} parentDocument + * @param {string} parentProperty + * @param {string} parentPropertyType + * @throws {Error} + * @return {Promise} + */ + createDocument(collectionId: string, data: object, read: string[], write: string[], parentDocument: string, parentProperty: string, parentPropertyType: string): Promise; + + /** + * Get Document + * + * Get document by its unique ID. This endpoint response returns a JSON object + * with the document data. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + getDocument(collectionId: string, documentId: string): Promise; + + /** + * Update Document + * + * + * @param {string} collectionId + * @param {string} documentId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + updateDocument(collectionId: string, documentId: string, data: object, read: string[], write: string[]): Promise; + + /** + * Delete Document + * + * Delete document by its unique ID. This endpoint deletes only the parent + * documents, his attributes and relations to other documents. Child documents + * **will not** be deleted. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + deleteDocument(collectionId: string, documentId: string): Promise; + + } + + export interface Locale { + + /** + * Get User Locale + * + * Get the current user location based on IP. Returns an object with user + * country code, country name, continent name, continent code, ip address and + * suggested currency. You can use the locale header to get the data in a + * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) + * + * @throws {Error} + * @return {Promise} + */ + get(): Promise; + + /** + * List Continents + * + * List of all continents. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getContinents(): Promise; + + /** + * List Countries + * + * List of all countries. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountries(): Promise; + + /** + * List EU Countries + * + * List of all countries that are currently members of the EU. You can use the + * locale header to get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesEU(): Promise; + + /** + * List Countries Phone Codes + * + * List of all countries phone codes. You can use the locale header to get the + * data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesPhones(): Promise; + + /** + * List Currencies + * + * List of all currencies, including currency symol, name, plural, and decimal + * digits for all major and minor currencies. You can use the locale header to + * get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCurrencies(): Promise; + + } + + export interface Storage { + + /** + * List Files + * + * Get a list of all the user files. You can use the query params to filter + * your results. On admin mode, this endpoint will return a list of all of the + * project files. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + listFiles(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create File + * + * Create a new file. The user who creates the file will automatically be + * assigned to read and write access unless he has passed custom values for + * read and write arguments. + * + * @param {File} file + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + createFile(file: File, read: string[], write: string[]): Promise; + + /** + * Get File + * + * Get file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + getFile(fileId: string): Promise; + + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param {string} fileId + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + updateFile(fileId: string, read: string[], write: string[]): Promise; + + /** + * Delete File + * + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + deleteFile(fileId: string): Promise; + + /** + * Get File for Download + * + * Get file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} fileId + * @throws {Error} + * @return {string} + */ + getFileDownload(fileId: string): string; + + /** + * Get File Preview + * + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. + * + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {number} quality + * @param {string} background + * @param {string} output + * @throws {Error} + * @return {string} + */ + getFilePreview(fileId: string, width: number, height: number, quality: number, background: string, output: string): string; + + /** + * Get File for View + * + * Get file content by its unique ID. This endpoint is similar to the download + * method but returns with no 'Content-Disposition: attachment' header. + * + * @param {string} fileId + * @param {string} as + * @throws {Error} + * @return {string} + */ + getFileView(fileId: string, as: string): string; + + } + + export interface Teams { + + /** + * List Teams + * + * Get a list of all the current user teams. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project teams. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + list(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create Team + * + * Create a new team. The user who creates the team will automatically be + * assigned as the owner of the team. The team owner can invite new members, + * who will be able add new owners and update or delete the team from your + * project. + * + * @param {string} name + * @param {string[]} roles + * @throws {Error} + * @return {Promise} + */ + create(name: string, roles: string[]): Promise; + + /** + * Get Team + * + * Get team by its unique ID. All team members have read access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + get(teamId: string): Promise; + + /** + * Update Team + * + * Update team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + update(teamId: string, name: string): Promise; + + /** + * Delete Team + * + * Delete team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + delete(teamId: string): Promise; + + /** + * Get Team Memberships + * + * Get team members by the team unique ID. All team members have read access + * for this list of resources. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + getMemberships(teamId: string): Promise; + + /** + * Create Team Membership + * + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. + * + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. + * + * Please note that in order to avoid a [Redirect + * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URL's are the once from domains you have set when + * added your platforms in the console interface. + * + * @param {string} teamId + * @param {string} email + * @param {string[]} roles + * @param {string} url + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + createMembership(teamId: string, email: string, roles: string[], url: string, name: string): Promise; + + /** + * Delete Team Membership + * + * This endpoint allows a user to leave a team or for a team owner to delete + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. + * + * @param {string} teamId + * @param {string} inviteId + * @throws {Error} + * @return {Promise} + */ + deleteMembership(teamId: string, inviteId: string): Promise; + + /** + * Update Team Membership Status + * + * Use this endpoint to allow a user to accept an invitation to join a team + * after he is being redirected back to your app from the invitation email he + * was sent. + * + * @param {string} teamId + * @param {string} inviteId + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateMembershipStatus(teamId: string, inviteId: string, userId: string, secret: string): Promise; + + } + + +} \ No newline at end of file diff --git a/app/sdks/console-javascript/package.json b/app/sdks/console-javascript/package.json deleted file mode 100644 index d4be0c0d03..0000000000 --- a/app/sdks/console-javascript/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "appwrite", - "homepage": "https://appwrite.io/support", - "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", - "version": "1.0.0", - "license": "BSD-3-Clause", - "main": "src/sdk.js", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-console" - }, - "devDependencies": {}, - "dependencies": {} -} \ No newline at end of file diff --git a/app/sdks/web-javascript/CHANGELOG.md b/app/sdks/console-web/CHANGELOG.md similarity index 100% rename from app/sdks/web-javascript/CHANGELOG.md rename to app/sdks/console-web/CHANGELOG.md diff --git a/app/sdks/web-javascript/LICENSE b/app/sdks/console-web/LICENSE similarity index 100% rename from app/sdks/web-javascript/LICENSE rename to app/sdks/console-web/LICENSE diff --git a/app/sdks/console-javascript/README.md b/app/sdks/console-web/README.md similarity index 61% rename from app/sdks/console-javascript/README.md rename to app/sdks/console-web/README.md index e92e54a111..5c6508f0a0 100644 --- a/app/sdks/console-javascript/README.md +++ b/app/sdks/console-web/README.md @@ -1,9 +1,11 @@ -# Appwrite SDK for JavaScript +# Appwrite Console SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://appwrite.io/images/github.png) @@ -31,21 +33,6 @@ To install with a CDN (content delivery network) add the following scripts to th ``` -## Getting Started - -Initialise the Appwrite SDK in your code, and setup your API credentials: - -```js - -// Init your JS SDK -var appwrite = new Appwrite(); - -appwrite - .setEndpoint('http://localhost/v1') // Set only when using self-hosted solution - .setProject('455x34dfkj') // Your Appwrite Project UID -; - -``` ## Contribution diff --git a/app/sdks/console-web/docs/examples/account/create-o-auth2session.md b/app/sdks/console-web/docs/examples/account/create-o-auth2session.md new file mode 100644 index 0000000000..b66e4360c6 --- /dev/null +++ b/app/sdks/console-web/docs/examples/account/create-o-auth2session.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.account.createOAuth2Session('bitbucket'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/account/create-recovery.md b/app/sdks/console-web/docs/examples/account/create-recovery.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/create-recovery.md rename to app/sdks/console-web/docs/examples/account/create-recovery.md diff --git a/app/sdks/console-javascript/docs/examples/account/create-session.md b/app/sdks/console-web/docs/examples/account/create-session.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/create-session.md rename to app/sdks/console-web/docs/examples/account/create-session.md diff --git a/app/sdks/console-javascript/docs/examples/account/create-verification.md b/app/sdks/console-web/docs/examples/account/create-verification.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/create-verification.md rename to app/sdks/console-web/docs/examples/account/create-verification.md diff --git a/app/sdks/console-javascript/docs/examples/account/create.md b/app/sdks/console-web/docs/examples/account/create.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/create.md rename to app/sdks/console-web/docs/examples/account/create.md diff --git a/app/sdks/console-javascript/docs/examples/account/delete-session.md b/app/sdks/console-web/docs/examples/account/delete-session.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/delete-session.md rename to app/sdks/console-web/docs/examples/account/delete-session.md diff --git a/app/sdks/console-javascript/docs/examples/account/delete-sessions.md b/app/sdks/console-web/docs/examples/account/delete-sessions.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/delete-sessions.md rename to app/sdks/console-web/docs/examples/account/delete-sessions.md diff --git a/app/sdks/console-javascript/docs/examples/account/delete.md b/app/sdks/console-web/docs/examples/account/delete.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/delete.md rename to app/sdks/console-web/docs/examples/account/delete.md diff --git a/app/sdks/console-javascript/docs/examples/account/get-logs.md b/app/sdks/console-web/docs/examples/account/get-logs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/get-logs.md rename to app/sdks/console-web/docs/examples/account/get-logs.md diff --git a/app/sdks/console-javascript/docs/examples/account/get-prefs.md b/app/sdks/console-web/docs/examples/account/get-prefs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/get-prefs.md rename to app/sdks/console-web/docs/examples/account/get-prefs.md diff --git a/app/sdks/console-javascript/docs/examples/account/get-sessions.md b/app/sdks/console-web/docs/examples/account/get-sessions.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/get-sessions.md rename to app/sdks/console-web/docs/examples/account/get-sessions.md diff --git a/app/sdks/console-javascript/docs/examples/account/get.md b/app/sdks/console-web/docs/examples/account/get.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/get.md rename to app/sdks/console-web/docs/examples/account/get.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-email.md b/app/sdks/console-web/docs/examples/account/update-email.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-email.md rename to app/sdks/console-web/docs/examples/account/update-email.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-name.md b/app/sdks/console-web/docs/examples/account/update-name.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-name.md rename to app/sdks/console-web/docs/examples/account/update-name.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-password.md b/app/sdks/console-web/docs/examples/account/update-password.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-password.md rename to app/sdks/console-web/docs/examples/account/update-password.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-prefs.md b/app/sdks/console-web/docs/examples/account/update-prefs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-prefs.md rename to app/sdks/console-web/docs/examples/account/update-prefs.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-recovery.md b/app/sdks/console-web/docs/examples/account/update-recovery.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-recovery.md rename to app/sdks/console-web/docs/examples/account/update-recovery.md diff --git a/app/sdks/console-javascript/docs/examples/account/update-verification.md b/app/sdks/console-web/docs/examples/account/update-verification.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/account/update-verification.md rename to app/sdks/console-web/docs/examples/account/update-verification.md diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-browser.md b/app/sdks/console-web/docs/examples/avatars/get-browser.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/avatars/get-browser.md rename to app/sdks/console-web/docs/examples/avatars/get-browser.md diff --git a/app/sdks/console-javascript/docs/examples/account/create-o-auth2session.md b/app/sdks/console-web/docs/examples/avatars/get-credit-card.md similarity index 65% rename from app/sdks/console-javascript/docs/examples/account/create-o-auth2session.md rename to app/sdks/console-web/docs/examples/avatars/get-credit-card.md index f4577b551f..3f701e3791 100644 --- a/app/sdks/console-javascript/docs/examples/account/create-o-auth2session.md +++ b/app/sdks/console-web/docs/examples/avatars/get-credit-card.md @@ -5,6 +5,6 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let result = sdk.account.createOAuth2Session('bitbucket', 'https://example.com', 'https://example.com'); +let result = sdk.avatars.getCreditCard('amex'); console.log(result); // Resource URL diff --git a/app/sdks/console-web/docs/examples/avatars/get-favicon.md b/app/sdks/console-web/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..037ddb30a0 --- /dev/null +++ b/app/sdks/console-web/docs/examples/avatars/get-favicon.md @@ -0,0 +1,10 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let result = sdk.avatars.getFavicon('https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/console-web/docs/examples/avatars/get-flag.md b/app/sdks/console-web/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..630673ca08 --- /dev/null +++ b/app/sdks/console-web/docs/examples/avatars/get-flag.md @@ -0,0 +1,10 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let result = sdk.avatars.getFlag('af'); + +console.log(result); // Resource URL diff --git a/app/sdks/console-web/docs/examples/avatars/get-image.md b/app/sdks/console-web/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..31994d6d88 --- /dev/null +++ b/app/sdks/console-web/docs/examples/avatars/get-image.md @@ -0,0 +1,10 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let result = sdk.avatars.getImage('https://example.com'); + +console.log(result); // Resource URL diff --git a/app/sdks/console-web/docs/examples/avatars/get-q-r.md b/app/sdks/console-web/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..91a31bf7fa --- /dev/null +++ b/app/sdks/console-web/docs/examples/avatars/get-q-r.md @@ -0,0 +1,10 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let result = sdk.avatars.getQR('[TEXT]'); + +console.log(result); // Resource URL diff --git a/app/sdks/console-javascript/docs/examples/database/create-collection.md b/app/sdks/console-web/docs/examples/database/create-collection.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/create-collection.md rename to app/sdks/console-web/docs/examples/database/create-collection.md diff --git a/app/sdks/console-javascript/docs/examples/database/create-document.md b/app/sdks/console-web/docs/examples/database/create-document.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/create-document.md rename to app/sdks/console-web/docs/examples/database/create-document.md diff --git a/app/sdks/console-javascript/docs/examples/database/delete-collection.md b/app/sdks/console-web/docs/examples/database/delete-collection.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/delete-collection.md rename to app/sdks/console-web/docs/examples/database/delete-collection.md diff --git a/app/sdks/console-javascript/docs/examples/database/delete-document.md b/app/sdks/console-web/docs/examples/database/delete-document.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/delete-document.md rename to app/sdks/console-web/docs/examples/database/delete-document.md diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-favicon.md b/app/sdks/console-web/docs/examples/database/get-collection-logs.md similarity index 81% rename from app/sdks/console-javascript/docs/examples/avatars/get-favicon.md rename to app/sdks/console-web/docs/examples/database/get-collection-logs.md index 2b8d94c4c6..09a05445ed 100644 --- a/app/sdks/console-javascript/docs/examples/avatars/get-favicon.md +++ b/app/sdks/console-web/docs/examples/database/get-collection-logs.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.avatars.getFavicon('https://example.com'); +let promise = sdk.database.getCollectionLogs('[COLLECTION_ID]'); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-javascript/docs/examples/database/get-collection.md b/app/sdks/console-web/docs/examples/database/get-collection.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/get-collection.md rename to app/sdks/console-web/docs/examples/database/get-collection.md diff --git a/app/sdks/console-javascript/docs/examples/database/get-document.md b/app/sdks/console-web/docs/examples/database/get-document.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/get-document.md rename to app/sdks/console-web/docs/examples/database/get-document.md diff --git a/app/sdks/console-javascript/docs/examples/database/list-collections.md b/app/sdks/console-web/docs/examples/database/list-collections.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/list-collections.md rename to app/sdks/console-web/docs/examples/database/list-collections.md diff --git a/app/sdks/console-javascript/docs/examples/database/list-documents.md b/app/sdks/console-web/docs/examples/database/list-documents.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/list-documents.md rename to app/sdks/console-web/docs/examples/database/list-documents.md diff --git a/app/sdks/console-javascript/docs/examples/database/update-collection.md b/app/sdks/console-web/docs/examples/database/update-collection.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/update-collection.md rename to app/sdks/console-web/docs/examples/database/update-collection.md diff --git a/app/sdks/console-javascript/docs/examples/database/update-document.md b/app/sdks/console-web/docs/examples/database/update-document.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/database/update-document.md rename to app/sdks/console-web/docs/examples/database/update-document.md diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-flag.md b/app/sdks/console-web/docs/examples/health/get-anti-virus.md similarity index 87% rename from app/sdks/console-javascript/docs/examples/avatars/get-flag.md rename to app/sdks/console-web/docs/examples/health/get-anti-virus.md index a2723be671..37ff9d820d 100644 --- a/app/sdks/console-javascript/docs/examples/avatars/get-flag.md +++ b/app/sdks/console-web/docs/examples/health/get-anti-virus.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.avatars.getFlag('af'); +let promise = sdk.health.getAntiVirus(); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-q-r.md b/app/sdks/console-web/docs/examples/health/get-cache.md similarity index 87% rename from app/sdks/console-javascript/docs/examples/avatars/get-q-r.md rename to app/sdks/console-web/docs/examples/health/get-cache.md index 39938a47bf..046c5ea191 100644 --- a/app/sdks/console-javascript/docs/examples/avatars/get-q-r.md +++ b/app/sdks/console-web/docs/examples/health/get-cache.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.avatars.getQR('[TEXT]'); +let promise = sdk.health.getCache(); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-credit-card.md b/app/sdks/console-web/docs/examples/health/get-d-b.md similarity index 85% rename from app/sdks/console-javascript/docs/examples/avatars/get-credit-card.md rename to app/sdks/console-web/docs/examples/health/get-d-b.md index 45c87c783a..5ce56a6c4e 100644 --- a/app/sdks/console-javascript/docs/examples/avatars/get-credit-card.md +++ b/app/sdks/console-web/docs/examples/health/get-d-b.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.avatars.getCreditCard('amex'); +let promise = sdk.health.getDB(); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-javascript/docs/examples/avatars/get-image.md b/app/sdks/console-web/docs/examples/health/get-queue-certificates.md similarity index 83% rename from app/sdks/console-javascript/docs/examples/avatars/get-image.md rename to app/sdks/console-web/docs/examples/health/get-queue-certificates.md index c9d6b6cf79..0ab304c378 100644 --- a/app/sdks/console-javascript/docs/examples/avatars/get-image.md +++ b/app/sdks/console-web/docs/examples/health/get-queue-certificates.md @@ -5,7 +5,7 @@ sdk .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; -let promise = sdk.avatars.getImage('https://example.com'); +let promise = sdk.health.getQueueCertificates(); promise.then(function (response) { console.log(response); // Success diff --git a/app/sdks/console-web/docs/examples/health/get-queue-functions.md b/app/sdks/console-web/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..6cbfbc342c --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-queue-functions.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getQueueFunctions(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-queue-logs.md b/app/sdks/console-web/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..35078edc21 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-queue-logs.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getQueueLogs(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-queue-tasks.md b/app/sdks/console-web/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..90ae978371 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getQueueTasks(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-queue-usage.md b/app/sdks/console-web/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..1c04d04fe9 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-queue-usage.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getQueueUsage(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-queue-webhooks.md b/app/sdks/console-web/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..18970f2157 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getQueueWebhooks(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-storage-local.md b/app/sdks/console-web/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..f034f47f9a --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-storage-local.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getStorageLocal(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get-time.md b/app/sdks/console-web/docs/examples/health/get-time.md new file mode 100644 index 0000000000..d579c981a3 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get-time.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.getTime(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-web/docs/examples/health/get.md b/app/sdks/console-web/docs/examples/health/get.md new file mode 100644 index 0000000000..0f7b186341 --- /dev/null +++ b/app/sdks/console-web/docs/examples/health/get.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = sdk.health.get(); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/locale/get-continents.md b/app/sdks/console-web/docs/examples/locale/get-continents.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get-continents.md rename to app/sdks/console-web/docs/examples/locale/get-continents.md diff --git a/app/sdks/console-javascript/docs/examples/locale/get-countries-e-u.md b/app/sdks/console-web/docs/examples/locale/get-countries-e-u.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get-countries-e-u.md rename to app/sdks/console-web/docs/examples/locale/get-countries-e-u.md diff --git a/app/sdks/console-javascript/docs/examples/locale/get-countries-phones.md b/app/sdks/console-web/docs/examples/locale/get-countries-phones.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get-countries-phones.md rename to app/sdks/console-web/docs/examples/locale/get-countries-phones.md diff --git a/app/sdks/console-javascript/docs/examples/locale/get-countries.md b/app/sdks/console-web/docs/examples/locale/get-countries.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get-countries.md rename to app/sdks/console-web/docs/examples/locale/get-countries.md diff --git a/app/sdks/console-javascript/docs/examples/locale/get-currencies.md b/app/sdks/console-web/docs/examples/locale/get-currencies.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get-currencies.md rename to app/sdks/console-web/docs/examples/locale/get-currencies.md diff --git a/app/sdks/console-javascript/docs/examples/locale/get.md b/app/sdks/console-web/docs/examples/locale/get.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/locale/get.md rename to app/sdks/console-web/docs/examples/locale/get.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create-domain.md b/app/sdks/console-web/docs/examples/projects/create-domain.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create-domain.md rename to app/sdks/console-web/docs/examples/projects/create-domain.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create-key.md b/app/sdks/console-web/docs/examples/projects/create-key.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create-key.md rename to app/sdks/console-web/docs/examples/projects/create-key.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create-platform.md b/app/sdks/console-web/docs/examples/projects/create-platform.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create-platform.md rename to app/sdks/console-web/docs/examples/projects/create-platform.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create-task.md b/app/sdks/console-web/docs/examples/projects/create-task.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create-task.md rename to app/sdks/console-web/docs/examples/projects/create-task.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create-webhook.md b/app/sdks/console-web/docs/examples/projects/create-webhook.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create-webhook.md rename to app/sdks/console-web/docs/examples/projects/create-webhook.md diff --git a/app/sdks/console-javascript/docs/examples/projects/create.md b/app/sdks/console-web/docs/examples/projects/create.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/create.md rename to app/sdks/console-web/docs/examples/projects/create.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete-domain.md b/app/sdks/console-web/docs/examples/projects/delete-domain.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete-domain.md rename to app/sdks/console-web/docs/examples/projects/delete-domain.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete-key.md b/app/sdks/console-web/docs/examples/projects/delete-key.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete-key.md rename to app/sdks/console-web/docs/examples/projects/delete-key.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete-platform.md b/app/sdks/console-web/docs/examples/projects/delete-platform.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete-platform.md rename to app/sdks/console-web/docs/examples/projects/delete-platform.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete-task.md b/app/sdks/console-web/docs/examples/projects/delete-task.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete-task.md rename to app/sdks/console-web/docs/examples/projects/delete-task.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete-webhook.md b/app/sdks/console-web/docs/examples/projects/delete-webhook.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete-webhook.md rename to app/sdks/console-web/docs/examples/projects/delete-webhook.md diff --git a/app/sdks/console-javascript/docs/examples/projects/delete.md b/app/sdks/console-web/docs/examples/projects/delete.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/delete.md rename to app/sdks/console-web/docs/examples/projects/delete.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-domain.md b/app/sdks/console-web/docs/examples/projects/get-domain.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-domain.md rename to app/sdks/console-web/docs/examples/projects/get-domain.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-key.md b/app/sdks/console-web/docs/examples/projects/get-key.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-key.md rename to app/sdks/console-web/docs/examples/projects/get-key.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-platform.md b/app/sdks/console-web/docs/examples/projects/get-platform.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-platform.md rename to app/sdks/console-web/docs/examples/projects/get-platform.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-task.md b/app/sdks/console-web/docs/examples/projects/get-task.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-task.md rename to app/sdks/console-web/docs/examples/projects/get-task.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-usage.md b/app/sdks/console-web/docs/examples/projects/get-usage.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-usage.md rename to app/sdks/console-web/docs/examples/projects/get-usage.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get-webhook.md b/app/sdks/console-web/docs/examples/projects/get-webhook.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get-webhook.md rename to app/sdks/console-web/docs/examples/projects/get-webhook.md diff --git a/app/sdks/console-javascript/docs/examples/projects/get.md b/app/sdks/console-web/docs/examples/projects/get.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/get.md rename to app/sdks/console-web/docs/examples/projects/get.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list-domains.md b/app/sdks/console-web/docs/examples/projects/list-domains.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list-domains.md rename to app/sdks/console-web/docs/examples/projects/list-domains.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list-keys.md b/app/sdks/console-web/docs/examples/projects/list-keys.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list-keys.md rename to app/sdks/console-web/docs/examples/projects/list-keys.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list-platforms.md b/app/sdks/console-web/docs/examples/projects/list-platforms.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list-platforms.md rename to app/sdks/console-web/docs/examples/projects/list-platforms.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list-tasks.md b/app/sdks/console-web/docs/examples/projects/list-tasks.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list-tasks.md rename to app/sdks/console-web/docs/examples/projects/list-tasks.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list-webhooks.md b/app/sdks/console-web/docs/examples/projects/list-webhooks.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list-webhooks.md rename to app/sdks/console-web/docs/examples/projects/list-webhooks.md diff --git a/app/sdks/console-javascript/docs/examples/projects/list.md b/app/sdks/console-web/docs/examples/projects/list.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/list.md rename to app/sdks/console-web/docs/examples/projects/list.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-domain-verification.md b/app/sdks/console-web/docs/examples/projects/update-domain-verification.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-domain-verification.md rename to app/sdks/console-web/docs/examples/projects/update-domain-verification.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-key.md b/app/sdks/console-web/docs/examples/projects/update-key.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-key.md rename to app/sdks/console-web/docs/examples/projects/update-key.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-o-auth2.md b/app/sdks/console-web/docs/examples/projects/update-o-auth2.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-o-auth2.md rename to app/sdks/console-web/docs/examples/projects/update-o-auth2.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-platform.md b/app/sdks/console-web/docs/examples/projects/update-platform.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-platform.md rename to app/sdks/console-web/docs/examples/projects/update-platform.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-task.md b/app/sdks/console-web/docs/examples/projects/update-task.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-task.md rename to app/sdks/console-web/docs/examples/projects/update-task.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update-webhook.md b/app/sdks/console-web/docs/examples/projects/update-webhook.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update-webhook.md rename to app/sdks/console-web/docs/examples/projects/update-webhook.md diff --git a/app/sdks/console-javascript/docs/examples/projects/update.md b/app/sdks/console-web/docs/examples/projects/update.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/projects/update.md rename to app/sdks/console-web/docs/examples/projects/update.md diff --git a/app/sdks/console-javascript/docs/examples/storage/create-file.md b/app/sdks/console-web/docs/examples/storage/create-file.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/create-file.md rename to app/sdks/console-web/docs/examples/storage/create-file.md diff --git a/app/sdks/console-javascript/docs/examples/storage/delete-file.md b/app/sdks/console-web/docs/examples/storage/delete-file.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/delete-file.md rename to app/sdks/console-web/docs/examples/storage/delete-file.md diff --git a/app/sdks/console-javascript/docs/examples/storage/get-file-download.md b/app/sdks/console-web/docs/examples/storage/get-file-download.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/get-file-download.md rename to app/sdks/console-web/docs/examples/storage/get-file-download.md diff --git a/app/sdks/console-javascript/docs/examples/storage/get-file-preview.md b/app/sdks/console-web/docs/examples/storage/get-file-preview.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/get-file-preview.md rename to app/sdks/console-web/docs/examples/storage/get-file-preview.md diff --git a/app/sdks/console-javascript/docs/examples/storage/get-file-view.md b/app/sdks/console-web/docs/examples/storage/get-file-view.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/get-file-view.md rename to app/sdks/console-web/docs/examples/storage/get-file-view.md diff --git a/app/sdks/console-javascript/docs/examples/storage/get-file.md b/app/sdks/console-web/docs/examples/storage/get-file.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/get-file.md rename to app/sdks/console-web/docs/examples/storage/get-file.md diff --git a/app/sdks/console-javascript/docs/examples/storage/list-files.md b/app/sdks/console-web/docs/examples/storage/list-files.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/list-files.md rename to app/sdks/console-web/docs/examples/storage/list-files.md diff --git a/app/sdks/console-javascript/docs/examples/storage/update-file.md b/app/sdks/console-web/docs/examples/storage/update-file.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/storage/update-file.md rename to app/sdks/console-web/docs/examples/storage/update-file.md diff --git a/app/sdks/console-javascript/docs/examples/teams/create-membership.md b/app/sdks/console-web/docs/examples/teams/create-membership.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/create-membership.md rename to app/sdks/console-web/docs/examples/teams/create-membership.md diff --git a/app/sdks/console-javascript/docs/examples/teams/create.md b/app/sdks/console-web/docs/examples/teams/create.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/create.md rename to app/sdks/console-web/docs/examples/teams/create.md diff --git a/app/sdks/console-javascript/docs/examples/teams/delete-membership.md b/app/sdks/console-web/docs/examples/teams/delete-membership.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/delete-membership.md rename to app/sdks/console-web/docs/examples/teams/delete-membership.md diff --git a/app/sdks/console-javascript/docs/examples/teams/delete.md b/app/sdks/console-web/docs/examples/teams/delete.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/delete.md rename to app/sdks/console-web/docs/examples/teams/delete.md diff --git a/app/sdks/console-javascript/docs/examples/teams/get-memberships.md b/app/sdks/console-web/docs/examples/teams/get-memberships.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/get-memberships.md rename to app/sdks/console-web/docs/examples/teams/get-memberships.md diff --git a/app/sdks/console-javascript/docs/examples/teams/get.md b/app/sdks/console-web/docs/examples/teams/get.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/get.md rename to app/sdks/console-web/docs/examples/teams/get.md diff --git a/app/sdks/console-javascript/docs/examples/teams/list.md b/app/sdks/console-web/docs/examples/teams/list.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/list.md rename to app/sdks/console-web/docs/examples/teams/list.md diff --git a/app/sdks/console-javascript/docs/examples/teams/update-membership-status.md b/app/sdks/console-web/docs/examples/teams/update-membership-status.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/update-membership-status.md rename to app/sdks/console-web/docs/examples/teams/update-membership-status.md diff --git a/app/sdks/console-javascript/docs/examples/teams/update.md b/app/sdks/console-web/docs/examples/teams/update.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/teams/update.md rename to app/sdks/console-web/docs/examples/teams/update.md diff --git a/app/sdks/console-javascript/docs/examples/users/create.md b/app/sdks/console-web/docs/examples/users/create.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/create.md rename to app/sdks/console-web/docs/examples/users/create.md diff --git a/app/sdks/console-javascript/docs/examples/users/delete-session.md b/app/sdks/console-web/docs/examples/users/delete-session.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/delete-session.md rename to app/sdks/console-web/docs/examples/users/delete-session.md diff --git a/app/sdks/console-javascript/docs/examples/users/delete-sessions.md b/app/sdks/console-web/docs/examples/users/delete-sessions.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/delete-sessions.md rename to app/sdks/console-web/docs/examples/users/delete-sessions.md diff --git a/app/sdks/console-javascript/docs/examples/users/get-logs.md b/app/sdks/console-web/docs/examples/users/get-logs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/get-logs.md rename to app/sdks/console-web/docs/examples/users/get-logs.md diff --git a/app/sdks/console-javascript/docs/examples/users/get-prefs.md b/app/sdks/console-web/docs/examples/users/get-prefs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/get-prefs.md rename to app/sdks/console-web/docs/examples/users/get-prefs.md diff --git a/app/sdks/console-javascript/docs/examples/users/get-sessions.md b/app/sdks/console-web/docs/examples/users/get-sessions.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/get-sessions.md rename to app/sdks/console-web/docs/examples/users/get-sessions.md diff --git a/app/sdks/console-javascript/docs/examples/users/get.md b/app/sdks/console-web/docs/examples/users/get.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/get.md rename to app/sdks/console-web/docs/examples/users/get.md diff --git a/app/sdks/console-javascript/docs/examples/users/list.md b/app/sdks/console-web/docs/examples/users/list.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/list.md rename to app/sdks/console-web/docs/examples/users/list.md diff --git a/app/sdks/console-javascript/docs/examples/users/update-prefs.md b/app/sdks/console-web/docs/examples/users/update-prefs.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/update-prefs.md rename to app/sdks/console-web/docs/examples/users/update-prefs.md diff --git a/app/sdks/console-javascript/docs/examples/users/update-status.md b/app/sdks/console-web/docs/examples/users/update-status.md similarity index 100% rename from app/sdks/console-javascript/docs/examples/users/update-status.md rename to app/sdks/console-web/docs/examples/users/update-status.md diff --git a/app/sdks/console-web/package.json b/app/sdks/console-web/package.json new file mode 100644 index 0000000000..6c53a70307 --- /dev/null +++ b/app/sdks/console-web/package.json @@ -0,0 +1,17 @@ +{ + "name": "appwrite", + "homepage": "https://appwrite.io/support", + "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", + "version": "1.0.0", + "license": "BSD-3-Clause", + "main": "src/sdk.js", + "types": "types/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/appwrite/sdk-for-console" + }, + "devDependencies": { + "typescript": "^3.6.4" + }, + "dependencies": {} +} \ No newline at end of file diff --git a/app/sdks/console-javascript/src/sdk.js b/app/sdks/console-web/src/sdk.js similarity index 92% rename from app/sdks/console-javascript/src/sdk.js rename to app/sdks/console-web/src/sdk.js index f707b7f779..a8b75c525b 100644 --- a/app/sdks/console-javascript/src/sdk.js +++ b/app/sdks/console-web/src/sdk.js @@ -286,28 +286,6 @@ } }(window.document); - let iframe = function(method, url, params) { - let form = document.createElement('form'); - - form.setAttribute('method', method); - form.setAttribute('action', config.endpoint + url); - - for(let key in params) { - if(params.hasOwnProperty(key)) { - let hiddenField = document.createElement("input"); - hiddenField.setAttribute("type", "hidden"); - hiddenField.setAttribute("name", key); - hiddenField.setAttribute("value", params[key]); - - form.appendChild(hiddenField); - } - } - - document.body.appendChild(form); - - return form.submit(); - }; - let account = { /** @@ -516,7 +494,7 @@ } if(oldPassword) { - payload['old-password'] = oldPassword; + payload['oldPassword'] = oldPassword; } return http @@ -630,12 +608,12 @@ * * @param {string} userId * @param {string} secret - * @param {string} passwordA - * @param {string} passwordB + * @param {string} password + * @param {string} passwordAgain * @throws {Error} * @return {Promise} */ - updateRecovery: function(userId, secret, passwordA, passwordB) { + updateRecovery: function(userId, secret, password, passwordAgain) { if(userId === undefined) { throw new Error('Missing required parameter: "userId"'); } @@ -644,12 +622,12 @@ throw new Error('Missing required parameter: "secret"'); } - if(passwordA === undefined) { - throw new Error('Missing required parameter: "passwordA"'); + if(password === undefined) { + throw new Error('Missing required parameter: "password"'); } - if(passwordB === undefined) { - throw new Error('Missing required parameter: "passwordB"'); + if(passwordAgain === undefined) { + throw new Error('Missing required parameter: "passwordAgain"'); } let path = '/account/recovery'; @@ -664,12 +642,12 @@ payload['secret'] = secret; } - if(passwordA) { - payload['password-a'] = passwordA; + if(password) { + payload['password'] = password; } - if(passwordB) { - payload['password-b'] = passwordB; + if(passwordAgain) { + payload['passwordAgain'] = passwordAgain; } return http @@ -768,21 +746,13 @@ * @param {string} success * @param {string} failure * @throws {Error} - * @return {string} + * @return {Promise} */ - createOAuth2Session: function(provider, success, failure) { + createOAuth2Session: function(provider, success = 'https://appwrite.io/auth/oauth2/success', failure = 'https://appwrite.io/auth/oauth2/failure') { if(provider === undefined) { throw new Error('Missing required parameter: "provider"'); } - if(success === undefined) { - throw new Error('Missing required parameter: "success"'); - } - - if(failure === undefined) { - throw new Error('Missing required parameter: "failure"'); - } - let path = '/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}', 'g'), provider); let payload = {}; @@ -800,8 +770,8 @@ payload['key'] = config.key; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - - return config.endpoint + path + ((query) ? '?' + query : ''); + + window.location = config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -968,7 +938,7 @@ * @param {number} height * @param {number} quality * @throws {Error} - * @return {Promise} + * @return {string} */ getCreditCard: function(code, width = 100, height = 100, quality = 100) { if(code === undefined) { @@ -991,10 +961,13 @@ payload['quality'] = quality; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + payload['key'] = config.key; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1005,7 +978,7 @@ * * @param {string} url * @throws {Error} - * @return {Promise} + * @return {string} */ getFavicon: function(url) { if(url === undefined) { @@ -1020,10 +993,13 @@ payload['url'] = url; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + payload['key'] = config.key; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1038,7 +1014,7 @@ * @param {number} height * @param {number} quality * @throws {Error} - * @return {Promise} + * @return {string} */ getFlag: function(code, width = 100, height = 100, quality = 100) { if(code === undefined) { @@ -1061,10 +1037,13 @@ payload['quality'] = quality; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + payload['key'] = config.key; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1079,7 +1058,7 @@ * @param {number} width * @param {number} height * @throws {Error} - * @return {Promise} + * @return {string} */ getImage: function(url, width = 400, height = 400) { if(url === undefined) { @@ -1102,10 +1081,13 @@ payload['height'] = height; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + payload['key'] = config.key; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); }, /** @@ -1119,7 +1101,7 @@ * @param {number} margin * @param {number} download * @throws {Error} - * @return {Promise} + * @return {string} */ getQR: function(text, size = 400, margin = 1, download = 0) { if(text === undefined) { @@ -1146,10 +1128,13 @@ payload['download'] = download; } - return http - .get(path, { - 'content-type': 'application/json', - }, payload); + payload['project'] = config.project; + + payload['key'] = config.key; + + let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); + + return config.endpoint + path + ((query) ? '?' + query : ''); } }; @@ -1203,9 +1188,9 @@ * Create a new Collection. * * @param {string} name - * @param {array} read - * @param {array} write - * @param {array} rules + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules * @throws {Error} * @return {Promise} */ @@ -1284,9 +1269,9 @@ * * @param {string} collectionId * @param {string} name - * @param {array} read - * @param {array} write - * @param {array} rules + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules * @throws {Error} * @return {Promise} */ @@ -1367,7 +1352,7 @@ * modes](/docs/admin). * * @param {string} collectionId - * @param {array} filters + * @param {string[]} filters * @param {number} offset * @param {number} limit * @param {string} orderField @@ -1401,15 +1386,15 @@ } if(orderField) { - payload['order-field'] = orderField; + payload['orderField'] = orderField; } if(orderType) { - payload['order-type'] = orderType; + payload['orderType'] = orderType; } if(orderCast) { - payload['order-cast'] = orderCast; + payload['orderCast'] = orderCast; } if(search) { @@ -1437,8 +1422,8 @@ * * @param {string} collectionId * @param {object} data - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @param {string} parentDocument * @param {string} parentProperty * @param {string} parentPropertyType @@ -1533,8 +1518,8 @@ * @param {string} collectionId * @param {string} documentId * @param {object} data - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -1610,6 +1595,272 @@ .delete(path, { 'content-type': 'application/json', }, payload); + }, + + /** + * Get Collection Logs + * + * + * @param {string} collectionId + * @throws {Error} + * @return {Promise} + */ + getCollectionLogs: function(collectionId) { + if(collectionId === undefined) { + throw new Error('Missing required parameter: "collectionId"'); + } + + let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + } + }; + + let health = { + + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @throws {Error} + * @return {Promise} + */ + get: function() { + let path = '/health'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getAntiVirus: function() { + let path = '/health/anti-virus'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @throws {Error} + * @return {Promise} + */ + getCache: function() { + let path = '/health/cache'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getDB: function() { + let path = '/health/db'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueCertificates: function() { + let path = '/health/queue/certificates'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Functions Queue + * + * + * @throws {Error} + * @return {Promise} + */ + getQueueFunctions: function() { + let path = '/health/queue/functions'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueLogs: function() { + let path = '/health/queue/logs'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueTasks: function() { + let path = '/health/queue/tasks'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueUsage: function() { + let path = '/health/queue/usage'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueWebhooks: function() { + let path = '/health/queue/webhooks'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getStorageLocal: function() { + let path = '/health/storage/local'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); + }, + + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @throws {Error} + * @return {Promise} + */ + getTime: function() { + let path = '/health/time'; + + let payload = {}; + + return http + .get(path, { + 'content-type': 'application/json', + }, payload); } }; @@ -1640,7 +1891,7 @@ }, /** - * List Countries + * List Continents * * List of all continents. You can use the locale header to get the data in a * supported language. @@ -2142,7 +2393,7 @@ * * @param {string} projectId * @param {string} name - * @param {array} scopes + * @param {string[]} scopes * @throws {Error} * @return {Promise} */ @@ -2212,7 +2463,7 @@ * @param {string} projectId * @param {string} keyId * @param {string} name - * @param {array} scopes + * @param {string[]} scopes * @throws {Error} * @return {Promise} */ @@ -2542,7 +2793,7 @@ * @param {number} security * @param {string} httpMethod * @param {string} httpUrl - * @param {array} httpHeaders + * @param {string[]} httpHeaders * @param {string} httpUser * @param {string} httpPass * @throws {Error} @@ -2663,7 +2914,7 @@ * @param {number} security * @param {string} httpMethod * @param {string} httpUrl - * @param {array} httpHeaders + * @param {string[]} httpHeaders * @param {string} httpUser * @param {string} httpPass * @throws {Error} @@ -2781,10 +3032,11 @@ * * * @param {string} projectId + * @param {string} range * @throws {Error} * @return {Promise} */ - getUsage: function(projectId) { + getUsage: function(projectId, range = 'last30') { if(projectId === undefined) { throw new Error('Missing required parameter: "projectId"'); } @@ -2793,6 +3045,10 @@ let payload = {}; + if(range) { + payload['range'] = range; + } + return http .get(path, { 'content-type': 'application/json', @@ -2828,7 +3084,7 @@ * * @param {string} projectId * @param {string} name - * @param {array} events + * @param {string[]} events * @param {string} url * @param {number} security * @param {string} httpUser @@ -2926,7 +3182,7 @@ * @param {string} projectId * @param {string} webhookId * @param {string} name - * @param {array} events + * @param {string[]} events * @param {string} url * @param {number} security * @param {string} httpUser @@ -3073,8 +3329,8 @@ * read and write arguments. * * @param {File} file - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -3145,8 +3401,8 @@ * to update this resource. * * @param {string} fileId - * @param {array} read - * @param {array} write + * @param {string[]} read + * @param {string[]} write * @throws {Error} * @return {Promise} */ @@ -3231,7 +3487,7 @@ payload['key'] = config.key; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); }, @@ -3286,7 +3542,7 @@ payload['key'] = config.key; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); }, @@ -3319,7 +3575,7 @@ payload['key'] = config.key; let query = Object.keys(payload).map(key => key + '=' + encodeURIComponent(payload[key])).join('&'); - + return config.endpoint + path + ((query) ? '?' + query : ''); } }; @@ -3376,7 +3632,7 @@ * project. * * @param {string} name - * @param {array} roles + * @param {string[]} roles * @throws {Error} * @return {Promise} */ @@ -3531,7 +3787,7 @@ * * @param {string} teamId * @param {string} email - * @param {array} roles + * @param {string[]} roles * @param {string} url * @param {string} name * @throws {Error} @@ -3918,14 +4174,10 @@ throw new Error('Missing required parameter: "sessionId"'); } - let path = '/users/{userId}/sessions/:session'.replace(new RegExp('{userId}', 'g'), userId); + let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); let payload = {}; - if(sessionId) { - payload['sessionId'] = sessionId; - } - return http .delete(path, { 'content-type': 'application/json', @@ -3975,6 +4227,7 @@ account: account, avatars: avatars, database: database, + health: health, locale: locale, projects: projects, storage: storage, diff --git a/app/sdks/console-javascript/src/sdk.min.js b/app/sdks/console-web/src/sdk.min.js similarity index 86% rename from app/sdks/console-javascript/src/sdk.min.js rename to app/sdks/console-web/src/sdk.min.js index ee58ad1ee3..ed8a70b4a1 100644 --- a/app/sdks/console-javascript/src/sdk.min.js +++ b/app/sdks/console-web/src/sdk.min.js @@ -12,8 +12,7 @@ request.setRequestHeader(key,headers[key])}} request.onload=function(){if(4===request.readyState&&399>=request.status){let data=request.response;let contentType=this.getResponseHeader('content-type')||'';contentType=contentType.substring(0,contentType.indexOf(';'));switch(contentType){case 'application/json':data=JSON.parse(data);break} let cookieFallback=this.getResponseHeader('X-Fallback-Cookies')||'';if(window.localStorage&&cookieFallback){window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');window.localStorage.setItem('cookieFallback',cookieFallback)} resolve(data)}else{reject(new Error(request.statusText))}};if(progress){request.addEventListener('progress',progress);request.upload.addEventListener('progress',progress,!1)} -request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let iframe=function(method,url,params){let form=document.createElement('form');form.setAttribute('method',method);form.setAttribute('action',config.endpoint+url);for(let key in params){if(params.hasOwnProperty(key)){let hiddenField=document.createElement("input");hiddenField.setAttribute("type","hidden");hiddenField.setAttribute("name",key);hiddenField.setAttribute("value",params[key]);form.appendChild(hiddenField)}} -document.body.appendChild(form);return form.submit()};let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} +request.onerror=function(){reject(new Error("Network Error"))};request.send(params)})};return{'get':function(path,headers={},params={}){return call('GET',path+((Object.keys(params).length>0)?'?'+buildQuery(params):''),headers,{})},'post':function(path,headers={},params={},progress=null){return call('POST',path,headers,params,progress)},'put':function(path,headers={},params={},progress=null){return call('PUT',path,headers,params,progress)},'patch':function(path,headers={},params={},progress=null){return call('PATCH',path,headers,params,progress)},'delete':function(path,headers={},params={},progress=null){return call('DELETE',path,headers,params,progress)},'addGlobalParam':addGlobalParam,'addGlobalHeader':addGlobalHeader}}(window.document);let account={get:function(){let path='/account';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(email,password,name=''){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account';let payload={};if(email){payload.email=email} if(password){payload.password=password} @@ -27,31 +26,29 @@ let path='/account/name';let payload={};if(name){payload.name=name} return http.patch(path,{'content-type':'application/json',},payload)},updatePassword:function(password,oldPassword){if(password===undefined){throw new Error('Missing required parameter: "password"')} if(oldPassword===undefined){throw new Error('Missing required parameter: "oldPassword"')} let path='/account/password';let payload={};if(password){payload.password=password} -if(oldPassword){payload['old-password']=oldPassword} +if(oldPassword){payload.oldPassword=oldPassword} return http.patch(path,{'content-type':'application/json',},payload)},getPrefs:function(){let path='/account/prefs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},updatePrefs:function(prefs){if(prefs===undefined){throw new Error('Missing required parameter: "prefs"')} let path='/account/prefs';let payload={};if(prefs){payload.prefs=prefs} return http.patch(path,{'content-type':'application/json',},payload)},createRecovery:function(email,url){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/account/recovery';let payload={};if(email){payload.email=email} if(url){payload.url=url} -return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,passwordA,passwordB){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +return http.post(path,{'content-type':'application/json',},payload)},updateRecovery:function(userId,secret,password,passwordAgain){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} if(secret===undefined){throw new Error('Missing required parameter: "secret"')} -if(passwordA===undefined){throw new Error('Missing required parameter: "passwordA"')} -if(passwordB===undefined){throw new Error('Missing required parameter: "passwordB"')} +if(password===undefined){throw new Error('Missing required parameter: "password"')} +if(passwordAgain===undefined){throw new Error('Missing required parameter: "passwordAgain"')} let path='/account/recovery';let payload={};if(userId){payload.userId=userId} if(secret){payload.secret=secret} -if(passwordA){payload['password-a']=passwordA} -if(passwordB){payload['password-b']=passwordB} +if(password){payload.password=password} +if(passwordAgain){payload.passwordAgain=passwordAgain} return http.put(path,{'content-type':'application/json',},payload)},getSessions:function(){let path='/account/sessions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},createSession:function(email,password){if(email===undefined){throw new Error('Missing required parameter: "email"')} if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account/sessions';let payload={};if(email){payload.email=email} if(password){payload.password=password} -return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success,failure){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} -if(success===undefined){throw new Error('Missing required parameter: "success"')} -if(failure===undefined){throw new Error('Missing required parameter: "failure"')} +return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://appwrite.io/auth/oauth2/success',failure='https://appwrite.io/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')} let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success} if(failure){payload.failure=failure} -payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} let path='/account/sessions/{sessionId}'.replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createVerification:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/account/verification';let payload={};if(url){payload.url=url} return http.post(path,{'content-type':'application/json',},payload)},updateVerification:function(userId,secret){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} @@ -66,22 +63,22 @@ return http.get(path,{'content-type':'application/json',},payload)},getCreditCar let path='/avatars/credit-cards/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} if(height){payload.height=height} if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFavicon:function(url){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/avatars/favicon';let payload={};if(url){payload.url=url} -return http.get(path,{'content-type':'application/json',},payload)},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getFlag:function(code,width=100,height=100,quality=100){if(code===undefined){throw new Error('Missing required parameter: "code"')} let path='/avatars/flags/{code}'.replace(new RegExp('{code}','g'),code);let payload={};if(width){payload.width=width} if(height){payload.height=height} if(quality){payload.quality=quality} -return http.get(path,{'content-type':'application/json',},payload)},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getImage:function(url,width=400,height=400){if(url===undefined){throw new Error('Missing required parameter: "url"')} let path='/avatars/image';let payload={};if(url){payload.url=url} if(width){payload.width=width} if(height){payload.height=height} -return http.get(path,{'content-type':'application/json',},payload)},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')},getQR:function(text,size=400,margin=1,download=0){if(text===undefined){throw new Error('Missing required parameter: "text"')} let path='/avatars/qr';let payload={};if(text){payload.text=text} if(size){payload.size=size} if(margin){payload.margin=margin} if(download){payload.download=download} -return http.get(path,{'content-type':'application/json',},payload)}};let database={listCollections:function(search='',limit=25,offset=0,orderType='ASC'){let path='/database/collections';let payload={};if(search){payload.search=search} +payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');return config.endpoint+path+((query)?'?'+query:'')}};let database={listCollections:function(search='',limit=25,offset=0,orderType='ASC'){let path='/database/collections';let payload={};if(search){payload.search=search} if(limit){payload.limit=limit} if(offset){payload.offset=offset} if(orderType){payload.orderType=orderType} @@ -107,9 +104,9 @@ let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionI let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload.filters=filters} if(offset){payload.offset=offset} if(limit){payload.limit=limit} -if(orderField){payload['order-field']=orderField} -if(orderType){payload['order-type']=orderType} -if(orderCast){payload['order-cast']=orderCast} +if(orderField){payload.orderField=orderField} +if(orderType){payload.orderType=orderType} +if(orderCast){payload.orderCast=orderCast} if(search){payload.search=search} if(first){payload.first=first} if(last){payload.last=last} @@ -135,7 +132,8 @@ if(read){payload.read=read} if(write){payload.write=write} return http.patch(path,{'content-type':'application/json',},payload)},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')} -let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let projects={list:function(){let path='/projects';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"')} +let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getCollectionLogs:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')} +let path='/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let health={get:function(){let path='/health';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getAntiVirus:function(){let path='/health/anti-virus';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCache:function(){let path='/health/cache';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getDB:function(){let path='/health/db';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueCertificates:function(){let path='/health/queue/certificates';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueFunctions:function(){let path='/health/queue/functions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueLogs:function(){let path='/health/queue/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueTasks:function(){let path='/health/queue/tasks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueUsage:function(){let path='/health/queue/usage';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueWebhooks:function(){let path='/health/queue/webhooks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getStorageLocal:function(){let path='/health/storage/local';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getTime:function(){let path='/health/time';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let projects={list:function(){let path='/projects';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"')} if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')} let path='/projects';let payload={};if(name){payload.name=name} if(teamId){payload.teamId=teamId} @@ -253,8 +251,9 @@ if(httpUser){payload.httpUser=httpUser} if(httpPass){payload.httpPass=httpPass} return http.put(path,{'content-type':'application/json',},payload)},deleteTask:function(projectId,taskId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} if(taskId===undefined){throw new Error('Missing required parameter: "taskId"')} -let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getUsage:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} -let path='/projects/{projectId}/usage'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},listWebhooks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} +let path='/projects/{projectId}/tasks/{taskId}'.replace(new RegExp('{projectId}','g'),projectId).replace(new RegExp('{taskId}','g'),taskId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getUsage:function(projectId,range='last30'){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} +let path='/projects/{projectId}/usage'.replace(new RegExp('{projectId}','g'),projectId);let payload={};if(range){payload.range=range} +return http.get(path,{'content-type':'application/json',},payload)},listWebhooks:function(projectId){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} let path='/projects/{projectId}/webhooks'.replace(new RegExp('{projectId}','g'),projectId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},createWebhook:function(projectId,name,events,url,security,httpUser='',httpPass=''){if(projectId===undefined){throw new Error('Missing required parameter: "projectId"')} if(name===undefined){throw new Error('Missing required parameter: "name"')} if(events===undefined){throw new Error('Missing required parameter: "events"')} @@ -356,8 +355,7 @@ return http.patch(path,{'content-type':'application/json',},payload)},getSession let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},deleteSessions:function(userId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} let path='/users/{userId}/sessions'.replace(new RegExp('{userId}','g'),userId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},deleteSession:function(userId,sessionId){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')} -let path='/users/{userId}/sessions/:session'.replace(new RegExp('{userId}','g'),userId);let payload={};if(sessionId){payload.sessionId=sessionId} -return http.delete(path,{'content-type':'application/json',},payload)},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} +let path='/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}','g'),userId).replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"')} if(status===undefined){throw new Error('Missing required parameter: "status"')} let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);let payload={};if(status){payload.status=status} -return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,locale:locale,projects:projects,storage:storage,teams:teams,users:users}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file +return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,health:health,locale:locale,projects:projects,storage:storage,teams:teams,users:users}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{}) \ No newline at end of file diff --git a/app/sdks/console-web/tsconfig.json b/app/sdks/console-web/tsconfig.json new file mode 100644 index 0000000000..1e668ca62c --- /dev/null +++ b/app/sdks/console-web/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "ES6", + "lib": ["ES2015", "ES6", "dom"], + "module": "commonjs", + "sourceMap": true + } +} \ No newline at end of file diff --git a/app/sdks/console-web/types/index.d.ts b/app/sdks/console-web/types/index.d.ts new file mode 100644 index 0000000000..5f62d42af8 --- /dev/null +++ b/app/sdks/console-web/types/index.d.ts @@ -0,0 +1,1594 @@ +// Type definitions for appwrite 1.0.0 +// Project: Appwrite + + +/*~ This declaration specifies that the class constructor function + *~ is the exported object from the file + */ +export = Appwrite; + +/*~ Write your module's methods and properties in this class */ +declare class Appwrite { + constructor(); + + /** + * @param {string} endpoint + * @returns {this} + */ + setEndpoint(endpoint: string): this; + + /** + * Set Project + * + * Your project ID + * + * @param value string + * + * @return this + */ + setProject(project: string): this; + /** + * Set Key + * + * Your secret API key + * + * @param value string + * + * @return this + */ + setKey(key: string): this; + /** + * Set Locale + * + * @param value string + * + * @return this + */ + setLocale(locale: string): this; + /** + * Set Mode + * + * @param value string + * + * @return this + */ + setMode(mode: string): this; + + account:Appwrite.Account; + avatars:Appwrite.Avatars; + database:Appwrite.Database; + health:Appwrite.Health; + locale:Appwrite.Locale; + projects:Appwrite.Projects; + storage:Appwrite.Storage; + teams:Appwrite.Teams; + users:Appwrite.Users; + +} + +declare namespace Appwrite { + + export interface Account { + + /** + * Get Account + * + * Get currently logged in user data as JSON object. + * + * @throws {Error} + * @return {Promise} + */ + get(): Promise; + + /** + * Create Account + * + * Use this endpoint to allow a new user to register a new account in your + * project. After the user registration completes successfully, you can use + * the [/account/verfication](/docs/account#createVerification) route to start + * verifying the user email address. To allow your new user to login to his + * new account, you need to create a new [account + * session](/docs/account#createSession). + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + create(email: string, password: string, name: string): Promise; + + /** + * Delete Account + * + * Delete a currently logged in user account. Behind the scene, the user + * record is not deleted but permanently blocked from any access. This is done + * to avoid deleted accounts being overtaken by new users with the same email + * address. Any user-related resources like documents or storage files should + * be deleted separately. + * + * @throws {Error} + * @return {Promise} + */ + delete(): Promise; + + /** + * Update Account Email + * + * Update currently logged in user account email address. After changing user + * address, user confirmation status is being reset and a new confirmation + * mail is sent. For security measures, user password is required to complete + * this request. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + updateEmail(email: string, password: string): Promise; + + /** + * Get Account Logs + * + * Get currently logged in user list of latest security activity logs. Each + * log returns user IP address, location and date and time of log. + * + * @throws {Error} + * @return {Promise} + */ + getLogs(): Promise; + + /** + * Update Account Name + * + * Update currently logged in user account name. + * + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + updateName(name: string): Promise; + + /** + * Update Account Password + * + * Update currently logged in user password. For validation, user is required + * to pass the password twice. + * + * @param {string} password + * @param {string} oldPassword + * @throws {Error} + * @return {Promise} + */ + updatePassword(password: string, oldPassword: string): Promise; + + /** + * Get Account Preferences + * + * Get currently logged in user preferences as a key-value object. + * + * @throws {Error} + * @return {Promise} + */ + getPrefs(): Promise; + + /** + * Update Account Preferences + * + * Update currently logged in user account preferences. You can pass only the + * specific settings you wish to update. + * + * @param {object} prefs + * @throws {Error} + * @return {Promise} + */ + updatePrefs(prefs: object): Promise; + + /** + * Create Password Recovery + * + * Sends the user an email with a temporary secret key for password reset. + * When the user clicks the confirmation link he is redirected back to your + * app password reset URL with the secret key and email address values + * attached to the URL query string. Use the query string params to submit a + * request to the [PUT /account/recovery](/docs/account#updateRecovery) + * endpoint to complete the process. + * + * @param {string} email + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createRecovery(email: string, url: string): Promise; + + /** + * Complete Password Recovery + * + * Use this endpoint to complete the user account password reset. Both the + * **userId** and **secret** arguments will be passed as query parameters to + * the redirect URL you have provided when sending your request to the [POST + * /account/recovery](/docs/account#createRecovery) endpoint. + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} userId + * @param {string} secret + * @param {string} password + * @param {string} passwordAgain + * @throws {Error} + * @return {Promise} + */ + updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise; + + /** + * Get Account Sessions + * + * Get currently logged in user list of active sessions across different + * devices. + * + * @throws {Error} + * @return {Promise} + */ + getSessions(): Promise; + + /** + * Create Account Session + * + * Allow the user to login into his account by providing a valid email and + * password combination. This route will create a new session for the user. + * + * @param {string} email + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + createSession(email: string, password: string): Promise; + + /** + * Delete All Account Sessions + * + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. + * + * @throws {Error} + * @return {Promise} + */ + deleteSessions(): Promise; + + /** + * Create Account Session with OAuth2 + * + * Allow the user to login to his account using the OAuth2 provider of his + * choice. Each OAuth2 provider should be enabled from the Appwrite console + * first. Use the success and failure arguments to provide a redirect URL's + * back to your app when login is completed. + * + * @param {string} provider + * @param {string} success + * @param {string} failure + * @throws {Error} + * @return {Promise} + */ + createOAuth2Session(provider: string, success: string, failure: string): Promise; + + /** + * Delete Account Session + * + * Use this endpoint to log out the currently logged in user from all his + * account sessions across all his different devices. When using the option id + * argument, only the session unique ID provider will be deleted. + * + * @param {string} sessionId + * @throws {Error} + * @return {Promise} + */ + deleteSession(sessionId: string): Promise; + + /** + * Create Email Verification + * + * Use this endpoint to send a verification message to your user email address + * to confirm they are the valid owners of that address. Both the **userId** + * and **secret** arguments will be passed as query parameters to the URL you + * have provider to be attached to the verification email. The provided URL + * should redirect the user back for your app and allow you to complete the + * verification process by verifying both the **userId** and **secret** + * parameters. Learn more about how to [complete the verification + * process](/docs/account#updateAccountVerification). + * + * Please note that in order to avoid a [Redirect + * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URLs are the ones from domains you have set when + * adding your platforms in the console interface. + * + * @param {string} url + * @throws {Error} + * @return {Promise} + */ + createVerification(url: string): Promise; + + /** + * Complete Email Verification + * + * Use this endpoint to complete the user email verification process. Use both + * the **userId** and **secret** parameters that were attached to your app URL + * to verify the user email ownership. If confirmed this route will return a + * 200 status code. + * + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateVerification(userId: string, secret: string): Promise; + + } + + export interface Avatars { + + /** + * Get Browser Icon + * + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user + * /account/sessions endpoint. Use width, height and quality arguments to + * change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {Promise} + */ + getBrowser(code: string, width: number, height: number, quality: number): Promise; + + /** + * Get Credit Card Icon + * + * Need to display your users with your billing method or their payment + * methods? The credit card endpoint will return you the icon of the credit + * card provider you need. Use width, height and quality arguments to change + * the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {string} + */ + getCreditCard(code: string, width: number, height: number, quality: number): string; + + /** + * Get Favicon + * + * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + * website URL. + * + * @param {string} url + * @throws {Error} + * @return {string} + */ + getFavicon(url: string): string; + + /** + * Get Country Flag + * + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. + * + * @param {string} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {Error} + * @return {string} + */ + getFlag(code: string, width: number, height: number, quality: number): string; + + /** + * Get Image from URL + * + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {Error} + * @return {string} + */ + getImage(url: string, width: number, height: number): string; + + /** + * Get QR Code + * + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {number} download + * @throws {Error} + * @return {string} + */ + getQR(text: string, size: number, margin: number, download: number): string; + + } + + export interface Database { + + /** + * List Collections + * + * Get a list of all the user collections. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project collections. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + listCollections(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create Collection + * + * Create a new Collection. + * + * @param {string} name + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules + * @throws {Error} + * @return {Promise} + */ + createCollection(name: string, read: string[], write: string[], rules: string[]): Promise; + + /** + * Get Collection + * + * Get collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + * + * @param {string} collectionId + * @throws {Error} + * @return {Promise} + */ + getCollection(collectionId: string): Promise; + + /** + * Update Collection + * + * Update collection by its unique ID. + * + * @param {string} collectionId + * @param {string} name + * @param {string[]} read + * @param {string[]} write + * @param {string[]} rules + * @throws {Error} + * @return {Promise} + */ + updateCollection(collectionId: string, name: string, read: string[], write: string[], rules: string[]): Promise; + + /** + * Delete Collection + * + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + * + * @param {string} collectionId + * @throws {Error} + * @return {Promise} + */ + deleteCollection(collectionId: string): Promise; + + /** + * List Documents + * + * Get a list of all the user documents. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project documents. [Learn more about different API + * modes](/docs/admin). + * + * @param {string} collectionId + * @param {string[]} filters + * @param {number} offset + * @param {number} limit + * @param {string} orderField + * @param {string} orderType + * @param {string} orderCast + * @param {string} search + * @param {number} first + * @param {number} last + * @throws {Error} + * @return {Promise} + */ + listDocuments(collectionId: string, filters: string[], offset: number, limit: number, orderField: string, orderType: string, orderCast: string, search: string, first: number, last: number): Promise; + + /** + * Create Document + * + * Create a new Document. + * + * @param {string} collectionId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @param {string} parentDocument + * @param {string} parentProperty + * @param {string} parentPropertyType + * @throws {Error} + * @return {Promise} + */ + createDocument(collectionId: string, data: object, read: string[], write: string[], parentDocument: string, parentProperty: string, parentPropertyType: string): Promise; + + /** + * Get Document + * + * Get document by its unique ID. This endpoint response returns a JSON object + * with the document data. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + getDocument(collectionId: string, documentId: string): Promise; + + /** + * Update Document + * + * + * @param {string} collectionId + * @param {string} documentId + * @param {object} data + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + updateDocument(collectionId: string, documentId: string, data: object, read: string[], write: string[]): Promise; + + /** + * Delete Document + * + * Delete document by its unique ID. This endpoint deletes only the parent + * documents, his attributes and relations to other documents. Child documents + * **will not** be deleted. + * + * @param {string} collectionId + * @param {string} documentId + * @throws {Error} + * @return {Promise} + */ + deleteDocument(collectionId: string, documentId: string): Promise; + + /** + * Get Collection Logs + * + * + * @param {string} collectionId + * @throws {Error} + * @return {Promise} + */ + getCollectionLogs(collectionId: string): Promise; + + } + + export interface Health { + + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @throws {Error} + * @return {Promise} + */ + get(): Promise; + + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getAntiVirus(): Promise; + + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @throws {Error} + * @return {Promise} + */ + getCache(): Promise; + + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getDB(): Promise; + + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueCertificates(): Promise; + + /** + * Get Functions Queue + * + * + * @throws {Error} + * @return {Promise} + */ + getQueueFunctions(): Promise; + + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueLogs(): Promise; + + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueTasks(): Promise; + + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueUsage(): Promise; + + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws {Error} + * @return {Promise} + */ + getQueueWebhooks(): Promise; + + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws {Error} + * @return {Promise} + */ + getStorageLocal(): Promise; + + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @throws {Error} + * @return {Promise} + */ + getTime(): Promise; + + } + + export interface Locale { + + /** + * Get User Locale + * + * Get the current user location based on IP. Returns an object with user + * country code, country name, continent name, continent code, ip address and + * suggested currency. You can use the locale header to get the data in a + * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) + * + * @throws {Error} + * @return {Promise} + */ + get(): Promise; + + /** + * List Continents + * + * List of all continents. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getContinents(): Promise; + + /** + * List Countries + * + * List of all countries. You can use the locale header to get the data in a + * supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountries(): Promise; + + /** + * List EU Countries + * + * List of all countries that are currently members of the EU. You can use the + * locale header to get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesEU(): Promise; + + /** + * List Countries Phone Codes + * + * List of all countries phone codes. You can use the locale header to get the + * data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCountriesPhones(): Promise; + + /** + * List Currencies + * + * List of all currencies, including currency symol, name, plural, and decimal + * digits for all major and minor currencies. You can use the locale header to + * get the data in a supported language. + * + * @throws {Error} + * @return {Promise} + */ + getCurrencies(): Promise; + + } + + export interface Projects { + + /** + * List Projects + * + * + * @throws {Error} + * @return {Promise} + */ + list(): Promise; + + /** + * Create Project + * + * + * @param {string} name + * @param {string} teamId + * @param {string} description + * @param {string} logo + * @param {string} url + * @param {string} legalName + * @param {string} legalCountry + * @param {string} legalState + * @param {string} legalCity + * @param {string} legalAddress + * @param {string} legalTaxId + * @throws {Error} + * @return {Promise} + */ + create(name: string, teamId: string, description: string, logo: string, url: string, legalName: string, legalCountry: string, legalState: string, legalCity: string, legalAddress: string, legalTaxId: string): Promise; + + /** + * Get Project + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + get(projectId: string): Promise; + + /** + * Update Project + * + * + * @param {string} projectId + * @param {string} name + * @param {string} description + * @param {string} logo + * @param {string} url + * @param {string} legalName + * @param {string} legalCountry + * @param {string} legalState + * @param {string} legalCity + * @param {string} legalAddress + * @param {string} legalTaxId + * @throws {Error} + * @return {Promise} + */ + update(projectId: string, name: string, description: string, logo: string, url: string, legalName: string, legalCountry: string, legalState: string, legalCity: string, legalAddress: string, legalTaxId: string): Promise; + + /** + * Delete Project + * + * + * @param {string} projectId + * @param {string} password + * @throws {Error} + * @return {Promise} + */ + delete(projectId: string, password: string): Promise; + + /** + * List Domains + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + listDomains(projectId: string): Promise; + + /** + * Create Domain + * + * + * @param {string} projectId + * @param {string} domain + * @throws {Error} + * @return {Promise} + */ + createDomain(projectId: string, domain: string): Promise; + + /** + * Get Domain + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {Error} + * @return {Promise} + */ + getDomain(projectId: string, domainId: string): Promise; + + /** + * Delete Domain + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {Error} + * @return {Promise} + */ + deleteDomain(projectId: string, domainId: string): Promise; + + /** + * Update Domain Verification Status + * + * + * @param {string} projectId + * @param {string} domainId + * @throws {Error} + * @return {Promise} + */ + updateDomainVerification(projectId: string, domainId: string): Promise; + + /** + * List Keys + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + listKeys(projectId: string): Promise; + + /** + * Create Key + * + * + * @param {string} projectId + * @param {string} name + * @param {string[]} scopes + * @throws {Error} + * @return {Promise} + */ + createKey(projectId: string, name: string, scopes: string[]): Promise; + + /** + * Get Key + * + * + * @param {string} projectId + * @param {string} keyId + * @throws {Error} + * @return {Promise} + */ + getKey(projectId: string, keyId: string): Promise; + + /** + * Update Key + * + * + * @param {string} projectId + * @param {string} keyId + * @param {string} name + * @param {string[]} scopes + * @throws {Error} + * @return {Promise} + */ + updateKey(projectId: string, keyId: string, name: string, scopes: string[]): Promise; + + /** + * Delete Key + * + * + * @param {string} projectId + * @param {string} keyId + * @throws {Error} + * @return {Promise} + */ + deleteKey(projectId: string, keyId: string): Promise; + + /** + * Update Project OAuth2 + * + * + * @param {string} projectId + * @param {string} provider + * @param {string} appId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateOAuth2(projectId: string, provider: string, appId: string, secret: string): Promise; + + /** + * List Platforms + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + listPlatforms(projectId: string): Promise; + + /** + * Create Platform + * + * + * @param {string} projectId + * @param {string} type + * @param {string} name + * @param {string} key + * @param {string} store + * @param {string} hostname + * @throws {Error} + * @return {Promise} + */ + createPlatform(projectId: string, type: string, name: string, key: string, store: string, hostname: string): Promise; + + /** + * Get Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @throws {Error} + * @return {Promise} + */ + getPlatform(projectId: string, platformId: string): Promise; + + /** + * Update Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @param {string} name + * @param {string} key + * @param {string} store + * @param {string} hostname + * @throws {Error} + * @return {Promise} + */ + updatePlatform(projectId: string, platformId: string, name: string, key: string, store: string, hostname: string): Promise; + + /** + * Delete Platform + * + * + * @param {string} projectId + * @param {string} platformId + * @throws {Error} + * @return {Promise} + */ + deletePlatform(projectId: string, platformId: string): Promise; + + /** + * List Tasks + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + listTasks(projectId: string): Promise; + + /** + * Create Task + * + * + * @param {string} projectId + * @param {string} name + * @param {string} status + * @param {string} schedule + * @param {number} security + * @param {string} httpMethod + * @param {string} httpUrl + * @param {string[]} httpHeaders + * @param {string} httpUser + * @param {string} httpPass + * @throws {Error} + * @return {Promise} + */ + createTask(projectId: string, name: string, status: string, schedule: string, security: number, httpMethod: string, httpUrl: string, httpHeaders: string[], httpUser: string, httpPass: string): Promise; + + /** + * Get Task + * + * + * @param {string} projectId + * @param {string} taskId + * @throws {Error} + * @return {Promise} + */ + getTask(projectId: string, taskId: string): Promise; + + /** + * Update Task + * + * + * @param {string} projectId + * @param {string} taskId + * @param {string} name + * @param {string} status + * @param {string} schedule + * @param {number} security + * @param {string} httpMethod + * @param {string} httpUrl + * @param {string[]} httpHeaders + * @param {string} httpUser + * @param {string} httpPass + * @throws {Error} + * @return {Promise} + */ + updateTask(projectId: string, taskId: string, name: string, status: string, schedule: string, security: number, httpMethod: string, httpUrl: string, httpHeaders: string[], httpUser: string, httpPass: string): Promise; + + /** + * Delete Task + * + * + * @param {string} projectId + * @param {string} taskId + * @throws {Error} + * @return {Promise} + */ + deleteTask(projectId: string, taskId: string): Promise; + + /** + * Get Project + * + * + * @param {string} projectId + * @param {string} range + * @throws {Error} + * @return {Promise} + */ + getUsage(projectId: string, range: string): Promise; + + /** + * List Webhooks + * + * + * @param {string} projectId + * @throws {Error} + * @return {Promise} + */ + listWebhooks(projectId: string): Promise; + + /** + * Create Webhook + * + * + * @param {string} projectId + * @param {string} name + * @param {string[]} events + * @param {string} url + * @param {number} security + * @param {string} httpUser + * @param {string} httpPass + * @throws {Error} + * @return {Promise} + */ + createWebhook(projectId: string, name: string, events: string[], url: string, security: number, httpUser: string, httpPass: string): Promise; + + /** + * Get Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @throws {Error} + * @return {Promise} + */ + getWebhook(projectId: string, webhookId: string): Promise; + + /** + * Update Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @param {string} name + * @param {string[]} events + * @param {string} url + * @param {number} security + * @param {string} httpUser + * @param {string} httpPass + * @throws {Error} + * @return {Promise} + */ + updateWebhook(projectId: string, webhookId: string, name: string, events: string[], url: string, security: number, httpUser: string, httpPass: string): Promise; + + /** + * Delete Webhook + * + * + * @param {string} projectId + * @param {string} webhookId + * @throws {Error} + * @return {Promise} + */ + deleteWebhook(projectId: string, webhookId: string): Promise; + + } + + export interface Storage { + + /** + * List Files + * + * Get a list of all the user files. You can use the query params to filter + * your results. On admin mode, this endpoint will return a list of all of the + * project files. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + listFiles(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create File + * + * Create a new file. The user who creates the file will automatically be + * assigned to read and write access unless he has passed custom values for + * read and write arguments. + * + * @param {File} file + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + createFile(file: File, read: string[], write: string[]): Promise; + + /** + * Get File + * + * Get file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + getFile(fileId: string): Promise; + + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param {string} fileId + * @param {string[]} read + * @param {string[]} write + * @throws {Error} + * @return {Promise} + */ + updateFile(fileId: string, read: string[], write: string[]): Promise; + + /** + * Delete File + * + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param {string} fileId + * @throws {Error} + * @return {Promise} + */ + deleteFile(fileId: string): Promise; + + /** + * Get File for Download + * + * Get file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} fileId + * @throws {Error} + * @return {string} + */ + getFileDownload(fileId: string): string; + + /** + * Get File Preview + * + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. + * + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {number} quality + * @param {string} background + * @param {string} output + * @throws {Error} + * @return {string} + */ + getFilePreview(fileId: string, width: number, height: number, quality: number, background: string, output: string): string; + + /** + * Get File for View + * + * Get file content by its unique ID. This endpoint is similar to the download + * method but returns with no 'Content-Disposition: attachment' header. + * + * @param {string} fileId + * @param {string} as + * @throws {Error} + * @return {string} + */ + getFileView(fileId: string, as: string): string; + + } + + export interface Teams { + + /** + * List Teams + * + * Get a list of all the current user teams. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project teams. [Learn more about different API modes](/docs/admin). + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + list(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create Team + * + * Create a new team. The user who creates the team will automatically be + * assigned as the owner of the team. The team owner can invite new members, + * who will be able add new owners and update or delete the team from your + * project. + * + * @param {string} name + * @param {string[]} roles + * @throws {Error} + * @return {Promise} + */ + create(name: string, roles: string[]): Promise; + + /** + * Get Team + * + * Get team by its unique ID. All team members have read access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + get(teamId: string): Promise; + + /** + * Update Team + * + * Update team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + update(teamId: string, name: string): Promise; + + /** + * Delete Team + * + * Delete team by its unique ID. Only team owners have write access for this + * resource. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + delete(teamId: string): Promise; + + /** + * Get Team Memberships + * + * Get team members by the team unique ID. All team members have read access + * for this list of resources. + * + * @param {string} teamId + * @throws {Error} + * @return {Promise} + */ + getMemberships(teamId: string): Promise; + + /** + * Create Team Membership + * + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. + * + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. + * + * Please note that in order to avoid a [Redirect + * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URL's are the once from domains you have set when + * added your platforms in the console interface. + * + * @param {string} teamId + * @param {string} email + * @param {string[]} roles + * @param {string} url + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + createMembership(teamId: string, email: string, roles: string[], url: string, name: string): Promise; + + /** + * Delete Team Membership + * + * This endpoint allows a user to leave a team or for a team owner to delete + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. + * + * @param {string} teamId + * @param {string} inviteId + * @throws {Error} + * @return {Promise} + */ + deleteMembership(teamId: string, inviteId: string): Promise; + + /** + * Update Team Membership Status + * + * Use this endpoint to allow a user to accept an invitation to join a team + * after he is being redirected back to your app from the invitation email he + * was sent. + * + * @param {string} teamId + * @param {string} inviteId + * @param {string} userId + * @param {string} secret + * @throws {Error} + * @return {Promise} + */ + updateMembershipStatus(teamId: string, inviteId: string, userId: string, secret: string): Promise; + + } + + export interface Users { + + /** + * List Users + * + * Get a list of all the project users. You can use the query params to filter + * your results. + * + * @param {string} search + * @param {number} limit + * @param {number} offset + * @param {string} orderType + * @throws {Error} + * @return {Promise} + */ + list(search: string, limit: number, offset: number, orderType: string): Promise; + + /** + * Create User + * + * Create a new user. + * + * @param {string} email + * @param {string} password + * @param {string} name + * @throws {Error} + * @return {Promise} + */ + create(email: string, password: string, name: string): Promise; + + /** + * Get User + * + * Get user by its unique ID. + * + * @param {string} userId + * @throws {Error} + * @return {Promise} + */ + get(userId: string): Promise; + + /** + * Get User Logs + * + * Get user activity logs list by its unique ID. + * + * @param {string} userId + * @throws {Error} + * @return {Promise} + */ + getLogs(userId: string): Promise; + + /** + * Get User Preferences + * + * Get user preferences by its unique ID. + * + * @param {string} userId + * @throws {Error} + * @return {Promise} + */ + getPrefs(userId: string): Promise; + + /** + * Update User Preferences + * + * Update user preferences by its unique ID. You can pass only the specific + * settings you wish to update. + * + * @param {string} userId + * @param {object} prefs + * @throws {Error} + * @return {Promise} + */ + updatePrefs(userId: string, prefs: object): Promise; + + /** + * Get User Sessions + * + * Get user sessions list by its unique ID. + * + * @param {string} userId + * @throws {Error} + * @return {Promise} + */ + getSessions(userId: string): Promise; + + /** + * Delete User Sessions + * + * Delete all user sessions by its unique ID. + * + * @param {string} userId + * @throws {Error} + * @return {Promise} + */ + deleteSessions(userId: string): Promise; + + /** + * Delete User Session + * + * Delete user sessions by its unique ID. + * + * @param {string} userId + * @param {string} sessionId + * @throws {Error} + * @return {Promise} + */ + deleteSession(userId: string, sessionId: string): Promise; + + /** + * Update User Status + * + * Update user status by its unique ID. + * + * @param {string} userId + * @param {string} status + * @throws {Error} + * @return {Promise} + */ + updateStatus(userId: string, status: string): Promise; + + } + + +} \ No newline at end of file diff --git a/app/sdks/flutter-dart/.dart_tool/package_config.json b/app/sdks/flutter-dart/.dart_tool/package_config.json deleted file mode 100644 index 79f1f8fa5a..0000000000 --- a/app/sdks/flutter-dart/.dart_tool/package_config.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "configVersion": 2, - "packages": [ - { - "name": "charcode", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.3", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "collection", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/collection-1.14.12", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "cookie_jar", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/cookie_jar-1.0.1", - "packageUri": "lib/", - "languageVersion": "1.20" - }, - { - "name": "dio", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio-3.0.9", - "packageUri": "lib/", - "languageVersion": "2.4" - }, - { - "name": "dio_cookie_manager", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio_cookie_manager-1.0.0", - "packageUri": "lib/", - "languageVersion": "2.4" - }, - { - "name": "http_parser", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.4", - "packageUri": "lib/", - "languageVersion": "2.3" - }, - { - "name": "meta", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8", - "packageUri": "lib/", - "languageVersion": "1.12" - }, - { - "name": "path", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/path-1.6.4", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "source_span", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/source_span-1.7.0", - "packageUri": "lib/", - "languageVersion": "2.6" - }, - { - "name": "string_scanner", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "term_glyph", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0", - "packageUri": "lib/", - "languageVersion": "1.8" - }, - { - "name": "typed_data", - "rootUri": "file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6", - "packageUri": "lib/", - "languageVersion": "2.0" - }, - { - "name": "appwrite", - "rootUri": "../", - "packageUri": "lib/", - "languageVersion": "2.6" - } - ], - "generated": "2020-04-10T18:56:11.631386Z", - "generator": "pub", - "generatorVersion": "2.7.2" -} diff --git a/app/sdks/flutter-dart/.packages b/app/sdks/flutter-dart/.packages deleted file mode 100644 index 7b07f11699..0000000000 --- a/app/sdks/flutter-dart/.packages +++ /dev/null @@ -1,14 +0,0 @@ -# Generated by pub on 2020-04-10 21:56:11.618646. -charcode:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.3/lib/ -collection:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/collection-1.14.12/lib/ -cookie_jar:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/cookie_jar-1.0.1/lib/ -dio:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio-3.0.9/lib/ -dio_cookie_manager:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/dio_cookie_manager-1.0.0/lib/ -http_parser:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.4/lib/ -meta:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/ -path:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/ -source_span:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/source_span-1.7.0/lib/ -string_scanner:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/ -term_glyph:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/ -typed_data:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/ -appwrite:lib/ diff --git a/app/sdks/flutter-dart/CHANGELOG.md b/app/sdks/flutter-dart/CHANGELOG.md deleted file mode 100644 index a7a936ee70..0000000000 --- a/app/sdks/flutter-dart/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -## 0.0.8 - -- Fixed compilation error in Client class -- Shorter description for package \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/client.dart b/app/sdks/flutter-dart/lib/client.dart deleted file mode 100644 index 943c51d18e..0000000000 --- a/app/sdks/flutter-dart/lib/client.dart +++ /dev/null @@ -1,84 +0,0 @@ -import 'dart:io'; - -import 'package:dio/adapter.dart'; -import 'package:dio/dio.dart'; -import 'package:dio_cookie_manager/dio_cookie_manager.dart'; -import 'package:cookie_jar/cookie_jar.dart'; - -import 'enums.dart'; - -class Client { - String endPoint; - Map headers; - bool selfSigned; - final Dio http; - - Client({this.endPoint: 'https://appwrite.io/v1', this.selfSigned: false, Dio http}) : this.http = http ?? Dio() { - this.headers = { - 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:dart:0.0.8', - }; - - assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'"); - this.http.options.baseUrl = this.endPoint; - this.http.options.validateStatus = (status) => status != 404; - this.http.interceptors.add(CookieManager(CookieJar())); - } - - /// Your project ID - Client setProject(value) { - addHeader('X-Appwrite-Project', value); - return this; - } - /// Your secret API key - Client setKey(value) { - addHeader('X-Appwrite-Key', value); - return this; - } - Client setLocale(value) { - addHeader('X-Appwrite-Locale', value); - return this; - } - Client setMode(value) { - addHeader('X-Appwrite-Mode', value); - return this; - } - Client setSelfSigned({bool status = true}) { - selfSigned = status; - return this; - } - - Client setEndpoint(String endPoint) { - this.endPoint = endPoint; - this.http.options.baseUrl = this.endPoint; - return this; - } - - Client addHeader(String key, String value) { - headers[key] = value; - - return this; - } - - Future call(HttpMethod method, {String path = '', Map headers = const {}, Map params = const {}}) { - if(this.selfSigned) { - // Allow self signed requests - (http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) { - client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; - return client; - }; - } - - // Origin is hardcoded for testing - Options options = Options( - headers: {...this.headers, ...headers, "Origin": "http://localhost"}, - method: method.name(), - ); - - if (method == HttpMethod.get) { - return http.get(path, queryParameters: params, options: options); - } else { - return http.request(path, data: params, options: options); - } - } -} \ No newline at end of file diff --git a/app/sdks/flutter-dart/lib/enums.dart b/app/sdks/flutter-dart/lib/enums.dart deleted file mode 100644 index 003073644f..0000000000 --- a/app/sdks/flutter-dart/lib/enums.dart +++ /dev/null @@ -1,19 +0,0 @@ -enum HttpMethod { - get, post, put, delete, patch -} - -extension HttpMethodString on HttpMethod { - String name(){ - return this.toString().split('.').last.toUpperCase(); - } -} - -enum OrderType { - asc, desc -} - -extension OrderTypeString on OrderType { - String name(){ - return this.toString().split('.').last.toUpperCase(); - } -} diff --git a/app/sdks/flutter-dart/lib/service.dart b/app/sdks/flutter-dart/lib/service.dart deleted file mode 100644 index 838047604a..0000000000 --- a/app/sdks/flutter-dart/lib/service.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'client.dart'; - -class Service { - final Client client; - - const Service(this.client); -} \ No newline at end of file diff --git a/app/sdks/flutter-dart/pubspec.lock b/app/sdks/flutter-dart/pubspec.lock deleted file mode 100644 index a1648b1374..0000000000 --- a/app/sdks/flutter-dart/pubspec.lock +++ /dev/null @@ -1,89 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.14.12" - cookie_jar: - dependency: "direct main" - description: - name: cookie_jar - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - dio: - dependency: "direct main" - description: - name: dio - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.9" - dio_cookie_manager: - dependency: "direct main" - description: - name: dio_cookie_manager - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.4" - meta: - dependency: "direct main" - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.8" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.4" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.7.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.6" -sdks: - dart: ">=2.6.0 <3.0.0" diff --git a/app/sdks/flutter-dart/pubspec.yaml b/app/sdks/flutter-dart/pubspec.yaml deleted file mode 100644 index 00139410e4..0000000000 --- a/app/sdks/flutter-dart/pubspec.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: appwrite -version: 0.0.8 -description: Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) -homepage: https://github.com/appwrite/sdk-for-dart -environment: - sdk: '>=2.6.0 <3.0.0' -dependencies: - meta: ^1.1.8 - dio: ^3.0.0 - cookie_jar: ^1.0.0 - dio_cookie_manager: ^1.0.0 diff --git a/app/sdks/server-go/README.md b/app/sdks/server-go/README.md index 7e5c39a721..3b46d51f79 100644 --- a/app/sdks/server-go/README.md +++ b/app/sdks/server-go/README.md @@ -1,11 +1,13 @@ # Appwrite SDK for Go ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.** -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-go/client.go b/app/sdks/server-go/client.go index 36fb2f28e5..bd21f5f347 100644 --- a/app/sdks/server-go/client.go +++ b/app/sdks/server-go/client.go @@ -45,10 +45,6 @@ func (clt *Client) SetLocale(value string) { clt.headers["X-Appwrite-Locale"] = value } -func (clt *Client) SetMode(value string) { - clt.headers["X-Appwrite-Mode"] = value -} - // Call an API using Client func (clt *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (map[string]interface{}, error) { if clt.client == nil { diff --git a/app/sdks/server-go/database.go b/app/sdks/server-go/database.go index 7e5f686bdb..d420d69fde 100644 --- a/app/sdks/server-go/database.go +++ b/app/sdks/server-go/database.go @@ -99,9 +99,9 @@ func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, O "filters": Filters, "offset": Offset, "limit": Limit, - "order-field": OrderField, - "order-type": OrderType, - "order-cast": OrderCast, + "orderField": OrderField, + "orderType": OrderType, + "orderCast": OrderCast, "search": Search, "first": First, "last": Last, @@ -165,3 +165,14 @@ func (srv *Database) DeleteDocument(CollectionId string, DocumentId string) (map return srv.client.Call("DELETE", path, nil, params) } + +// GetCollectionLogs +func (srv *Database) GetCollectionLogs(CollectionId string) (map[string]interface{}, error) { + r := strings.NewReplacer("{collectionId}", CollectionId) + path := r.Replace("/database/collections/{collectionId}/logs") + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} diff --git a/app/sdks/server-go/docs/examples/database/get-collection-logs.md b/app/sdks/server-go/docs/examples/database/get-collection-logs.md new file mode 100644 index 0000000000..4427295371 --- /dev/null +++ b/app/sdks/server-go/docs/examples/database/get-collection-logs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Database{ + client: &client + } + + var response, error := service.GetCollectionLogs("[COLLECTION_ID]") + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-anti-virus.md b/app/sdks/server-go/docs/examples/health/get-anti-virus.md new file mode 100644 index 0000000000..a6f363dde1 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-anti-virus.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetAntiVirus() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-cache.md b/app/sdks/server-go/docs/examples/health/get-cache.md new file mode 100644 index 0000000000..ce7b1c6f93 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-cache.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetCache() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-d-b.md b/app/sdks/server-go/docs/examples/health/get-d-b.md new file mode 100644 index 0000000000..6d86894417 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-d-b.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetDB() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-certificates.md b/app/sdks/server-go/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000000..9954551580 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueCertificates() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-functions.md b/app/sdks/server-go/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..5df453068b --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-functions.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueFunctions() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-logs.md b/app/sdks/server-go/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..0b6280a42a --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-logs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueLogs() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-tasks.md b/app/sdks/server-go/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..28d615dc2c --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueTasks() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-usage.md b/app/sdks/server-go/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..e9fe988aa2 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-usage.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueUsage() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..2f92835a12 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetQueueWebhooks() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md b/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md new file mode 100644 index 0000000000..8369b5ba07 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-storage-anti-virus.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetStorageAntiVirus() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-storage-local.md b/app/sdks/server-go/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..db0d5a5b21 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-storage-local.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetStorageLocal() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-time.md b/app/sdks/server-go/docs/examples/health/get-time.md new file mode 100644 index 0000000000..dd8486a484 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-time.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.GetTime() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get.md b/app/sdks/server-go/docs/examples/health/get.md new file mode 100644 index 0000000000..df1cb27243 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go" +) + +func main() { + var client := appwrite.Client{} + + client.SetProject("5df5acd0d48c2") // Your project ID + client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + + var service := appwrite.Health{ + client: &client + } + + var response, error := service.Get() + + if error != nil { + panic(error) + } + + fmt.Println(response) +} \ No newline at end of file diff --git a/app/sdks/server-go/health.go b/app/sdks/server-go/health.go new file mode 100644 index 0000000000..d3b6b3a926 --- /dev/null +++ b/app/sdks/server-go/health.go @@ -0,0 +1,153 @@ +package appwrite + +import ( +) + +// Health service +type Health struct { + client Client +} + +func NewHealth(clt Client) Health { + service := Health{ + client: clt, + } + + return service +} + +// Get check the Appwrite HTTP server is up and responsive. +func (srv *Health) Get() (map[string]interface{}, error) { + path := "/health" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetAntiVirus check the Appwrite Anti Virus server is up and connection is +// successful. +func (srv *Health) GetAntiVirus() (map[string]interface{}, error) { + path := "/health/anti-virus" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetCache check the Appwrite in-memory cache server is up and connection is +// successful. +func (srv *Health) GetCache() (map[string]interface{}, error) { + path := "/health/cache" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetDB check the Appwrite database server is up and connection is +// successful. +func (srv *Health) GetDB() (map[string]interface{}, error) { + path := "/health/db" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueCertificates get the number of certificates that are waiting to be +// issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite +// internal queue server. +func (srv *Health) GetQueueCertificates() (map[string]interface{}, error) { + path := "/health/queue/certificates" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueFunctions +func (srv *Health) GetQueueFunctions() (map[string]interface{}, error) { + path := "/health/queue/functions" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueLogs get the number of logs that are waiting to be processed in the +// Appwrite internal queue server. +func (srv *Health) GetQueueLogs() (map[string]interface{}, error) { + path := "/health/queue/logs" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueTasks get the number of tasks that are waiting to be processed in +// the Appwrite internal queue server. +func (srv *Health) GetQueueTasks() (map[string]interface{}, error) { + path := "/health/queue/tasks" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueUsage get the number of usage stats that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueUsage() (map[string]interface{}, error) { + path := "/health/queue/usage" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetQueueWebhooks get the number of webhooks that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueWebhooks() (map[string]interface{}, error) { + path := "/health/queue/webhooks" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetStorageLocal check the Appwrite local storage device is up and +// connection is successful. +func (srv *Health) GetStorageLocal() (map[string]interface{}, error) { + path := "/health/storage/local" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} + +// GetTime check the Appwrite server time is synced with Google remote NTP +// server. We use this technology to smoothly handle leap seconds with no +// disruptive events. The [Network Time +// Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is +// used by hundreds of millions of computers and devices to synchronize their +// clocks over the Internet. If your computer sets its own clock, it likely +// uses NTP. +func (srv *Health) GetTime() (map[string]interface{}, error) { + path := "/health/time" + + params := map[string]interface{}{ + } + + return srv.client.Call("GET", path, nil, params) +} diff --git a/app/sdks/server-go/users.go b/app/sdks/server-go/users.go index dc1b6be977..405b5a3209 100644 --- a/app/sdks/server-go/users.go +++ b/app/sdks/server-go/users.go @@ -115,11 +115,10 @@ func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error) // DeleteSession delete user sessions by its unique ID. func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions/:session") + r := strings.NewReplacer("{userId}", UserId, "{sessionId}", SessionId) + path := r.Replace("/users/{userId}/sessions/{sessionId}") params := map[string]interface{}{ - "sessionId": SessionId, } return srv.client.Call("DELETE", path, nil, params) diff --git a/app/sdks/server-java/CHANGELOG.md b/app/sdks/server-java/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-java/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-java/LICENSE b/app/sdks/server-java/LICENSE new file mode 100644 index 0000000000..fc7c051a91 --- /dev/null +++ b/app/sdks/server-java/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/sdks/server-java/README.md b/app/sdks/server-java/README.md new file mode 100644 index 0000000000..05e7d85945 --- /dev/null +++ b/app/sdks/server-java/README.md @@ -0,0 +1,43 @@ +# Appwrite SDK for Java + +![License](https://img.shields.io/github/license/appwrite/sdk-for-java.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) + +**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.** + +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Java SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) + + + +![Appwrite](https://appwrite.io/images/github.png) + +## Installation + +### Maven +Add this to your project's `pom.xml` file: + +```xml + + + com.squareup.okhttp3 + appwrite + 0.0.1 + + +``` + +You can install packages from the command line: + +```bash +mvn install appwrite +``` + +## Contribution + +This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request. + +## License + +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file diff --git a/app/sdks/server-java/pom.xml b/app/sdks/server-java/pom.xml new file mode 100644 index 0000000000..6d3098a6ea --- /dev/null +++ b/app/sdks/server-java/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + + + appwrite + 0.0.1 + + Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API + https://appwrite.io + + + 1.9 + 1.9 + + + + + com.squareup.okhttp3 + okhttp + 4.5.0 + + + com.google.code.gson + gson + 2.8.2 + + + + org.junit.jupiter + junit-jupiter-api + 5.6.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.6.2 + test + + + + + + + maven-surefire-plugin + 2.22.2 + + + maven-failsafe-plugin + 2.22.2 + + + + \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/Client.java b/app/sdks/server-java/src/main/java/Client.java new file mode 100644 index 0000000000..51c52aebb5 --- /dev/null +++ b/app/sdks/server-java/src/main/java/Client.java @@ -0,0 +1,143 @@ +package ; + +import com.google.gson.Gson; +import okhttp3.Call; +import okhttp3.CookieJar; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Client { + private final OkHttpClient http; + private final Map headers; + private final Map config; + private String endPoint; + private boolean selfSigned; + private CookieJar cookieJar = CookieJar.NO_COOKIES; + + public Client() { + this("https://appwrite.io/v1", false, new OkHttpClient()); + } + + public Client(String endPoint, boolean selfSigned, OkHttpClient http) { + this.endPoint = endPoint; + this.selfSigned = selfSigned; + this.headers = new HashMap<>(Map.ofEntries( + entry("content-type", "application/json"), + entry("x-sdk-version", "appwrite:java:0.0.1") + )); + this.config = new HashMap<>(); + this.http = http.newBuilder() + .cookieJar(cookieJar) + .build(); + } + + public String getEndPoint(){ + return endPoint; + } + + public Map getConfig(){ + return config; + } + +// private Future getCookiePath() { +// final directory = getApplicationDocumentsDirectory(); +// final path = directory.path; +// final Directory dir = new Directory("$path/cookies"); +// dir.create(); +// return dir; +// } + + /// Your project ID + public Client setProject(String value) { + config.put("project", value); + addHeader("X-Appwrite-Project", value); + return this; + } + + /// Your secret API key + public Client setKey(String value) { + config.put("key", value); + addHeader("X-Appwrite-Key", value); + return this; + } + + public Client setLocale(String value) { + config.put("locale", value); + addHeader("X-Appwrite-Locale", value); + return this; + } + + public Client setSelfSigned(boolean status) { + selfSigned = status; + return this; + } + + public Client setEndpoint(String endPoint) { + this.endPoint = endPoint; + return this; + } + + public Client addHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public Call call(String method, String path, Map headers, Map params) { + if(selfSigned) { + // Allow self signed requests + + } + + Headers requestHeaders = Headers.of(this.headers).newBuilder() + .addAll(Headers.of(headers)) + .build(); + + HttpUrl.Builder httpBuilder = HttpUrl.get(endPoint + path).newBuilder(); + if("GET".equals(method)) { + params.forEach((k, v) -> { + if(v instanceof List){ + httpBuilder.addQueryParameter(k+"[]", v.toString()); + }else{ + httpBuilder.addQueryParameter(k, v.toString()); + } + }); + Request request = new Request.Builder() + .url(httpBuilder.build()) + .headers(requestHeaders) + .get() + .build(); + + return http.newCall(request); + } + + RequestBody body; + if("multipart/form-data".equals(headers.get("content-type"))) { + FormBody.Builder builder = new FormBody.Builder(); + params.forEach((k, v) -> builder.add(k, v.toString())); + body = builder.build(); + } else { + Gson gson = new Gson(); + String json = gson.toJson(params); + body = RequestBody.create(json, MediaType.get("application/json")); + } + + Request request = new Request.Builder() + .url(httpBuilder.build()) + .headers(requestHeaders) + .method(method, body) + .build(); + + return http.newCall(request); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/enums/OrderType.java b/app/sdks/server-java/src/main/java/enums/OrderType.java new file mode 100644 index 0000000000..d4a73a3886 --- /dev/null +++ b/app/sdks/server-java/src/main/java/enums/OrderType.java @@ -0,0 +1,6 @@ +package .enums; + +public enum OrderType { + ASC, DESC +} + diff --git a/app/sdks/server-java/src/main/java/services/Avatars.java b/app/sdks/server-java/src/main/java/services/Avatars.java new file mode 100644 index 0000000000..3c0bb4e6c8 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Avatars.java @@ -0,0 +1,164 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Avatars extends Service { + public Avatars(Client client){ + super(client); + } + + /// Get Browser Icon + /* + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user + * /account/sessions endpoint. Use width, height and quality arguments to + * change the output settings. + */ + public Call getBrowser(String code, int width, int height, int quality) { + final String path = "/avatars/browsers/{code}".replace("{code}", code); + + final Map params = Map.ofEntries( + entry("width", width), + entry("height", height), + entry("quality", quality) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Credit Card Icon + /* + * Need to display your users with your billing method or their payment + * methods? The credit card endpoint will return you the icon of the credit + * card provider you need. Use width, height and quality arguments to change + * the output settings. + */ + public Call getCreditCard(String code, int width, int height, int quality) { + final String path = "/avatars/credit-cards/{code}".replace("{code}", code); + + final Map params = Map.ofEntries( + entry("width", width), + entry("height", height), + entry("quality", quality) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Favicon + /* + * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + * website URL. + */ + public Call getFavicon(String url) { + final String path = "/avatars/favicon"; + + final Map params = Map.ofEntries( + entry("url", url) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Country Flag + /* + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. + */ + public Call getFlag(String code, int width, int height, int quality) { + final String path = "/avatars/flags/{code}".replace("{code}", code); + + final Map params = Map.ofEntries( + entry("width", width), + entry("height", height), + entry("quality", quality) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Image from URL + /* + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + */ + public Call getImage(String url, int width, int height) { + final String path = "/avatars/image"; + + final Map params = Map.ofEntries( + entry("url", url), + entry("width", width), + entry("height", height) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get QR Code + /* + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + */ + public Call getQR(String text, int size, int margin, int download) { + final String path = "/avatars/qr"; + + final Map params = Map.ofEntries( + entry("text", text), + entry("size", size), + entry("margin", margin), + entry("download", download) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Database.java b/app/sdks/server-java/src/main/java/services/Database.java new file mode 100644 index 0000000000..84161de9fc --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Database.java @@ -0,0 +1,264 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Database extends Service { + public Database(Client client){ + super(client); + } + + /// List Collections + /* + * Get a list of all the user collections. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project collections. [Learn more about different API + * modes](/docs/admin). + */ + public Call listCollections(String search, int limit, int offset, OrderType orderType) { + final String path = "/database/collections"; + + final Map params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create Collection + /* + * Create a new Collection. + */ + public Call createCollection(String name, List read, List write, List rules) { + final String path = "/database/collections"; + + final Map params = Map.ofEntries( + entry("name", name), + entry("read", read), + entry("write", write), + entry("rules", rules) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("POST", path, headers, params); + } + + /// Get Collection + /* + * Get collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + */ + public Call getCollection(String collectionId) { + final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Update Collection + /* + * Update collection by its unique ID. + */ + public Call updateCollection(String collectionId, String name, List read, List write, List rules) { + final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + entry("name", name), + entry("read", read), + entry("write", write), + entry("rules", rules) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PUT", path, headers, params); + } + + /// Delete Collection + /* + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + */ + public Call deleteCollection(String collectionId) { + final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// List Documents + /* + * Get a list of all the user documents. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project documents. [Learn more about different API + * modes](/docs/admin). + */ + public Call listDocuments(String collectionId, List filters, int offset, int limit, String orderField, OrderType orderType, String orderCast, String search, int first, int last) { + final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + entry("filters", filters), + entry("offset", offset), + entry("limit", limit), + entry("orderField", orderField), + entry("orderType", orderType.name()), + entry("orderCast", orderCast), + entry("search", search), + entry("first", first), + entry("last", last) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create Document + /* + * Create a new Document. + */ + public Call createDocument(String collectionId, Object data, List read, List write, String parentDocument, String parentProperty, String parentPropertyType) { + final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + entry("data", data), + entry("read", read), + entry("write", write), + entry("parentDocument", parentDocument), + entry("parentProperty", parentProperty), + entry("parentPropertyType", parentPropertyType) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("POST", path, headers, params); + } + + /// Get Document + /* + * Get document by its unique ID. This endpoint response returns a JSON object + * with the document data. + */ + public Call getDocument(String collectionId, String documentId) { + final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Update Document + public Call updateDocument(String collectionId, String documentId, Object data, List read, List write) { + final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); + + final Map params = Map.ofEntries( + entry("data", data), + entry("read", read), + entry("write", write) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PATCH", path, headers, params); + } + + /// Delete Document + /* + * Delete document by its unique ID. This endpoint deletes only the parent + * documents, his attributes and relations to other documents. Child documents + * **will not** be deleted. + */ + public Call deleteDocument(String collectionId, String documentId) { + final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// Get Collection Logs + public Call getCollectionLogs(String collectionId) { + final String path = "/database/collections/{collectionId}/logs".replace("{collectionId}", collectionId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Health.java b/app/sdks/server-java/src/main/java/services/Health.java new file mode 100644 index 0000000000..08e23433d1 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Health.java @@ -0,0 +1,258 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Health extends Service { + public Health(Client client){ + super(client); + } + + /// Get HTTP + /* + * Check the Appwrite HTTP server is up and responsive. + */ + public Call get() { + final String path = "/health"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Anti virus + /* + * Check the Appwrite Anti Virus server is up and connection is successful. + */ + public Call getAntiVirus() { + final String path = "/health/anti-virus"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Cache + /* + * Check the Appwrite in-memory cache server is up and connection is + * successful. + */ + public Call getCache() { + final String path = "/health/cache"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get DB + /* + * Check the Appwrite database server is up and connection is successful. + */ + public Call getDB() { + final String path = "/health/db"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Certificate Queue + /* + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + */ + public Call getQueueCertificates() { + final String path = "/health/queue/certificates"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Functions Queue + public Call getQueueFunctions() { + final String path = "/health/queue/functions"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Logs Queue + /* + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + */ + public Call getQueueLogs() { + final String path = "/health/queue/logs"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Tasks Queue + /* + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + */ + public Call getQueueTasks() { + final String path = "/health/queue/tasks"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Usage Queue + /* + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + */ + public Call getQueueUsage() { + final String path = "/health/queue/usage"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Webhooks Queue + /* + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + */ + public Call getQueueWebhooks() { + final String path = "/health/queue/webhooks"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Local Storage + /* + * Check the Appwrite local storage device is up and connection is successful. + */ + public Call getStorageLocal() { + final String path = "/health/storage/local"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get Time + /* + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + */ + public Call getTime() { + final String path = "/health/time"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Locale.java b/app/sdks/server-java/src/main/java/services/Locale.java new file mode 100644 index 0000000000..695b04a679 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Locale.java @@ -0,0 +1,145 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Locale extends Service { + public Locale(Client client){ + super(client); + } + + /// Get User Locale + /* + * Get the current user location based on IP. Returns an object with user + * country code, country name, continent name, continent code, ip address and + * suggested currency. You can use the locale header to get the data in a + * supported language. + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) + */ + public Call get() { + final String path = "/locale"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// List Continents + /* + * List of all continents. You can use the locale header to get the data in a + * supported language. + */ + public Call getContinents() { + final String path = "/locale/continents"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// List Countries + /* + * List of all countries. You can use the locale header to get the data in a + * supported language. + */ + public Call getCountries() { + final String path = "/locale/countries"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// List EU Countries + /* + * List of all countries that are currently members of the EU. You can use the + * locale header to get the data in a supported language. + */ + public Call getCountriesEU() { + final String path = "/locale/countries/eu"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// List Countries Phone Codes + /* + * List of all countries phone codes. You can use the locale header to get the + * data in a supported language. + */ + public Call getCountriesPhones() { + final String path = "/locale/countries/phones"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// List Currencies + /* + * List of all currencies, including currency symol, name, plural, and decimal + * digits for all major and minor currencies. You can use the locale header to + * get the data in a supported language. + */ + public Call getCurrencies() { + final String path = "/locale/currencies"; + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Service.java b/app/sdks/server-java/src/main/java/services/Service.java new file mode 100644 index 0000000000..477b0ba724 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Service.java @@ -0,0 +1,11 @@ +package .services; + +import .Client; + +abstract class Service { + final Client client; + + Service(Client client) { + this.client = client; + } +} diff --git a/app/sdks/server-java/src/main/java/services/Storage.java b/app/sdks/server-java/src/main/java/services/Storage.java new file mode 100644 index 0000000000..0233868d0d --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Storage.java @@ -0,0 +1,204 @@ +package .services; + + + +import okhttp3.Call; +import okhttp3.HttpUrl; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Storage extends Service { + public Storage(Client client){ + super(client); + } + + /// List Files + /* + * Get a list of all the user files. You can use the query params to filter + * your results. On admin mode, this endpoint will return a list of all of the + * project files. [Learn more about different API modes](/docs/admin). + */ + public Call listFiles(String search, int limit, int offset, OrderType orderType) { + final String path = "/storage/files"; + + final Map params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create File + /* + * Create a new file. The user who creates the file will automatically be + * assigned to read and write access unless he has passed custom values for + * read and write arguments. + */ + public Call createFile(File file, List read, List write) { + final String path = "/storage/files"; + + final Map params = Map.ofEntries( + entry("file", file), + entry("read", read), + entry("write", write) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "multipart/form-data") + ); + + return client.call("POST", path, headers, params); + } + + /// Get File + /* + * Get file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + */ + public Call getFile(String fileId) { + final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Update File + /* + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + */ + public Call updateFile(String fileId, List read, List write) { + final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + entry("read", read), + entry("write", write) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PUT", path, headers, params); + } + + /// Delete File + /* + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + */ + public Call deleteFile(String fileId) { + final String path = "/storage/files/{fileId}".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// Get File for Download + /* + * Get file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + */ + public String getFileDownload(String fileId) { + final String path = "/storage/files/{fileId}/download".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + entry("project", client.getConfig().get("project")), + entry("key", client.getConfig().get("key")) + ); + + + + HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); + params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); + + return httpBuilder.build().toString(); + } + + /// Get File Preview + /* + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. + */ + public String getFilePreview(String fileId, int width, int height, int quality, String background, String output) { + final String path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + entry("width", width), + entry("height", height), + entry("quality", quality), + entry("background", background), + entry("output", output), + entry("project", client.getConfig().get("project")), + entry("key", client.getConfig().get("key")) + ); + + + + HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); + params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); + + return httpBuilder.build().toString(); + } + + /// Get File for View + /* + * Get file content by its unique ID. This endpoint is similar to the download + * method but returns with no 'Content-Disposition: attachment' header. + */ + public String getFileView(String fileId, String as) { + final String path = "/storage/files/{fileId}/view".replace("{fileId}", fileId); + + final Map params = Map.ofEntries( + entry("as", as), + entry("project", client.getConfig().get("project")), + entry("key", client.getConfig().get("key")) + ); + + + + HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path); + params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString())); + + return httpBuilder.build().toString(); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Teams.java b/app/sdks/server-java/src/main/java/services/Teams.java new file mode 100644 index 0000000000..46cff57f8c --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Teams.java @@ -0,0 +1,206 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Teams extends Service { + public Teams(Client client){ + super(client); + } + + /// List Teams + /* + * Get a list of all the current user teams. You can use the query params to + * filter your results. On admin mode, this endpoint will return a list of all + * of the project teams. [Learn more about different API modes](/docs/admin). + */ + public Call list(String search, int limit, int offset, OrderType orderType) { + final String path = "/teams"; + + final Map params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create Team + /* + * Create a new team. The user who creates the team will automatically be + * assigned as the owner of the team. The team owner can invite new members, + * who will be able add new owners and update or delete the team from your + * project. + */ + public Call create(String name, List roles) { + final String path = "/teams"; + + final Map params = Map.ofEntries( + entry("name", name), + entry("roles", roles) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("POST", path, headers, params); + } + + /// Get Team + /* + * Get team by its unique ID. All team members have read access for this + * resource. + */ + public Call get(String teamId) { + final String path = "/teams/{teamId}".replace("{teamId}", teamId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Update Team + /* + * Update team by its unique ID. Only team owners have write access for this + * resource. + */ + public Call update(String teamId, String name) { + final String path = "/teams/{teamId}".replace("{teamId}", teamId); + + final Map params = Map.ofEntries( + entry("name", name) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PUT", path, headers, params); + } + + /// Delete Team + /* + * Delete team by its unique ID. Only team owners have write access for this + * resource. + */ + public Call delete(String teamId) { + final String path = "/teams/{teamId}".replace("{teamId}", teamId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// Get Team Memberships + /* + * Get team members by the team unique ID. All team members have read access + * for this list of resources. + */ + public Call getMemberships(String teamId) { + final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create Team Membership + /* + * Use this endpoint to invite a new member to join your team. An email with a + * link to join the team will be sent to the new member email address if the + * member doesn't exist in the project it will be created automatically. + * + * Use the 'URL' parameter to redirect the user from the invitation email back + * to your app. When the user is redirected, use the [Update Team Membership + * Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to + * accept the invitation to the team. + * + * Please note that in order to avoid a [Redirect + * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * the only valid redirect URL's are the once from domains you have set when + * added your platforms in the console interface. + */ + public Call createMembership(String teamId, String email, List roles, String url, String name) { + final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId); + + final Map params = Map.ofEntries( + entry("email", email), + entry("name", name), + entry("roles", roles), + entry("url", url) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("POST", path, headers, params); + } + + /// Delete Team Membership + /* + * This endpoint allows a user to leave a team or for a team owner to delete + * the membership of any other team member. You can also use this endpoint to + * delete a user membership even if he didn't accept it. + */ + public Call deleteMembership(String teamId, String inviteId) { + final String path = "/teams/{teamId}/memberships/{inviteId}".replace("{teamId}", teamId).replace("{inviteId}", inviteId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Users.java b/app/sdks/server-java/src/main/java/services/Users.java new file mode 100644 index 0000000000..921a7c1296 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Users.java @@ -0,0 +1,221 @@ +package .services; + + + +import okhttp3.Call; +import .Client; +import .enums.OrderType; + +import java.io.File; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import static java.util.Map.entry; + +public class Users extends Service { + public Users(Client client){ + super(client); + } + + /// List Users + /* + * Get a list of all the project users. You can use the query params to filter + * your results. + */ + public Call list(String search, int limit, int offset, OrderType orderType) { + final String path = "/users"; + + final Map params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Create User + /* + * Create a new user. + */ + public Call create(String email, String password, String name) { + final String path = "/users"; + + final Map params = Map.ofEntries( + entry("email", email), + entry("password", password), + entry("name", name) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("POST", path, headers, params); + } + + /// Get User + /* + * Get user by its unique ID. + */ + public Call get(String userId) { + final String path = "/users/{userId}".replace("{userId}", userId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get User Logs + /* + * Get user activity logs list by its unique ID. + */ + public Call getLogs(String userId) { + final String path = "/users/{userId}/logs".replace("{userId}", userId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Get User Preferences + /* + * Get user preferences by its unique ID. + */ + public Call getPrefs(String userId) { + final String path = "/users/{userId}/prefs".replace("{userId}", userId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Update User Preferences + /* + * Update user preferences by its unique ID. You can pass only the specific + * settings you wish to update. + */ + public Call updatePrefs(String userId, Object prefs) { + final String path = "/users/{userId}/prefs".replace("{userId}", userId); + + final Map params = Map.ofEntries( + entry("prefs", prefs) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PATCH", path, headers, params); + } + + /// Get User Sessions + /* + * Get user sessions list by its unique ID. + */ + public Call getSessions(String userId) { + final String path = "/users/{userId}/sessions".replace("{userId}", userId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("GET", path, headers, params); + } + + /// Delete User Sessions + /* + * Delete all user sessions by its unique ID. + */ + public Call deleteSessions(String userId) { + final String path = "/users/{userId}/sessions".replace("{userId}", userId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// Delete User Session + /* + * Delete user sessions by its unique ID. + */ + public Call deleteSession(String userId, String sessionId) { + final String path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId); + + final Map params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } + + /// Update User Status + /* + * Update user status by its unique ID. + */ + public Call updateStatus(String userId, String status) { + final String path = "/users/{userId}/status".replace("{userId}", userId); + + final Map params = Map.ofEntries( + entry("status", status) + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("PATCH", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-nodejs/README.md b/app/sdks/server-nodejs/README.md index 76ba6d4de2..a6df1832a3 100644 --- a/app/sdks/server-nodejs/README.md +++ b/app/sdks/server-nodejs/README.md @@ -1,9 +1,11 @@ -# Appwrite SDK for NodeJS +# Appwrite Node.js SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Node.js SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-nodejs/docs/examples/database/get-collection-logs.md b/app/sdks/server-nodejs/docs/examples/database/get-collection-logs.md new file mode 100644 index 0000000000..580ca8fc3a --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/database/get-collection-logs.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let database = new sdk.Database(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = database.getCollectionLogs('[COLLECTION_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-anti-virus.md b/app/sdks/server-nodejs/docs/examples/health/get-anti-virus.md new file mode 100644 index 0000000000..8d09508218 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-anti-virus.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getAntiVirus(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-cache.md b/app/sdks/server-nodejs/docs/examples/health/get-cache.md new file mode 100644 index 0000000000..6b49af6ffd --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-cache.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getCache(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-d-b.md b/app/sdks/server-nodejs/docs/examples/health/get-d-b.md new file mode 100644 index 0000000000..273ad1ad74 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-d-b.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getDB(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-certificates.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000000..23494f189b --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueCertificates(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..a799c29805 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueFunctions(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-logs.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..b4423c5c96 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-logs.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueLogs(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-tasks.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..f581d8c1ed --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueTasks(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-usage.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..e8774856ce --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-usage.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueUsage(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..24333e8ec4 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getQueueWebhooks(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-storage-anti-virus.md b/app/sdks/server-nodejs/docs/examples/health/get-storage-anti-virus.md new file mode 100644 index 0000000000..70c3850375 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-storage-anti-virus.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getStorageAntiVirus(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-storage-local.md b/app/sdks/server-nodejs/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..2323be7d9d --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-storage-local.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getStorageLocal(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-time.md b/app/sdks/server-nodejs/docs/examples/health/get-time.md new file mode 100644 index 0000000000..c3d2a369d4 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-time.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.getTime(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get.md b/app/sdks/server-nodejs/docs/examples/health/get.md new file mode 100644 index 0000000000..8b504497ef --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get.md @@ -0,0 +1,19 @@ +const sdk = require('node-appwrite'); + +// Init SDK +let client = new sdk.Client(); + +let health = new sdk.Health(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = health.get(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/index.js b/app/sdks/server-nodejs/index.js index d9e8b5a391..f5259f59dc 100644 --- a/app/sdks/server-nodejs/index.js +++ b/app/sdks/server-nodejs/index.js @@ -1,6 +1,7 @@ const Client = require('./lib/client.js'); const Avatars = require('./lib/services/avatars.js'); const Database = require('./lib/services/database.js'); +const Health = require('./lib/services/health.js'); const Locale = require('./lib/services/locale.js'); const Storage = require('./lib/services/storage.js'); const Teams = require('./lib/services/teams.js'); @@ -10,6 +11,7 @@ module.exports = { Client, Avatars, Database, + Health, Locale, Storage, Teams, diff --git a/app/sdks/server-nodejs/lib/client.js b/app/sdks/server-nodejs/lib/client.js index 6fc349ea7a..024c4f1c5b 100644 --- a/app/sdks/server-nodejs/lib/client.js +++ b/app/sdks/server-nodejs/lib/client.js @@ -55,19 +55,6 @@ class Client { return this; } - /** - * Set Mode - * - * @param string value - * - * @return self - */ - setMode(value) { - this.addHeader('X-Appwrite-Mode', value); - - return this; - } - /*** * @param bool status * @return this diff --git a/app/sdks/server-nodejs/lib/services/database.js b/app/sdks/server-nodejs/lib/services/database.js index b72a3938ca..ce1c09e391 100644 --- a/app/sdks/server-nodejs/lib/services/database.js +++ b/app/sdks/server-nodejs/lib/services/database.js @@ -37,9 +37,9 @@ class Database extends Service { * Create a new Collection. * * @param string name - * @param array read - * @param array write - * @param array rules + * @param string[] read + * @param string[] write + * @param string[] rules * @throws Exception * @return {} */ @@ -84,9 +84,9 @@ class Database extends Service { * * @param string collectionId * @param string name - * @param array read - * @param array write - * @param array rules + * @param string[] read + * @param string[] write + * @param string[] rules * @throws Exception * @return {} */ @@ -133,7 +133,7 @@ class Database extends Service { * modes](/docs/admin). * * @param string collectionId - * @param array filters + * @param string[] filters * @param number offset * @param number limit * @param string orderField @@ -155,9 +155,9 @@ class Database extends Service { 'filters': filters, 'offset': offset, 'limit': limit, - 'order-field': orderField, - 'order-type': orderType, - 'order-cast': orderCast, + 'orderField': orderField, + 'orderType': orderType, + 'orderCast': orderCast, 'search': search, 'first': first, 'last': last @@ -171,8 +171,8 @@ class Database extends Service { * * @param string collectionId * @param object data - * @param array read - * @param array write + * @param string[] read + * @param string[] write * @param string parentDocument * @param string parentProperty * @param string parentPropertyType @@ -222,8 +222,8 @@ class Database extends Service { * @param string collectionId * @param string documentId * @param object data - * @param array read - * @param array write + * @param string[] read + * @param string[] write * @throws Exception * @return {} */ @@ -261,6 +261,23 @@ class Database extends Service { { }); } + + /** + * Get Collection Logs + * + * @param string collectionId + * @throws Exception + * @return {} + */ + async getCollectionLogs(collectionId) { + let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } } module.exports = Database; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/health.js b/app/sdks/server-nodejs/lib/services/health.js new file mode 100644 index 0000000000..a0aed052ce --- /dev/null +++ b/app/sdks/server-nodejs/lib/services/health.js @@ -0,0 +1,233 @@ +const Service = require('../service.js'); + +class Health extends Service { + + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @throws Exception + * @return {} + */ + async get() { + let path = '/health'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @throws Exception + * @return {} + */ + async getAntiVirus() { + let path = '/health/anti-virus'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @throws Exception + * @return {} + */ + async getCache() { + let path = '/health/cache'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @throws Exception + * @return {} + */ + async getDB() { + let path = '/health/db'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @throws Exception + * @return {} + */ + async getQueueCertificates() { + let path = '/health/queue/certificates'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Functions Queue + * + * @throws Exception + * @return {} + */ + async getQueueFunctions() { + let path = '/health/queue/functions'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return {} + */ + async getQueueLogs() { + let path = '/health/queue/logs'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return {} + */ + async getQueueTasks() { + let path = '/health/queue/tasks'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @throws Exception + * @return {} + */ + async getQueueUsage() { + let path = '/health/queue/usage'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return {} + */ + async getQueueWebhooks() { + let path = '/health/queue/webhooks'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws Exception + * @return {} + */ + async getStorageLocal() { + let path = '/health/storage/local'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @throws Exception + * @return {} + */ + async getTime() { + let path = '/health/time'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } +} + +module.exports = Health; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/locale.js b/app/sdks/server-nodejs/lib/services/locale.js index 1a89ba7dd9..bc1efa4688 100644 --- a/app/sdks/server-nodejs/lib/services/locale.js +++ b/app/sdks/server-nodejs/lib/services/locale.js @@ -26,7 +26,7 @@ class Locale extends Service { } /** - * List Countries + * List Continents * * List of all continents. You can use the locale header to get the data in a * supported language. diff --git a/app/sdks/server-nodejs/lib/services/storage.js b/app/sdks/server-nodejs/lib/services/storage.js index 7237ccfc6f..2b670db31a 100644 --- a/app/sdks/server-nodejs/lib/services/storage.js +++ b/app/sdks/server-nodejs/lib/services/storage.js @@ -38,8 +38,8 @@ class Storage extends Service { * read and write arguments. * * @param File file - * @param array read - * @param array write + * @param string[] read + * @param string[] write * @throws Exception * @return {} */ @@ -83,8 +83,8 @@ class Storage extends Service { * to update this resource. * * @param string fileId - * @param array read - * @param array write + * @param string[] read + * @param string[] write * @throws Exception * @return {} */ diff --git a/app/sdks/server-nodejs/lib/services/teams.js b/app/sdks/server-nodejs/lib/services/teams.js index ed9924bbee..a17dd50aa3 100644 --- a/app/sdks/server-nodejs/lib/services/teams.js +++ b/app/sdks/server-nodejs/lib/services/teams.js @@ -39,7 +39,7 @@ class Teams extends Service { * project. * * @param string name - * @param array roles + * @param string[] roles * @throws Exception * @return {} */ @@ -156,7 +156,7 @@ class Teams extends Service { * * @param string teamId * @param string email - * @param array roles + * @param string[] roles * @param string url * @param string name * @throws Exception diff --git a/app/sdks/server-nodejs/lib/services/users.js b/app/sdks/server-nodejs/lib/services/users.js index abcdd4ed9f..2292fb2664 100644 --- a/app/sdks/server-nodejs/lib/services/users.js +++ b/app/sdks/server-nodejs/lib/services/users.js @@ -181,13 +181,12 @@ class Users extends Service { * @return {} */ async deleteSession(userId, sessionId) { - let path = '/users/{userId}/sessions/:session'.replace(new RegExp('{userId}', 'g'), userId); + let path = '/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}', 'g'), userId).replace(new RegExp('{sessionId}', 'g'), sessionId); return await this.client.call('delete', path, { 'content-type': 'application/json', }, { - 'sessionId': sessionId }); } diff --git a/app/sdks/server-nodejs/package.json b/app/sdks/server-nodejs/package.json index a61515bf29..f55aed2719 100644 --- a/app/sdks/server-nodejs/package.json +++ b/app/sdks/server-nodejs/package.json @@ -1,7 +1,7 @@ { "name": "node-appwrite", "homepage": "https://appwrite.io/support", - "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", + "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", "version": "1.0.32", "license": "BSD-3-Clause", "main": "index.js", diff --git a/app/sdks/server-php/README.md b/app/sdks/server-php/README.md index 9470cf512d..a66297ba59 100644 --- a/app/sdks/server-php/README.md +++ b/app/sdks/server-php/README.md @@ -1,9 +1,11 @@ -# Appwrite SDK for PHP +# Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-php/composer.json b/app/sdks/server-php/composer.json index c7e4692c95..64d2e1746f 100644 --- a/app/sdks/server-php/composer.json +++ b/app/sdks/server-php/composer.json @@ -1,11 +1,13 @@ { "name": "appwrite/appwrite", - "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", + "description": "Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", "type": "library", "license": "BSD-3-Clause", "support": { "url": "https://appwrite.io/support", - "email": "team@appwrite.io" + "email": "team@localhost.test" }, "autoload": { "psr-4": { diff --git a/app/sdks/server-php/docs/avatars.md b/app/sdks/server-php/docs/avatars.md index cf506e0db1..9fa1ee61f1 100644 --- a/app/sdks/server-php/docs/avatars.md +++ b/app/sdks/server-php/docs/avatars.md @@ -95,6 +95,6 @@ GET https://appwrite.io/v1/avatars/qr | --- | --- | --- | --- | | text | string | **Required** Plain text to be converted to QR code image. | | | size | integer | QR code size. Pass an integer between 0 to 1000. Defaults to 400. | 400 | -| margin | integer | Margin From Edge. Pass an integer between 0 to 10. Defaults to 1. | 1 | +| margin | integer | Margin from edge. Pass an integer between 0 to 10. Defaults to 1. | 1 | | download | integer | Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. | 0 | diff --git a/app/sdks/server-php/docs/database.md b/app/sdks/server-php/docs/database.md index 0f996a6126..f192a92fc8 100644 --- a/app/sdks/server-php/docs/database.md +++ b/app/sdks/server-php/docs/database.md @@ -96,12 +96,12 @@ GET https://appwrite.io/v1/database/collections/{collectionId}/documents | filters | array | Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. | [] | | offset | integer | Offset value. Use this value to manage pagination. | 0 | | limit | integer | Maximum number of documents to return in response. Use this value to manage pagination. | 50 | -| order-field | string | Document field that results will be sorted by. | $id | -| order-type | string | Order direction. Possible values are DESC for descending order, or ASC for ascending order. | ASC | -| order-cast | string | Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. | string | +| orderField | string | Document field that results will be sorted by. | $id | +| orderType | string | Order direction. Possible values are DESC for descending order, or ASC for ascending order. | ASC | +| orderCast | string | Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. | string | | search | string | Search query. Enter any free text search. The database will try to find a match against all document attributes and children. | | -| first | integer | Return only first document. Pass 1 for true or 0 for false. The default value is 0. | 0 | -| last | integer | Return only last document. Pass 1 for true or 0 for false. The default value is 0. | 0 | +| first | integer | Return only the first document. Pass 1 for true or 0 for false. The default value is 0. | 0 | +| last | integer | Return only the last document. Pass 1 for true or 0 for false. The default value is 0. | 0 | ## Create Document @@ -169,3 +169,15 @@ DELETE https://appwrite.io/v1/database/collections/{collectionId}/documents/{doc | collectionId | string | **Required** Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection). | | | documentId | string | **Required** Document unique ID. | | +## Get Collection Logs + +```http request +GET https://appwrite.io/v1/database/collections/{collectionId}/logs +``` + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| collectionId | string | **Required** Collection unique ID. | | + diff --git a/app/sdks/server-php/docs/examples/database/get-collection-logs.md b/app/sdks/server-php/docs/examples/database/get-collection-logs.md new file mode 100644 index 0000000000..bcb8374ce2 --- /dev/null +++ b/app/sdks/server-php/docs/examples/database/get-collection-logs.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$database = new Database($client); + +$result = $database->getCollectionLogs('[COLLECTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-anti-virus.md b/app/sdks/server-php/docs/examples/health/get-anti-virus.md new file mode 100644 index 0000000000..a1e5b66a9b --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-anti-virus.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getAntiVirus(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-cache.md b/app/sdks/server-php/docs/examples/health/get-cache.md new file mode 100644 index 0000000000..4599dea724 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-cache.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getCache(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-d-b.md b/app/sdks/server-php/docs/examples/health/get-d-b.md new file mode 100644 index 0000000000..2626ebe356 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-d-b.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getDB(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-certificates.md b/app/sdks/server-php/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000000..e6805e0ed7 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueCertificates(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-functions.md b/app/sdks/server-php/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..b8df530241 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-functions.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueFunctions(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-logs.md b/app/sdks/server-php/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..70d4b7ee18 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-logs.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueLogs(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-tasks.md b/app/sdks/server-php/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..a63faabfc1 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueTasks(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-usage.md b/app/sdks/server-php/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..a48385aea5 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-usage.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueUsage(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-php/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..e8433ee986 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueWebhooks(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-storage-anti-virus.md b/app/sdks/server-php/docs/examples/health/get-storage-anti-virus.md new file mode 100644 index 0000000000..0d1958e4f2 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-storage-anti-virus.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getStorageAntiVirus(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-storage-local.md b/app/sdks/server-php/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..b5c751bfbc --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-storage-local.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getStorageLocal(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-time.md b/app/sdks/server-php/docs/examples/health/get-time.md new file mode 100644 index 0000000000..04acfa3be5 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-time.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getTime(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get.md b/app/sdks/server-php/docs/examples/health/get.md new file mode 100644 index 0000000000..76c8e0b46a --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->get(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/health.md b/app/sdks/server-php/docs/health.md new file mode 100644 index 0000000000..38b814b633 --- /dev/null +++ b/app/sdks/server-php/docs/health.md @@ -0,0 +1,96 @@ +# Health Service + +## Get HTTP + +```http request +GET https://appwrite.io/v1/health +``` + +** Check the Appwrite HTTP server is up and responsive. ** + +## Get Anti virus + +```http request +GET https://appwrite.io/v1/health/anti-virus +``` + +** Check the Appwrite Anti Virus server is up and connection is successful. ** + +## Get Cache + +```http request +GET https://appwrite.io/v1/health/cache +``` + +** Check the Appwrite in-memory cache server is up and connection is successful. ** + +## Get DB + +```http request +GET https://appwrite.io/v1/health/db +``` + +** Check the Appwrite database server is up and connection is successful. ** + +## Get Certificate Queue + +```http request +GET https://appwrite.io/v1/health/queue/certificates +``` + +** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. ** + +## Get Functions Queue + +```http request +GET https://appwrite.io/v1/health/queue/functions +``` + +## Get Logs Queue + +```http request +GET https://appwrite.io/v1/health/queue/logs +``` + +** Get the number of logs that are waiting to be processed in the Appwrite internal queue server. ** + +## Get Tasks Queue + +```http request +GET https://appwrite.io/v1/health/queue/tasks +``` + +** Get the number of tasks that are waiting to be processed in the Appwrite internal queue server. ** + +## Get Usage Queue + +```http request +GET https://appwrite.io/v1/health/queue/usage +``` + +** Get the number of usage stats that are waiting to be processed in the Appwrite internal queue server. ** + +## Get Webhooks Queue + +```http request +GET https://appwrite.io/v1/health/queue/webhooks +``` + +** Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. ** + +## Get Local Storage + +```http request +GET https://appwrite.io/v1/health/storage/local +``` + +** Check the Appwrite local storage device is up and connection is successful. ** + +## Get Time + +```http request +GET https://appwrite.io/v1/health/time +``` + +** Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. ** + diff --git a/app/sdks/server-php/docs/locale.md b/app/sdks/server-php/docs/locale.md index 604d4f37fb..7e99b08829 100644 --- a/app/sdks/server-php/docs/locale.md +++ b/app/sdks/server-php/docs/locale.md @@ -10,7 +10,7 @@ GET https://appwrite.io/v1/locale ([IP Geolocation by DB-IP](https://db-ip.com)) ** -## List Countries +## List Continents ```http request GET https://appwrite.io/v1/locale/continents diff --git a/app/sdks/server-php/docs/users.md b/app/sdks/server-php/docs/users.md index fe68614cab..fd884b254f 100644 --- a/app/sdks/server-php/docs/users.md +++ b/app/sdks/server-php/docs/users.md @@ -121,7 +121,7 @@ DELETE https://appwrite.io/v1/users/{userId}/sessions ## Delete User Session ```http request -DELETE https://appwrite.io/v1/users/{userId}/sessions/:session +DELETE https://appwrite.io/v1/users/{userId}/sessions/{sessionId} ``` ** Delete user sessions by its unique ID. ** @@ -131,7 +131,7 @@ DELETE https://appwrite.io/v1/users/{userId}/sessions/:session | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User unique ID. | | -| sessionId | string | User unique session ID. | | +| sessionId | string | **Required** User unique session ID. | | ## Update User Status diff --git a/app/sdks/server-php/src/Appwrite/Client.php b/app/sdks/server-php/src/Appwrite/Client.php index 36a9b85e33..21ca0bda1b 100644 --- a/app/sdks/server-php/src/Appwrite/Client.php +++ b/app/sdks/server-php/src/Appwrite/Client.php @@ -93,20 +93,6 @@ class Client return $this; } - /** - * Set Mode - * - * @param string $value - * - * @return Client - */ - public function setMode($value) - { - $this->addHeader('X-Appwrite-Mode', $value); - - return $this; - } - /*** * @param bool $status diff --git a/app/sdks/server-php/src/Appwrite/Services/Database.php b/app/sdks/server-php/src/Appwrite/Services/Database.php index d91cbab534..7ce8ac359f 100644 --- a/app/sdks/server-php/src/Appwrite/Services/Database.php +++ b/app/sdks/server-php/src/Appwrite/Services/Database.php @@ -164,9 +164,9 @@ class Database extends Service $params['filters'] = $filters; $params['offset'] = $offset; $params['limit'] = $limit; - $params['order-field'] = $orderField; - $params['order-type'] = $orderType; - $params['order-cast'] = $orderCast; + $params['orderField'] = $orderField; + $params['orderType'] = $orderType; + $params['orderCast'] = $orderCast; $params['search'] = $search; $params['first'] = $first; $params['last'] = $last; @@ -278,4 +278,22 @@ class Database extends Service ], $params); } + /** + * Get Collection Logs + * + * @param string $collectionId + * @throws Exception + * @return array + */ + public function getCollectionLogs(string $collectionId):array + { + $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/logs'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + } \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Health.php b/app/sdks/server-php/src/Appwrite/Services/Health.php new file mode 100644 index 0000000000..d39f1f406d --- /dev/null +++ b/app/sdks/server-php/src/Appwrite/Services/Health.php @@ -0,0 +1,250 @@ +client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @throws Exception + * @return array + */ + public function getAntiVirus():array + { + $path = str_replace([], [], '/health/anti-virus'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @throws Exception + * @return array + */ + public function getCache():array + { + $path = str_replace([], [], '/health/cache'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @throws Exception + * @return array + */ + public function getDB():array + { + $path = str_replace([], [], '/health/db'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @throws Exception + * @return array + */ + public function getQueueCertificates():array + { + $path = str_replace([], [], '/health/queue/certificates'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Functions Queue + * + * @throws Exception + * @return array + */ + public function getQueueFunctions():array + { + $path = str_replace([], [], '/health/queue/functions'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return array + */ + public function getQueueLogs():array + { + $path = str_replace([], [], '/health/queue/logs'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return array + */ + public function getQueueTasks():array + { + $path = str_replace([], [], '/health/queue/tasks'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @throws Exception + * @return array + */ + public function getQueueUsage():array + { + $path = str_replace([], [], '/health/queue/usage'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @throws Exception + * @return array + */ + public function getQueueWebhooks():array + { + $path = str_replace([], [], '/health/queue/webhooks'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws Exception + * @return array + */ + public function getStorageLocal():array + { + $path = str_replace([], [], '/health/storage/local'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @throws Exception + * @return array + */ + public function getTime():array + { + $path = str_replace([], [], '/health/time'); + $params = []; + + + return $this->client->call(Client::METHOD_GET, $path, [ + 'content-type' => 'application/json', + ], $params); + } + +} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Locale.php b/app/sdks/server-php/src/Appwrite/Services/Locale.php index 4cb95fa97a..25255c81a0 100644 --- a/app/sdks/server-php/src/Appwrite/Services/Locale.php +++ b/app/sdks/server-php/src/Appwrite/Services/Locale.php @@ -33,7 +33,7 @@ class Locale extends Service } /** - * List Countries + * List Continents * * List of all continents. You can use the locale header to get the data in a * supported language. diff --git a/app/sdks/server-php/src/Appwrite/Services/Users.php b/app/sdks/server-php/src/Appwrite/Services/Users.php index 89189b0d63..b2b4f576cc 100644 --- a/app/sdks/server-php/src/Appwrite/Services/Users.php +++ b/app/sdks/server-php/src/Appwrite/Services/Users.php @@ -196,10 +196,9 @@ class Users extends Service */ public function deleteSession(string $userId, string $sessionId):array { - $path = str_replace(['{userId}'], [$userId], '/users/{userId}/sessions/:session'); + $path = str_replace(['{userId}', '{sessionId}'], [$userId, $sessionId], '/users/{userId}/sessions/{sessionId}'); $params = []; - $params['sessionId'] = $sessionId; return $this->client->call(Client::METHOD_DELETE, $path, [ 'content-type' => 'application/json', diff --git a/app/sdks/server-python/README.md b/app/sdks/server-python/README.md index 2c065d3466..546019dac2 100644 --- a/app/sdks/server-python/README.md +++ b/app/sdks/server-python/README.md @@ -1,11 +1,13 @@ -# Appwrite SDK for Python +# Appwrite Python SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.** -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-python/appwrite/client.py b/app/sdks/server-python/appwrite/client.py index 643e0ae0f0..d0e74de33d 100644 --- a/app/sdks/server-python/appwrite/client.py +++ b/app/sdks/server-python/appwrite/client.py @@ -38,10 +38,6 @@ class Client: self._global_headers['x-appwrite-locale'] = value.lower() return self - def set_mode(self, value): - self._global_headers['x-appwrite-mode'] = value.lower() - return self - def call(self, method, path='', headers=None, params=None): if headers is None: headers = {} diff --git a/app/sdks/server-python/appwrite/services/database.py b/app/sdks/server-python/appwrite/services/database.py index ea07962ebc..2549e689d5 100644 --- a/app/sdks/server-python/appwrite/services/database.py +++ b/app/sdks/server-python/appwrite/services/database.py @@ -80,9 +80,9 @@ class Database(Service): params['filters'] = filters params['offset'] = offset params['limit'] = limit - params['order-field'] = order_field - params['order-type'] = order_type - params['order-cast'] = order_cast + params['orderField'] = order_field + params['orderType'] = order_type + params['orderCast'] = order_cast params['search'] = search params['first'] = first params['last'] = last @@ -146,3 +146,14 @@ class Database(Service): return self.client.call('delete', path, { 'content-type': 'application/json', }, params) + + def get_collection_logs(self, collection_id): + """Get Collection Logs""" + + params = {} + path = '/database/collections/{collectionId}/logs' + path = path.replace('{collectionId}', collection_id) + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) diff --git a/app/sdks/server-python/appwrite/services/health.py b/app/sdks/server-python/appwrite/services/health.py new file mode 100644 index 0000000000..5e08ebe6e8 --- /dev/null +++ b/app/sdks/server-python/appwrite/services/health.py @@ -0,0 +1,127 @@ +from ..service import Service + + +class Health(Service): + + def __init__(self, client): + super(Health, self).__init__(client) + + def get(self): + """Get HTTP""" + + params = {} + path = '/health' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_anti_virus(self): + """Get Anti virus""" + + params = {} + path = '/health/anti-virus' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_cache(self): + """Get Cache""" + + params = {} + path = '/health/cache' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_d_b(self): + """Get DB""" + + params = {} + path = '/health/db' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_certificates(self): + """Get Certificate Queue""" + + params = {} + path = '/health/queue/certificates' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_functions(self): + """Get Functions Queue""" + + params = {} + path = '/health/queue/functions' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_logs(self): + """Get Logs Queue""" + + params = {} + path = '/health/queue/logs' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_tasks(self): + """Get Tasks Queue""" + + params = {} + path = '/health/queue/tasks' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_usage(self): + """Get Usage Queue""" + + params = {} + path = '/health/queue/usage' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_queue_webhooks(self): + """Get Webhooks Queue""" + + params = {} + path = '/health/queue/webhooks' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_storage_local(self): + """Get Local Storage""" + + params = {} + path = '/health/storage/local' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) + + def get_time(self): + """Get Time""" + + params = {} + path = '/health/time' + + return self.client.call('get', path, { + 'content-type': 'application/json', + }, params) diff --git a/app/sdks/server-python/appwrite/services/locale.py b/app/sdks/server-python/appwrite/services/locale.py index 1c5ad69832..70c955eb85 100644 --- a/app/sdks/server-python/appwrite/services/locale.py +++ b/app/sdks/server-python/appwrite/services/locale.py @@ -17,7 +17,7 @@ class Locale(Service): }, params) def get_continents(self): - """List Countries""" + """List Continents""" params = {} path = '/locale/continents' diff --git a/app/sdks/server-python/appwrite/services/users.py b/app/sdks/server-python/appwrite/services/users.py index be9b2da8de..2608f07a50 100644 --- a/app/sdks/server-python/appwrite/services/users.py +++ b/app/sdks/server-python/appwrite/services/users.py @@ -104,9 +104,9 @@ class Users(Service): """Delete User Session""" params = {} - path = '/users/{userId}/sessions/:session' + path = '/users/{userId}/sessions/{sessionId}' path = path.replace('{userId}', user_id) - params['sessionId'] = session_id + path = path.replace('{sessionId}', session_id) return self.client.call('delete', path, { 'content-type': 'application/json', diff --git a/app/sdks/server-python/docs/examples/database/get-collection-logs.md b/app/sdks/server-python/docs/examples/database/get-collection-logs.md new file mode 100644 index 0000000000..7776a1e31d --- /dev/null +++ b/app/sdks/server-python/docs/examples/database/get-collection-logs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.database import Database + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +database = Database(client) + +result = database.get_collection_logs('[COLLECTION_ID]') diff --git a/app/sdks/server-python/docs/examples/health/get-anti-virus.md b/app/sdks/server-python/docs/examples/health/get-anti-virus.md new file mode 100644 index 0000000000..51e301c12a --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-anti-virus.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_anti_virus() diff --git a/app/sdks/server-python/docs/examples/health/get-cache.md b/app/sdks/server-python/docs/examples/health/get-cache.md new file mode 100644 index 0000000000..308bdee556 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-cache.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_cache() diff --git a/app/sdks/server-python/docs/examples/health/get-d-b.md b/app/sdks/server-python/docs/examples/health/get-d-b.md new file mode 100644 index 0000000000..6c4fe2e4f9 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-d-b.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_d_b() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-certificates.md b/app/sdks/server-python/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000000..6b0361e13b --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_certificates() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-functions.md b/app/sdks/server-python/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..c282ba7969 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-functions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_functions() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-logs.md b/app/sdks/server-python/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..5b3e387ab7 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-logs.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_logs() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-tasks.md b/app/sdks/server-python/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..b33bc081d0 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_tasks() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-usage.md b/app/sdks/server-python/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..774f2a892a --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-usage.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_usage() diff --git a/app/sdks/server-python/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-python/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..7cef20570f --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_queue_webhooks() diff --git a/app/sdks/server-python/docs/examples/health/get-storage-anti-virus.md b/app/sdks/server-python/docs/examples/health/get-storage-anti-virus.md new file mode 100644 index 0000000000..5ce63ac816 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-storage-anti-virus.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_storage_anti_virus() diff --git a/app/sdks/server-python/docs/examples/health/get-storage-local.md b/app/sdks/server-python/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..7b1a30f615 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-storage-local.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_storage_local() diff --git a/app/sdks/server-python/docs/examples/health/get-time.md b/app/sdks/server-python/docs/examples/health/get-time.md new file mode 100644 index 0000000000..42390722c3 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-time.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get_time() diff --git a/app/sdks/server-python/docs/examples/health/get.md b/app/sdks/server-python/docs/examples/health/get.md new file mode 100644 index 0000000000..831b34768f --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() + +(client + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +health = Health(client) + +result = health.get() diff --git a/app/sdks/server-python/setup.py b/app/sdks/server-python/setup.py index f7707eaefa..85c64b9c28 100644 --- a/app/sdks/server-python/setup.py +++ b/app/sdks/server-python/setup.py @@ -5,11 +5,11 @@ setuptools.setup( packages = ['appwrite', 'appwrite/services'], version = '0.0.4', license='BSD-3-Clause', - description = 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)', + description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', author = 'Appwrite Team', - author_email = 'team@appwrite.io', + author_email = 'team@localhost.test', maintainer = 'Appwrite Team', - maintainer_email = 'team@appwrite.io', + maintainer_email = 'team@localhost.test', url = 'https://appwrite.io/support', download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.4.tar.gz', # keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'], diff --git a/app/sdks/server-ruby/README.md b/app/sdks/server-ruby/README.md index 812c86fea9..758a2dae7d 100644 --- a/app/sdks/server-ruby/README.md +++ b/app/sdks/server-ruby/README.md @@ -1,11 +1,13 @@ -# Appwrite SDK for Ruby +# Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1) -**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.** +**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.** -Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/app/sdks/server-ruby/appwrite.gemspec b/app/sdks/server-ruby/appwrite.gemspec index 308e225449..aba1f90947 100644 --- a/app/sdks/server-ruby/appwrite.gemspec +++ b/app/sdks/server-ruby/appwrite.gemspec @@ -2,10 +2,12 @@ Gem::Specification.new do |s| s.name = 'appwrite' s.version = '1.0.9' - s.summary = "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)" + s.summary = "Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)" s.author = 'Appwrite Team' s.homepage = 'https://appwrite.io/support' - s.email = 'team@appwrite.io' + s.email = 'team@localhost.test' s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite.rb b/app/sdks/server-ruby/lib/appwrite.rb index 0d0dcd156e..8e88842789 100644 --- a/app/sdks/server-ruby/lib/appwrite.rb +++ b/app/sdks/server-ruby/lib/appwrite.rb @@ -5,6 +5,7 @@ require_relative 'appwrite/client' require_relative 'appwrite/service' require_relative 'appwrite/services/avatars' require_relative 'appwrite/services/database' +require_relative 'appwrite/services/health' require_relative 'appwrite/services/locale' require_relative 'appwrite/services/storage' require_relative 'appwrite/services/teams' diff --git a/app/sdks/server-ruby/lib/appwrite/client.rb b/app/sdks/server-ruby/lib/appwrite/client.rb index ce15392c65..5e413cf6ae 100644 --- a/app/sdks/server-ruby/lib/appwrite/client.rb +++ b/app/sdks/server-ruby/lib/appwrite/client.rb @@ -43,12 +43,6 @@ module Appwrite return self end - def set_mode(value) - add_header('x-appwrite-mode', value) - - return self - end - def set_endpoint(endpoint) @endpoint = endpoint diff --git a/app/sdks/server-ruby/lib/appwrite/services/database.rb b/app/sdks/server-ruby/lib/appwrite/services/database.rb index 0e897a942e..8bb9c3bbb4 100644 --- a/app/sdks/server-ruby/lib/appwrite/services/database.rb +++ b/app/sdks/server-ruby/lib/appwrite/services/database.rb @@ -79,9 +79,9 @@ module Appwrite 'filters': filters, 'offset': offset, 'limit': limit, - 'order-field': order_field, - 'order-type': order_type, - 'order-cast': order_cast, + 'orderField': order_field, + 'orderType': order_type, + 'orderCast': order_cast, 'search': search, 'first': first, 'last': last @@ -152,6 +152,18 @@ module Appwrite }, params); end + def get_collection_logs(collection_id:) + path = '/database/collections/{collectionId}/logs' + .gsub('{collection_id}', collection_id) + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + protected diff --git a/app/sdks/server-ruby/lib/appwrite/services/health.rb b/app/sdks/server-ruby/lib/appwrite/services/health.rb new file mode 100644 index 0000000000..d2c6bc7b60 --- /dev/null +++ b/app/sdks/server-ruby/lib/appwrite/services/health.rb @@ -0,0 +1,141 @@ +module Appwrite + class Health < Service + + def get() + path = '/health' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_anti_virus() + path = '/health/anti-virus' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_cache() + path = '/health/cache' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_d_b() + path = '/health/db' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_certificates() + path = '/health/queue/certificates' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_functions() + path = '/health/queue/functions' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_logs() + path = '/health/queue/logs' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_tasks() + path = '/health/queue/tasks' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_usage() + path = '/health/queue/usage' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_queue_webhooks() + path = '/health/queue/webhooks' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_storage_local() + path = '/health/storage/local' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + def get_time() + path = '/health/time' + + params = { + } + + return @client.call('get', path, { + 'content-type' => 'application/json', + }, params); + end + + + protected + + private + end +end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/users.rb b/app/sdks/server-ruby/lib/appwrite/services/users.rb index 75b1701f2d..ae790c9403 100644 --- a/app/sdks/server-ruby/lib/appwrite/services/users.rb +++ b/app/sdks/server-ruby/lib/appwrite/services/users.rb @@ -104,11 +104,11 @@ module Appwrite end def delete_session(user_id:, session_id:) - path = '/users/{userId}/sessions/:session' + path = '/users/{userId}/sessions/{sessionId}' .gsub('{user_id}', user_id) + .gsub('{session_id}', session_id) params = { - 'sessionId': session_id } return @client.call('delete', path, { diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-credit-card.md b/app/sdks/web-javascript/docs/examples/avatars/get-credit-card.md deleted file mode 100644 index 584f24d8a0..0000000000 --- a/app/sdks/web-javascript/docs/examples/avatars/get-credit-card.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('5df5acd0d48c2') // Your project ID -; - -let promise = sdk.avatars.getCreditCard('amex'); - -promise.then(function (response) { - console.log(response); // Success -}, function (error) { - console.log(error); // Failure -}); \ No newline at end of file diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-favicon.md b/app/sdks/web-javascript/docs/examples/avatars/get-favicon.md deleted file mode 100644 index 292a4f4403..0000000000 --- a/app/sdks/web-javascript/docs/examples/avatars/get-favicon.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('5df5acd0d48c2') // Your project ID -; - -let promise = sdk.avatars.getFavicon('https://example.com'); - -promise.then(function (response) { - console.log(response); // Success -}, function (error) { - console.log(error); // Failure -}); \ No newline at end of file diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-flag.md b/app/sdks/web-javascript/docs/examples/avatars/get-flag.md deleted file mode 100644 index fc5e6ff644..0000000000 --- a/app/sdks/web-javascript/docs/examples/avatars/get-flag.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('5df5acd0d48c2') // Your project ID -; - -let promise = sdk.avatars.getFlag('af'); - -promise.then(function (response) { - console.log(response); // Success -}, function (error) { - console.log(error); // Failure -}); \ No newline at end of file diff --git a/app/sdks/web-javascript/docs/examples/avatars/get-q-r.md b/app/sdks/web-javascript/docs/examples/avatars/get-q-r.md deleted file mode 100644 index 33ae75a2d4..0000000000 --- a/app/sdks/web-javascript/docs/examples/avatars/get-q-r.md +++ /dev/null @@ -1,13 +0,0 @@ -let sdk = new Appwrite(); - -sdk - .setProject('5df5acd0d48c2') // Your project ID -; - -let promise = sdk.avatars.getQR('[TEXT]'); - -promise.then(function (response) { - console.log(response); // Success -}, function (error) { - console.log(error); // Failure -}); \ No newline at end of file diff --git a/app/sdks/web-javascript/package.json b/app/sdks/web-javascript/package.json deleted file mode 100644 index 8baa2d87c7..0000000000 --- a/app/sdks/web-javascript/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "appwrite", - "homepage": "https://appwrite.io/support", - "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", - "version": "1.0.29", - "license": "BSD-3-Clause", - "main": "src/sdk.js", - "repository": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-js" - }, - "devDependencies": {}, - "dependencies": {} -} \ No newline at end of file diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 63e50cbb76..19d2deb3b8 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -16,7 +16,7 @@ use Appwrite\SDK\Language\Python; use Appwrite\SDK\Language\Ruby; use Appwrite\SDK\Language\Dart; use Appwrite\SDK\Language\Go; -use Appwrite\SDK\Language\Typescript; +use Appwrite\SDK\Language\Java; $cli = new CLI(); @@ -41,11 +41,16 @@ $cli } $platforms = Config::getParam('platforms'); + $selected = strtolower(Console::confirm('Choose SDK ("*" for all):')); $message = Console::confirm('Please enter your commit message:'); $production = (Console::confirm('Type "Appwrite" to deploy for production') == 'Appwrite'); foreach($platforms as $key => $platform) { foreach($platform['languages'] as $language) { + if($selected !== $language['key'] && $selected !== '*') { + continue; + } + if(!$language['enabled']) { Console::warning($language['name'].' for '.$platform['name'] . ' is disabled'); continue; @@ -55,11 +60,14 @@ $cli //$spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']); $spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform='.$language['family']); + $spec = getSSLPage('https://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']); $result = realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key']; $target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/'; $readme = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/README.md'); $readme = ($readme) ? file_get_contents($readme) : ''; + $examples = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/EXAMPLES.md'); + $examples = ($examples) ? file_get_contents($examples) : ''; $changelog = realpath(__DIR__ . '/../../docs/sdks/'.$language['key'].'/CHANGELOG.md'); $changelog = ($changelog) ? file_get_contents($changelog) : '# Change Log'; $warning = ($language['beta']) ? '**This SDK is compatible with Appwrite server version ' . $version . '. For older versions, please check previous releases.**' : ''; @@ -78,25 +86,18 @@ Redistribution and use in source and binary forms, with or without modification, THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'; switch ($language['key']) { - case 'php': - $config = new PHP(); - $config - ->setComposerVendor('appwrite') - ->setComposerPackage('appwrite') - ; - break; - case 'javascript': + case 'web': $config = new JS(); $config ->setNPMPackage('appwrite') ->setBowerPackage('appwrite') ; break; - case 'typescript': - $config = new Typescript(); + case 'php': + $config = new PHP(); $config - ->setNPMPackage('appwrite') - ->setBowerPackage('appwrite') + ->setComposerVendor('appwrite') + ->setComposerPackage('appwrite') ; break; case 'nodejs': @@ -119,12 +120,16 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setGemPackage('appwrite') ; break; + case 'flutter': case 'dart': $config = new Dart(); break; case 'go': $config = new Go(); break; + case 'java': + $config = new Java(); + break; default: throw new Exception('Language "'.$language['key'].'" not supported'); break; @@ -135,6 +140,11 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $sdk = new SDK($config, new Swagger2($spec)); $sdk + ->setName($language['name']) + ->setDescription("Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. + Use the {$language['name']} SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. + For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)") + ->setShortDescription('Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API') ->setLicense($license) ->setLicenseContent($licenseContent) ->setVersion($language['version']) @@ -151,6 +161,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setWarning($warning) ->setReadme($readme) ->setChangelog($changelog) + ->setExamples($examples) ; try { diff --git a/app/views/console/account/index.phtml b/app/views/console/account/index.phtml index 88b96cbe3c..37abdb5ddc 100644 --- a/app/views/console/account/index.phtml +++ b/app/views/console/account/index.phtml @@ -253,7 +253,7 @@
- + /
@@ -302,11 +302,11 @@ - + - + diff --git a/app/views/console/comps/footer.phtml b/app/views/console/comps/footer.phtml index 99f3ba1f29..e8f7770d6f 100644 --- a/app/views/console/comps/footer.phtml +++ b/app/views/console/comps/footer.phtml @@ -1,8 +1,8 @@ getParam('home', ''); -$version = $this->getParam('version', ''); +$version = $this->getParam('version', '').'.'.APP_CACHE_BUSTER; ?> -