diff --git a/CHANGES.md b/CHANGES.md index a6aff01af1..caab53b6db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,8 +10,9 @@ - Fixed wrong SDK method type in avatars browser route - Fixed bug denied public documents (*) to be accessed by guest users - Fixed cache control issue not allowing collection UI to update properly -- Added missing webhooks events in the console - Fixed a bug where single permission tag in the console was not being saved +- Added missing webhooks events in the console +- Added missing option to delete project ## Security diff --git a/app/app.php b/app/app.php index a438950f3f..447a593ae1 100644 --- a/app/app.php +++ b/app/app.php @@ -27,6 +27,7 @@ $services = include __DIR__.'/config/services.php'; // List of services $webhook = new Event('v1-webhooks', 'WebhooksV1'); $audit = new Event('v1-audits', 'AuditsV1'); $usage = new Event('v1-usage', 'UsageV1'); +$deletes = new Event('v1-deletes', 'DeletesV1'); /** * Get All verified client URLs for both console and current projects @@ -215,10 +216,10 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $ ; }); -$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $mode, $project, $utopia) { +$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage, $deletes, $mode, $project, $utopia) { /* - * Trigger Events for background jobs + * Trigger events for background workers */ if (!empty($webhook->getParam('event'))) { $webhook->trigger(); @@ -228,6 +229,10 @@ $utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage $audit->trigger(); } + if (!empty($deletes->getParam('document'))) { + $deletes->trigger(); + } + $route = $utopia->match($request); if($project->getId() diff --git a/app/config/platforms.php b/app/config/platforms.php index 796f4ad39f..ed1bf24a0c 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -139,6 +139,20 @@ return [ 'gitRepoName' => 'sdk-for-node', 'gitUserName' => 'appwrite', ], + [ + 'key' => 'deno', + 'name' => 'Deno', + 'version' => '0.0.1', + 'url' => 'https://github.com/appwrite/sdk-for-deno', + 'enabled' => false, + 'beta' => true, + 'family' => APP_PLATFORM_SERVER, + 'prism' => 'typescript', + 'source' => realpath(__DIR__ . '/../sdks/server-deno'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-deno.git', + 'gitRepoName' => 'sdk-for-deno', + 'gitUserName' => 'appwrite', + ], [ 'key' => 'php', 'name' => 'PHP', diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9f35733bc7..54ccd2dcec 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1,6 +1,6 @@ delete('/v1/projects/:projectId') ->param('projectId', '', function () { return new UID(); }, 'Project unique ID.') ->param('password', '', function () { return new UID(); }, 'Your user password for confirmation.') ->action( - function ($projectId, $password) use ($response, $consoleDB, $user) { + function ($projectId, $password) use ($response, $consoleDB, $user, $deletes) { if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password throw new Exception('Invalid credentials', 401); } @@ -413,20 +413,22 @@ $utopia->delete('/v1/projects/:projectId') throw new Exception('Project not found', 404); } - // Delete all children (keys, webhooks, tasks [stop tasks?], platforms) + $deletes->setParam('document', $project->getArrayCopy()); + + foreach(['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms) + $list = $project->getAttribute('webhooks', []); + + foreach ($list as $document) { /* @var $document Document */ + if (!$consoleDB->deleteDocument($projectId)) { + throw new Exception('Failed to remove project document ('.$key.')] from DB', 500); + } + } + } if (!$consoleDB->deleteDocument($projectId)) { throw new Exception('Failed to remove project from DB', 500); } - // Delete all DBs - // $consoleDB->deleteNamespace($project->getId()); - - // Optimize DB? - - // Delete all storage files - // Delete all storage cache - $response->noContent(); } ); diff --git a/app/sdks/server-deno/CHANGELOG.md b/app/sdks/server-deno/CHANGELOG.md new file mode 100644 index 0000000000..fa4d35e687 --- /dev/null +++ b/app/sdks/server-deno/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/server-deno/LICENSE b/app/sdks/server-deno/LICENSE new file mode 100644 index 0000000000..fc7c051a91 --- /dev/null +++ b/app/sdks/server-deno/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-deno/README.md b/app/sdks/server-deno/README.md new file mode 100644 index 0000000000..1a53fc663b --- /dev/null +++ b/app/sdks/server-deno/README.md @@ -0,0 +1,28 @@ +# Appwrite Deno SDK + +![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?v=1) +![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.svg?v=1) + +**This SDK is compatible with Appwrite server version 0.6.1. 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 Deno 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 + +```javascript +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; +``` + +## 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-deno/docs/examples/avatars/get-browser.md b/app/sdks/server-deno/docs/examples/avatars/get-browser.md new file mode 100644 index 0000000000..38b693da58 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-browser.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getBrowser('aa'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/avatars/get-credit-card.md b/app/sdks/server-deno/docs/examples/avatars/get-credit-card.md new file mode 100644 index 0000000000..e3af5aad73 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getCreditCard('amex'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/avatars/get-favicon.md b/app/sdks/server-deno/docs/examples/avatars/get-favicon.md new file mode 100644 index 0000000000..c3305a22b8 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-favicon.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getFavicon('https://example.com'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/avatars/get-flag.md b/app/sdks/server-deno/docs/examples/avatars/get-flag.md new file mode 100644 index 0000000000..c16c433bf3 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-flag.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getFlag('af'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/avatars/get-image.md b/app/sdks/server-deno/docs/examples/avatars/get-image.md new file mode 100644 index 0000000000..5555b673be --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-image.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getImage('https://example.com'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/avatars/get-q-r.md b/app/sdks/server-deno/docs/examples/avatars/get-q-r.md new file mode 100644 index 0000000000..30d66f88a3 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/avatars/get-q-r.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let avatars = new sdk.Avatars(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = avatars.getQR('[TEXT]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/database/create-collection.md b/app/sdks/server-deno/docs/examples/database/create-collection.md new file mode 100644 index 0000000000..e33d1f92ba --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/create-collection.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.createCollection('[NAME]', [], [], []); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/database/create-document.md b/app/sdks/server-deno/docs/examples/database/create-document.md new file mode 100644 index 0000000000..6d6d66dd75 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/create-document.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.createDocument('[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-deno/docs/examples/database/delete-collection.md b/app/sdks/server-deno/docs/examples/database/delete-collection.md new file mode 100644 index 0000000000..e3ab2022ad --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/delete-collection.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.deleteCollection('[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-deno/docs/examples/database/delete-document.md b/app/sdks/server-deno/docs/examples/database/delete-document.md new file mode 100644 index 0000000000..7b1626885d --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/delete-document.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_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-deno/docs/examples/database/get-collection-logs.md b/app/sdks/server-deno/docs/examples/database/get-collection-logs.md new file mode 100644 index 0000000000..7c68ffb2d2 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/get-collection-logs.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/database/get-collection.md b/app/sdks/server-deno/docs/examples/database/get-collection.md new file mode 100644 index 0000000000..5023c2349e --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/get-collection.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.getCollection('[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-deno/docs/examples/database/get-document.md b/app/sdks/server-deno/docs/examples/database/get-document.md new file mode 100644 index 0000000000..0b3b4c2e34 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/get-document.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.getDocument('[COLLECTION_ID]', '[DOCUMENT_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-deno/docs/examples/database/list-collections.md b/app/sdks/server-deno/docs/examples/database/list-collections.md new file mode 100644 index 0000000000..7ac270809f --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/list-collections.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.listCollections(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/database/list-documents.md b/app/sdks/server-deno/docs/examples/database/list-documents.md new file mode 100644 index 0000000000..6e49475cad --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/list-documents.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.listDocuments('[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-deno/docs/examples/database/update-collection.md b/app/sdks/server-deno/docs/examples/database/update-collection.md new file mode 100644 index 0000000000..ac009964f6 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/update-collection.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.updateCollection('[COLLECTION_ID]', '[NAME]', [], []); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/database/update-document.md b/app/sdks/server-deno/docs/examples/database/update-document.md new file mode 100644 index 0000000000..51a92ac562 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/database/update-document.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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.updateDocument('[COLLECTION_ID]', '[DOCUMENT_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-deno/docs/examples/health/get-anti-virus.md b/app/sdks/server-deno/docs/examples/health/get-anti-virus.md new file mode 100644 index 0000000000..6bf045456f --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-anti-virus.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-cache.md b/app/sdks/server-deno/docs/examples/health/get-cache.md new file mode 100644 index 0000000000..c8b2ac6731 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-cache.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-d-b.md b/app/sdks/server-deno/docs/examples/health/get-d-b.md new file mode 100644 index 0000000000..0e43374f85 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-d-b.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-certificates.md b/app/sdks/server-deno/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000000..906f9069ef --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-functions.md b/app/sdks/server-deno/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000000..30ffc7f134 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-functions.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-logs.md b/app/sdks/server-deno/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000000..a139915c51 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-logs.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-tasks.md b/app/sdks/server-deno/docs/examples/health/get-queue-tasks.md new file mode 100644 index 0000000000..9868b4fb50 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-tasks.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-usage.md b/app/sdks/server-deno/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000000..07b9a08664 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-usage.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-queue-webhooks.md b/app/sdks/server-deno/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000000..fcf250d359 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-storage-local.md b/app/sdks/server-deno/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000000..b92b720c2f --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-storage-local.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get-time.md b/app/sdks/server-deno/docs/examples/health/get-time.md new file mode 100644 index 0000000000..88e1036670 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get-time.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/health/get.md b/app/sdks/server-deno/docs/examples/health/get.md new file mode 100644 index 0000000000..abc1af3e50 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/health/get.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// 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-deno/docs/examples/locale/get-continents.md b/app/sdks/server-deno/docs/examples/locale/get-continents.md new file mode 100644 index 0000000000..2633029d58 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get-continents.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.getContinents(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/locale/get-countries-e-u.md b/app/sdks/server-deno/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 0000000000..6d6f15959f --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.getCountriesEU(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/locale/get-countries-phones.md b/app/sdks/server-deno/docs/examples/locale/get-countries-phones.md new file mode 100644 index 0000000000..e1085e34b2 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.getCountriesPhones(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/locale/get-countries.md b/app/sdks/server-deno/docs/examples/locale/get-countries.md new file mode 100644 index 0000000000..626d339405 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get-countries.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.getCountries(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/locale/get-currencies.md b/app/sdks/server-deno/docs/examples/locale/get-currencies.md new file mode 100644 index 0000000000..2bcdb0da64 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get-currencies.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.getCurrencies(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/locale/get.md b/app/sdks/server-deno/docs/examples/locale/get.md new file mode 100644 index 0000000000..5189633d34 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/locale/get.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let locale = new sdk.Locale(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = locale.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-deno/docs/examples/storage/create-file.md b/app/sdks/server-deno/docs/examples/storage/create-file.md new file mode 100644 index 0000000000..5452f892ee --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/create-file.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.createFile(fs.createReadStream(__dirname + '/file.png')), [], []); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/storage/delete-file.md b/app/sdks/server-deno/docs/examples/storage/delete-file.md new file mode 100644 index 0000000000..63a4a7a163 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/delete-file.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.deleteFile('[FILE_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-deno/docs/examples/storage/get-file-download.md b/app/sdks/server-deno/docs/examples/storage/get-file-download.md new file mode 100644 index 0000000000..e46a6276c5 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/get-file-download.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.getFileDownload('[FILE_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-deno/docs/examples/storage/get-file-preview.md b/app/sdks/server-deno/docs/examples/storage/get-file-preview.md new file mode 100644 index 0000000000..d55e4e2c78 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/get-file-preview.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.getFilePreview('[FILE_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-deno/docs/examples/storage/get-file-view.md b/app/sdks/server-deno/docs/examples/storage/get-file-view.md new file mode 100644 index 0000000000..9f13a1b2cb --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/get-file-view.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.getFileView('[FILE_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-deno/docs/examples/storage/get-file.md b/app/sdks/server-deno/docs/examples/storage/get-file.md new file mode 100644 index 0000000000..56d16adbc1 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/get-file.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.getFile('[FILE_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-deno/docs/examples/storage/list-files.md b/app/sdks/server-deno/docs/examples/storage/list-files.md new file mode 100644 index 0000000000..56279b6a47 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/list-files.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.listFiles(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/storage/update-file.md b/app/sdks/server-deno/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..c2493a27d6 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/storage/update-file.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let storage = new sdk.Storage(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = storage.updateFile('[FILE_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-deno/docs/examples/teams/create-membership.md b/app/sdks/server-deno/docs/examples/teams/create-membership.md new file mode 100644 index 0000000000..19ed6d1e84 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/create-membership.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/teams/create.md b/app/sdks/server-deno/docs/examples/teams/create.md new file mode 100644 index 0000000000..548ddc6722 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/create.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.create('[NAME]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/teams/delete-membership.md b/app/sdks/server-deno/docs/examples/teams/delete-membership.md new file mode 100644 index 0000000000..98e05f4655 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/delete-membership.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.deleteMembership('[TEAM_ID]', '[INVITE_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-deno/docs/examples/teams/delete.md b/app/sdks/server-deno/docs/examples/teams/delete.md new file mode 100644 index 0000000000..54d0e7c0b6 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/delete.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.delete('[TEAM_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-deno/docs/examples/teams/get-memberships.md b/app/sdks/server-deno/docs/examples/teams/get-memberships.md new file mode 100644 index 0000000000..b3e0c6990d --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/get-memberships.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.getMemberships('[TEAM_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-deno/docs/examples/teams/get.md b/app/sdks/server-deno/docs/examples/teams/get.md new file mode 100644 index 0000000000..36a74c20eb --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/get.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.get('[TEAM_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-deno/docs/examples/teams/list.md b/app/sdks/server-deno/docs/examples/teams/list.md new file mode 100644 index 0000000000..0fabc7bd1a --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/list.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.list(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/teams/update.md b/app/sdks/server-deno/docs/examples/teams/update.md new file mode 100644 index 0000000000..f28143d989 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/teams/update.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let teams = new sdk.Teams(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = teams.update('[TEAM_ID]', '[NAME]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/users/create.md b/app/sdks/server-deno/docs/examples/users/create.md new file mode 100644 index 0000000000..0a7c27aef2 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/create.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.create('email@example.com', 'password'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/users/delete-session.md b/app/sdks/server-deno/docs/examples/users/delete-session.md new file mode 100644 index 0000000000..fce31a8329 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/delete-session.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.deleteSession('[USER_ID]', '[SESSION_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-deno/docs/examples/users/delete-sessions.md b/app/sdks/server-deno/docs/examples/users/delete-sessions.md new file mode 100644 index 0000000000..ad29540583 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/delete-sessions.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.deleteSessions('[USER_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-deno/docs/examples/users/get-logs.md b/app/sdks/server-deno/docs/examples/users/get-logs.md new file mode 100644 index 0000000000..e7243cdd57 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/get-logs.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.getLogs('[USER_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-deno/docs/examples/users/get-prefs.md b/app/sdks/server-deno/docs/examples/users/get-prefs.md new file mode 100644 index 0000000000..9cce769aa9 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/get-prefs.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.getPrefs('[USER_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-deno/docs/examples/users/get-sessions.md b/app/sdks/server-deno/docs/examples/users/get-sessions.md new file mode 100644 index 0000000000..0aded27e16 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/get-sessions.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.getSessions('[USER_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-deno/docs/examples/users/get.md b/app/sdks/server-deno/docs/examples/users/get.md new file mode 100644 index 0000000000..fe08ece8d9 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/get.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.get('[USER_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-deno/docs/examples/users/list.md b/app/sdks/server-deno/docs/examples/users/list.md new file mode 100644 index 0000000000..9a290eb0b7 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/list.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.list(); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/docs/examples/users/update-prefs.md b/app/sdks/server-deno/docs/examples/users/update-prefs.md new file mode 100644 index 0000000000..db180ed7ae --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/update-prefs.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.updatePrefs('[USER_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-deno/docs/examples/users/update-status.md b/app/sdks/server-deno/docs/examples/users/update-status.md new file mode 100644 index 0000000000..dfd3d44202 --- /dev/null +++ b/app/sdks/server-deno/docs/examples/users/update-status.md @@ -0,0 +1,19 @@ +import * as sdk from "https://deno.land/x/appwrite/mod.ts"; + +// Init SDK +let client = new sdk.Client(); + +let users = new sdk.Users(client); + +client + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +let promise = users.updateStatus('[USER_ID]', '1'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/server-deno/mod.ts b/app/sdks/server-deno/mod.ts new file mode 100644 index 0000000000..3e51466fe6 --- /dev/null +++ b/app/sdks/server-deno/mod.ts @@ -0,0 +1,19 @@ +import { Client } from "./src/client.ts"; +import { Avatars } from "./src/services/avatars.ts"; +import { Database } from "./src/services/database.ts"; +import { Health } from "./src/services/health.ts"; +import { Locale } from "./src/services/locale.ts"; +import { Storage } from "./src/services/storage.ts"; +import { Teams } from "./src/services/teams.ts"; +import { Users } from "./src/services/users.ts"; + +export { + Client, + Avatars, + Database, + Health, + Locale, + Storage, + Teams, + Users, +}; \ No newline at end of file diff --git a/app/sdks/server-deno/src/client.ts b/app/sdks/server-deno/src/client.ts new file mode 100644 index 0000000000..4c7b8dd3d0 --- /dev/null +++ b/app/sdks/server-deno/src/client.ts @@ -0,0 +1,138 @@ +export interface DocumentData { + [key: string]: any; +} + +export class Client { + + endpoint: string = 'https://appwrite.io/v1'; + headers: DocumentData = { + 'content-type': '', + 'x-sdk-version': 'appwrite:deno:0.0.1', + }; + + /** + * Set Project + * + * Your project ID + * + * @param string value + * + * @return self + */ + setProject(value: string): this { + this.addHeader('X-Appwrite-Project', value); + + return this; + } + + /** + * Set Key + * + * Your secret API key + * + * @param string value + * + * @return self + */ + setKey(value: string): this { + this.addHeader('X-Appwrite-Key', value); + + return this; + } + + /** + * Set Locale + * + * @param string value + * + * @return self + */ + setLocale(value: string): this { + this.addHeader('X-Appwrite-Locale', value); + + return this; + } + + + /*** + * @param endpoint + * @return this + */ + setEndpoint(endpoint: string): this { + this.endpoint = endpoint; + + return this; + } + + /** + * @param key string + * @param value string + */ + addHeader(key: string, value: string): this { + this.headers[key.toLowerCase()] = value.toLowerCase(); + + return this; + } + + withoutHeader(key: string, headers: DocumentData): DocumentData { + return Object.keys(headers).reduce((acc: DocumentData, cv) => { + if (cv == 'content-type') return acc + acc[cv] = headers[cv] + return acc + }, {}) + } + + async call(method: string, path: string = '', headers: DocumentData = {}, params: DocumentData = {}) { + headers = Object.assign(this.headers, headers); + + let body; + const url = new URL(this.endpoint + path) + if (method.toUpperCase() === 'GET') { + url.search = new URLSearchParams(this.flatten(params)).toString() + body = null + } else if (headers['content-type'].toLowerCase().startsWith('multipart/form-data')) { + headers = this.withoutHeader('content-type', headers) + const formData = new FormData() + const flatParams = this.flatten(params) + for (const key in flatParams) { + formData.append(key, flatParams[key]); + } + body = formData + } else { + body = JSON.stringify(params) + } + + const options = { + method: method.toUpperCase(), + headers: headers, + body: body, + }; + + let response = await fetch(url.toString(), options); + const contentType = response.headers.get('content-type'); + + if (contentType && contentType.includes('application/json')) { + return response.json() + } + + return response; + } + + flatten(data: DocumentData, prefix = '') { + let output: DocumentData = {}; + + for (const key in data) { + let value = data[key]; + let finalKey = prefix ? prefix + '[' + key +']' : key; + + if (Array.isArray(value)) { + output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed + } + else { + output[finalKey] = value; + } + } + + return output; + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/service.ts b/app/sdks/server-deno/src/service.ts new file mode 100644 index 0000000000..ceedf1a0c3 --- /dev/null +++ b/app/sdks/server-deno/src/service.ts @@ -0,0 +1,13 @@ +import { Client } from "./client.ts"; + +export abstract class Service { + + client: Client; + + /** + * @param client + */ + constructor(client: Client) { + this.client = client; + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/avatars.ts b/app/sdks/server-deno/src/services/avatars.ts new file mode 100644 index 0000000000..f70e950bed --- /dev/null +++ b/app/sdks/server-deno/src/services/avatars.ts @@ -0,0 +1,163 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Avatars extends Service { + + /** + * 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 Exception + * @return Promise + */ + async getBrowser(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { + let path = '/avatars/browsers/{code}'.replace(new RegExp('{code}', 'g'), code); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'width': width, + 'height': height, + 'quality': quality + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getCreditCard(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { + let path = '/avatars/credit-cards/{code}'.replace(new RegExp('{code}', 'g'), code); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'width': width, + 'height': height, + 'quality': quality + }); + } + + /** + * Get Favicon + * + * Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote + * website URL. + * + * @param string url + * @throws Exception + * @return Promise + */ + async getFavicon(url: string): Promise { + let path = '/avatars/favicon'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'url': url + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getFlag(code: string, width: number = 100, height: number = 100, quality: number = 100): Promise { + let path = '/avatars/flags/{code}'.replace(new RegExp('{code}', 'g'), code); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'width': width, + 'height': height, + 'quality': quality + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getImage(url: string, width: number = 400, height: number = 400): Promise { + let path = '/avatars/image'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'url': url, + 'width': width, + 'height': height + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getQR(text: string, size: number = 400, margin: number = 1, download: number = 0): Promise { + let path = '/avatars/qr'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'text': text, + 'size': size, + 'margin': margin, + 'download': download + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/database.ts b/app/sdks/server-deno/src/services/database.ts new file mode 100644 index 0000000000..30e601b2e5 --- /dev/null +++ b/app/sdks/server-deno/src/services/database.ts @@ -0,0 +1,282 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Database extends Service { + + /** + * 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 Exception + * @return Promise + */ + async listCollections(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { + let path = '/database/collections'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType + }); + } + + /** + * Create Collection + * + * Create a new Collection. + * + * @param string name + * @param Array read + * @param Array write + * @param Array rules + * @throws Exception + * @return Promise + */ + async createCollection(name: string, read: Array, write: Array, rules: Array): Promise { + let path = '/database/collections'; + + return await this.client.call('post', path, { + 'content-type': 'application/json', + }, + { + 'name': name, + 'read': read, + 'write': write, + 'rules': rules + }); + } + + /** + * Get Collection + * + * Get collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + * + * @param string collectionId + * @throws Exception + * @return Promise + */ + async getCollection(collectionId: string): Promise { + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Update Collection + * + * Update collection by its unique ID. + * + * @param string collectionId + * @param string name + * @param Array read + * @param Array write + * @param Array rules + * @throws Exception + * @return Promise + */ + async updateCollection(collectionId: string, name: string, read: Array, write: Array, rules: Array = []): Promise { + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('put', path, { + 'content-type': 'application/json', + }, + { + 'name': name, + 'read': read, + 'write': write, + 'rules': rules + }); + } + + /** + * Delete Collection + * + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + * + * @param string collectionId + * @throws Exception + * @return Promise + */ + async deleteCollection(collectionId: string): Promise { + let path = '/database/collections/{collectionId}'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Array 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 Exception + * @return Promise + */ + async listDocuments(collectionId: string, filters: Array = [], offset: number = 0, limit: number = 50, orderField: string = '$id', orderType: string = 'ASC', orderCast: string = 'string', search: string = '', first: number = 0, last: number = 0): Promise { + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'filters': filters, + 'offset': offset, + 'limit': limit, + 'orderField': orderField, + 'orderType': orderType, + 'orderCast': orderCast, + 'search': search, + 'first': first, + 'last': last + }); + } + + /** + * Create Document + * + * Create a new Document. + * + * @param string collectionId + * @param DocumentData data + * @param Array read + * @param Array write + * @param string parentDocument + * @param string parentProperty + * @param string parentPropertyType + * @throws Exception + * @return Promise + */ + async createDocument(collectionId: string, data: DocumentData, read: Array, write: Array, parentDocument: string = '', parentProperty: string = '', parentPropertyType: string = 'assign'): Promise { + let path = '/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('post', path, { + 'content-type': 'application/json', + }, + { + 'data': data, + 'read': read, + 'write': write, + 'parentDocument': parentDocument, + 'parentProperty': parentProperty, + 'parentPropertyType': parentPropertyType + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getDocument(collectionId: string, documentId: string): Promise { + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Update Document + * + * @param string collectionId + * @param string documentId + * @param DocumentData data + * @param Array read + * @param Array write + * @throws Exception + * @return Promise + */ + async updateDocument(collectionId: string, documentId: string, data: DocumentData, read: Array, write: Array): Promise { + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + + return await this.client.call('patch', path, { + 'content-type': 'application/json', + }, + { + 'data': data, + 'read': read, + 'write': write + }); + } + + /** + * 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 Exception + * @return Promise + */ + async deleteDocument(collectionId: string, documentId: string): Promise { + let path = '/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}', 'g'), collectionId).replace(new RegExp('{documentId}', 'g'), documentId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Collection Logs + * + * @param string collectionId + * @throws Exception + * @return Promise + */ + async getCollectionLogs(collectionId: string): Promise { + let path = '/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}', 'g'), collectionId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/health.ts b/app/sdks/server-deno/src/services/health.ts new file mode 100644 index 0000000000..df5c18a2cb --- /dev/null +++ b/app/sdks/server-deno/src/services/health.ts @@ -0,0 +1,232 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Health extends Service { + + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @throws Exception + * @return Promise + */ + async get(): Promise { + 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 Promise + */ + async getAntiVirus(): Promise { + 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 Promise + */ + async getCache(): Promise { + 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 Promise + */ + async getDB(): Promise { + 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 Promise + */ + async getQueueCertificates(): Promise { + let path = '/health/queue/certificates'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get Functions Queue + * + * @throws Exception + * @return Promise + */ + async getQueueFunctions(): Promise { + 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 Promise + */ + async getQueueLogs(): Promise { + 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 Promise + */ + async getQueueTasks(): Promise { + 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 Promise + */ + async getQueueUsage(): Promise { + 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 Promise + */ + async getQueueWebhooks(): Promise { + 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 Promise + */ + async getStorageLocal(): Promise { + 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 Promise + */ + async getTime(): Promise { + let path = '/health/time'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/locale.ts b/app/sdks/server-deno/src/services/locale.ts new file mode 100644 index 0000000000..0c42ac61d2 --- /dev/null +++ b/app/sdks/server-deno/src/services/locale.ts @@ -0,0 +1,124 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Locale extends Service { + + /** + * 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 Exception + * @return Promise + */ + async get(): Promise { + let path = '/locale'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * List Continents + * + * List of all continents. You can use the locale header to get the data in a + * supported language. + * + * @throws Exception + * @return Promise + */ + async getContinents(): Promise { + let path = '/locale/continents'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * List Countries + * + * List of all countries. You can use the locale header to get the data in a + * supported language. + * + * @throws Exception + * @return Promise + */ + async getCountries(): Promise { + let path = '/locale/countries'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getCountriesEU(): Promise { + let path = '/locale/countries/eu'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getCountriesPhones(): Promise { + let path = '/locale/countries/phones'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getCurrencies(): Promise { + let path = '/locale/currencies'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/storage.ts b/app/sdks/server-deno/src/services/storage.ts new file mode 100644 index 0000000000..b644d3a61d --- /dev/null +++ b/app/sdks/server-deno/src/services/storage.ts @@ -0,0 +1,198 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Storage extends Service { + + /** + * 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 Exception + * @return Promise + */ + async listFiles(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { + let path = '/storage/files'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType + }); + } + + /** + * 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 | Blob file + * @param Array read + * @param Array write + * @throws Exception + * @return Promise + */ + async createFile(file: File | Blob, read: Array, write: Array): Promise { + let path = '/storage/files'; + + return await this.client.call('post', path, { + 'content-type': 'multipart/form-data', + }, + { + 'file': file, + 'read': read, + 'write': write + }); + } + + /** + * Get File + * + * Get file by its unique ID. This endpoint response returns a JSON object + * with the file metadata. + * + * @param string fileId + * @throws Exception + * @return Promise + */ + async getFile(fileId: string): Promise { + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param string fileId + * @param Array read + * @param Array write + * @throws Exception + * @return Promise + */ + async updateFile(fileId: string, read: Array, write: Array): Promise { + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('put', path, { + 'content-type': 'application/json', + }, + { + 'read': read, + 'write': write + }); + } + + /** + * Delete File + * + * Delete a file by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param string fileId + * @throws Exception + * @return Promise + */ + async deleteFile(fileId: string): Promise { + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getFileDownload(fileId: string): Promise { + let path = '/storage/files/{fileId}/download'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getFilePreview(fileId: string, width: number = 0, height: number = 0, quality: number = 100, background: string = '', output: string = ''): Promise { + let path = '/storage/files/{fileId}/preview'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'width': width, + 'height': height, + 'quality': quality, + 'background': background, + 'output': output + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getFileView(fileId: string, as: string = ''): Promise { + let path = '/storage/files/{fileId}/view'.replace(new RegExp('{fileId}', 'g'), fileId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'as': as + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/teams.ts b/app/sdks/server-deno/src/services/teams.ts new file mode 100644 index 0000000000..f4a936b537 --- /dev/null +++ b/app/sdks/server-deno/src/services/teams.ts @@ -0,0 +1,201 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Teams extends Service { + + /** + * 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 Exception + * @return Promise + */ + async list(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { + let path = '/teams'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType + }); + } + + /** + * 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 Array roles + * @throws Exception + * @return Promise + */ + async create(name: string, roles: Array = ["owner"]): Promise { + let path = '/teams'; + + return await this.client.call('post', path, { + 'content-type': 'application/json', + }, + { + 'name': name, + 'roles': roles + }); + } + + /** + * Get Team + * + * Get team by its unique ID. All team members have read access for this + * resource. + * + * @param string teamId + * @throws Exception + * @return Promise + */ + async get(teamId: string): Promise { + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Update Team + * + * Update team by its unique ID. Only team owners have write access for this + * resource. + * + * @param string teamId + * @param string name + * @throws Exception + * @return Promise + */ + async update(teamId: string, name: string): Promise { + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + return await this.client.call('put', path, { + 'content-type': 'application/json', + }, + { + 'name': name + }); + } + + /** + * Delete Team + * + * Delete team by its unique ID. Only team owners have write access for this + * resource. + * + * @param string teamId + * @throws Exception + * @return Promise + */ + async delete(teamId: string): Promise { + let path = '/teams/{teamId}'.replace(new RegExp('{teamId}', 'g'), teamId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Exception + * @return Promise + */ + async getMemberships(teamId: string): Promise { + let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 Array roles + * @param string url + * @param string name + * @throws Exception + * @return Promise + */ + async createMembership(teamId: string, email: string, roles: Array, url: string, name: string = ''): Promise { + let path = '/teams/{teamId}/memberships'.replace(new RegExp('{teamId}', 'g'), teamId); + + return await this.client.call('post', path, { + 'content-type': 'application/json', + }, + { + 'email': email, + 'name': name, + 'roles': roles, + 'url': url + }); + } + + /** + * 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 Exception + * @return Promise + */ + async deleteMembership(teamId: string, inviteId: string): Promise { + let path = '/teams/{teamId}/memberships/{inviteId}'.replace(new RegExp('{teamId}', 'g'), teamId).replace(new RegExp('{inviteId}', 'g'), inviteId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } +} \ No newline at end of file diff --git a/app/sdks/server-deno/src/services/users.ts b/app/sdks/server-deno/src/services/users.ts new file mode 100644 index 0000000000..ac48507f08 --- /dev/null +++ b/app/sdks/server-deno/src/services/users.ts @@ -0,0 +1,214 @@ +import { Service } from "../service.ts"; +import { DocumentData } from '../client.ts' + +export class Users extends Service { + + /** + * 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 Exception + * @return Promise + */ + async list(search: string = '', limit: number = 25, offset: number = 0, orderType: string = 'ASC'): Promise { + let path = '/users'; + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + 'search': search, + 'limit': limit, + 'offset': offset, + 'orderType': orderType + }); + } + + /** + * Create User + * + * Create a new user. + * + * @param string email + * @param string password + * @param string name + * @throws Exception + * @return Promise + */ + async create(email: string, password: string, name: string = ''): Promise { + let path = '/users'; + + return await this.client.call('post', path, { + 'content-type': 'application/json', + }, + { + 'email': email, + 'password': password, + 'name': name + }); + } + + /** + * Get User + * + * Get user by its unique ID. + * + * @param string userId + * @throws Exception + * @return Promise + */ + async get(userId: string): Promise { + let path = '/users/{userId}'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get User Logs + * + * Get user activity logs list by its unique ID. + * + * @param string userId + * @throws Exception + * @return Promise + */ + async getLogs(userId: string): Promise { + let path = '/users/{userId}/logs'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Get User Preferences + * + * Get user preferences by its unique ID. + * + * @param string userId + * @throws Exception + * @return Promise + */ + async getPrefs(userId: string): Promise { + let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * 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 DocumentData prefs + * @throws Exception + * @return Promise + */ + async updatePrefs(userId: string, prefs: DocumentData): Promise { + let path = '/users/{userId}/prefs'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('patch', path, { + 'content-type': 'application/json', + }, + { + 'prefs': prefs + }); + } + + /** + * Get User Sessions + * + * Get user sessions list by its unique ID. + * + * @param string userId + * @throws Exception + * @return Promise + */ + async getSessions(userId: string): Promise { + let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('get', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Delete User Sessions + * + * Delete all user sessions by its unique ID. + * + * @param string userId + * @throws Exception + * @return Promise + */ + async deleteSessions(userId: string): Promise { + let path = '/users/{userId}/sessions'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('delete', path, { + 'content-type': 'application/json', + }, + { + }); + } + + /** + * Delete User Session + * + * Delete user sessions by its unique ID. + * + * @param string userId + * @param string sessionId + * @throws Exception + * @return Promise + */ + async deleteSession(userId: string, sessionId: string): Promise { + 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', + }, + { + }); + } + + /** + * Update User Status + * + * Update user status by its unique ID. + * + * @param string userId + * @param string status + * @throws Exception + * @return Promise + */ + async updateStatus(userId: string, status: string): Promise { + let path = '/users/{userId}/status'.replace(new RegExp('{userId}', 'g'), userId); + + return await this.client.call('patch', path, { + 'content-type': 'application/json', + }, + { + 'status': status + }); + } +} \ No newline at end of file diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 19d2deb3b8..2843443924 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -15,6 +15,7 @@ use Appwrite\SDK\Language\Node; use Appwrite\SDK\Language\Python; use Appwrite\SDK\Language\Ruby; use Appwrite\SDK\Language\Dart; +use Appwrite\SDK\Language\Deno; use Appwrite\SDK\Language\Go; use Appwrite\SDK\Language\Java; @@ -107,6 +108,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ->setBowerPackage('appwrite') ; break; + case 'deno': + $config = new Deno(); + break; case 'python': $config = new Python(); $config diff --git a/app/views/console/settings/index.phtml b/app/views/console/settings/index.phtml index 0202400cc0..e6def1b2ee 100644 --- a/app/views/console/settings/index.phtml +++ b/app/views/console/settings/index.phtml @@ -27,39 +27,36 @@ $customDomainsTarget = $this->getParam('customDomainsTarget', false);
  • Overview

    -
    +
    +
    +
    + - - -
    -
    -
    + - -
    - + + +
    +
    - -
    - -
    +
    - - -
    - -
    - - -
    - -
    -
    + +
    -
    +

    Danger Zone

    + +
    +

    This is the area where you can delete your project.

    + +

    By deleting your project you will lose all your project metadata, resources and stats.

    + +

    PLEASE NOTE: Project deletion is irreversible.

    + +
    + + + + +
    +
    -
    - + +
    + +
    + +
    + + +
    + +
    + + +
    +