diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..fa4d35e
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1 @@
+# Change Log
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index d81b095..47cfdfb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,12 @@
-MIT License
+Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
+All rights reserved.
-Copyright (c) 2022 Appwrite
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ 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.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+ 3. Neither the name of the copyright holder 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/README.md b/README.md
index 306336a..93ffba5 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,111 @@
-# sdk-for-console
\ No newline at end of file
+# Appwrite Console SDK
+
+
+
+[](https://travis-ci.com/appwrite/sdk-generator)
+[](https://twitter.com/appwrite)
+[](https://appwrite.io/discord)
+
+**This SDK is compatible with Appwrite server version 1.2.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-console/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 Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
+
+
+
+## Installation
+
+### NPM
+
+To install via [NPM](https://www.npmjs.com/):
+
+```bash
+npm install appwrite --save
+```
+
+If you're using a bundler (like [Rollup](https://rollupjs.org/) or [webpack](https://webpack.js.org/)), you can import the Appwrite module when you need it:
+
+```js
+import { Client, Account } from "appwrite";
+```
+
+### CDN
+
+To install with a CDN (content delivery network) add the following scripts to the bottom of your
tag, but before you use any Appwrite services:
+
+```html
+
+```
+
+
+## Getting Started
+
+### Add your Web Platform
+For you to init your SDK and interact with Appwrite services you need to add a web platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before and click the 'Add Platform' button.
+
+From the options, choose to add a **Web** platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.
+
+### Init your SDK
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.
+
+```js
+// Init your Web SDK
+const client = new Client();
+
+client
+ .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
+ .setProject('455x34dfkj') // Your project ID
+;
+```
+
+### Make Your First Request
+Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
+
+```js
+const account = new Account(client);
+
+// Register User
+account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe')
+ .then(function (response) {
+ console.log(response);
+ }, function (error) {
+ console.log(error);
+ });
+
+```
+
+### Full Example
+```js
+// Init your Web SDK
+const client = new Client();
+
+client
+ .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
+ .setProject('455x34dfkj')
+;
+
+const account = new Account(client);
+
+// Register User
+account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe')
+ .then(function (response) {
+ console.log(response);
+ }, function (error) {
+ console.log(error);
+ });
+```
+
+### Learn more
+You can use the following resources to learn more and get help
+- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-flutter)
+- 📜 [Appwrite Docs](https://appwrite.io/docs)
+- 💬 [Discord Community](https://appwrite.io/discord)
+- 🚂 [Appwrite Flutter Playground](https://github.com/appwrite/playground-for-flutter)
+
+
+## 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/dist/cjs/package.json b/dist/cjs/package.json
new file mode 100644
index 0000000..6a0d2ef
--- /dev/null
+++ b/dist/cjs/package.json
@@ -0,0 +1,3 @@
+{
+ "type": "commonjs"
+}
\ No newline at end of file
diff --git a/dist/esm/package.json b/dist/esm/package.json
new file mode 100644
index 0000000..96ae6e5
--- /dev/null
+++ b/dist/esm/package.json
@@ -0,0 +1,3 @@
+{
+ "type": "module"
+}
\ No newline at end of file
diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md
new file mode 100644
index 0000000..a1ff484
--- /dev/null
+++ b/docs/examples/account/create-anonymous-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createAnonymousSession();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-email-session.md b/docs/examples/account/create-email-session.md
new file mode 100644
index 0000000..43a0aa2
--- /dev/null
+++ b/docs/examples/account/create-email-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createEmailSession('email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md
new file mode 100644
index 0000000..3b5c7ed
--- /dev/null
+++ b/docs/examples/account/create-j-w-t.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createJWT();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-magic-u-r-l-session.md b/docs/examples/account/create-magic-u-r-l-session.md
new file mode 100644
index 0000000..9339d67
--- /dev/null
+++ b/docs/examples/account/create-magic-u-r-l-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createMagicURLSession('[USER_ID]', 'email@example.com');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-o-auth2session.md b/docs/examples/account/create-o-auth2session.md
new file mode 100644
index 0000000..25e67b1
--- /dev/null
+++ b/docs/examples/account/create-o-auth2session.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+// Go to OAuth provider login page
+account.createOAuth2Session('amazon');
+
diff --git a/docs/examples/account/create-phone-session.md b/docs/examples/account/create-phone-session.md
new file mode 100644
index 0000000..df2efe0
--- /dev/null
+++ b/docs/examples/account/create-phone-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createPhoneSession('[USER_ID]', '+12065550100');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md
new file mode 100644
index 0000000..f325a92
--- /dev/null
+++ b/docs/examples/account/create-phone-verification.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createPhoneVerification();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md
new file mode 100644
index 0000000..4f737ed
--- /dev/null
+++ b/docs/examples/account/create-recovery.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createRecovery('email@example.com', 'https://example.com');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md
new file mode 100644
index 0000000..0e7162c
--- /dev/null
+++ b/docs/examples/account/create-verification.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.createVerification('https://example.com');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md
new file mode 100644
index 0000000..5b275bd
--- /dev/null
+++ b/docs/examples/account/create.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.create('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md
new file mode 100644
index 0000000..a23a1f2
--- /dev/null
+++ b/docs/examples/account/delete-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.deleteSession('[SESSION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md
new file mode 100644
index 0000000..5849538
--- /dev/null
+++ b/docs/examples/account/delete-sessions.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.deleteSessions();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md
new file mode 100644
index 0000000..a355c68
--- /dev/null
+++ b/docs/examples/account/get-prefs.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.getPrefs();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md
new file mode 100644
index 0000000..dd0c086
--- /dev/null
+++ b/docs/examples/account/get-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.getSession('[SESSION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md
new file mode 100644
index 0000000..fd26ad7
--- /dev/null
+++ b/docs/examples/account/get.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.get();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md
new file mode 100644
index 0000000..4ce60e4
--- /dev/null
+++ b/docs/examples/account/list-logs.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.listLogs();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md
new file mode 100644
index 0000000..d7e901c
--- /dev/null
+++ b/docs/examples/account/list-sessions.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.listSessions();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md
new file mode 100644
index 0000000..6e3d603
--- /dev/null
+++ b/docs/examples/account/update-email.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateEmail('email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md
new file mode 100644
index 0000000..1934263
--- /dev/null
+++ b/docs/examples/account/update-magic-u-r-l-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateMagicURLSession('[USER_ID]', '[SECRET]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md
new file mode 100644
index 0000000..24a27f1
--- /dev/null
+++ b/docs/examples/account/update-name.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateName('[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md
new file mode 100644
index 0000000..5ace968
--- /dev/null
+++ b/docs/examples/account/update-password.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updatePassword('password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md
new file mode 100644
index 0000000..8ad2051
--- /dev/null
+++ b/docs/examples/account/update-phone-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updatePhoneSession('[USER_ID]', '[SECRET]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md
new file mode 100644
index 0000000..b96f3be
--- /dev/null
+++ b/docs/examples/account/update-phone-verification.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updatePhoneVerification('[USER_ID]', '[SECRET]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md
new file mode 100644
index 0000000..33dac51
--- /dev/null
+++ b/docs/examples/account/update-phone.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updatePhone('+12065550100', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md
new file mode 100644
index 0000000..4948631
--- /dev/null
+++ b/docs/examples/account/update-prefs.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updatePrefs({});
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md
new file mode 100644
index 0000000..85915f1
--- /dev/null
+++ b/docs/examples/account/update-recovery.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateRecovery('[USER_ID]', '[SECRET]', 'password', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md
new file mode 100644
index 0000000..70fe5fa
--- /dev/null
+++ b/docs/examples/account/update-session.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateSession('[SESSION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md
new file mode 100644
index 0000000..a7c7817
--- /dev/null
+++ b/docs/examples/account/update-status.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateStatus();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md
new file mode 100644
index 0000000..27d5cbc
--- /dev/null
+++ b/docs/examples/account/update-verification.md
@@ -0,0 +1,18 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client();
+
+const account = new Account(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = account.updateVerification('[USER_ID]', '[SECRET]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md
new file mode 100644
index 0000000..20480ce
--- /dev/null
+++ b/docs/examples/avatars/get-browser.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getBrowser('aa');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md
new file mode 100644
index 0000000..cdbc4a0
--- /dev/null
+++ b/docs/examples/avatars/get-credit-card.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getCreditCard('amex');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md
new file mode 100644
index 0000000..f8db5c3
--- /dev/null
+++ b/docs/examples/avatars/get-favicon.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getFavicon('https://example.com');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md
new file mode 100644
index 0000000..e609fb2
--- /dev/null
+++ b/docs/examples/avatars/get-flag.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getFlag('af');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md
new file mode 100644
index 0000000..468f6a3
--- /dev/null
+++ b/docs/examples/avatars/get-image.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getImage('https://example.com');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md
new file mode 100644
index 0000000..d061813
--- /dev/null
+++ b/docs/examples/avatars/get-initials.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getInitials();
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md
new file mode 100644
index 0000000..86fed12
--- /dev/null
+++ b/docs/examples/avatars/get-q-r.md
@@ -0,0 +1,14 @@
+import { Client, Avatars } from "appwrite";
+
+const client = new Client();
+
+const avatars = new Avatars(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = avatars.getQR('[TEXT]');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md
new file mode 100644
index 0000000..b8a2143
--- /dev/null
+++ b/docs/examples/databases/create-boolean-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md
new file mode 100644
index 0000000..d5367d0
--- /dev/null
+++ b/docs/examples/databases/create-collection.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md
new file mode 100644
index 0000000..a3921bb
--- /dev/null
+++ b/docs/examples/databases/create-datetime-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createDatetimeAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md
new file mode 100644
index 0000000..5b8d89a
--- /dev/null
+++ b/docs/examples/databases/create-document.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', {});
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md
new file mode 100644
index 0000000..50557c0
--- /dev/null
+++ b/docs/examples/databases/create-email-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md
new file mode 100644
index 0000000..92e8fae
--- /dev/null
+++ b/docs/examples/databases/create-enum-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md
new file mode 100644
index 0000000..4c4159f
--- /dev/null
+++ b/docs/examples/databases/create-float-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md
new file mode 100644
index 0000000..b706ae6
--- /dev/null
+++ b/docs/examples/databases/create-index.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createIndex('[DATABASE_ID]', '[COLLECTION_ID]', '', 'key', []);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md
new file mode 100644
index 0000000..534a61d
--- /dev/null
+++ b/docs/examples/databases/create-integer-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md
new file mode 100644
index 0000000..9ef9ad7
--- /dev/null
+++ b/docs/examples/databases/create-ip-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md
new file mode 100644
index 0000000..1553ea9
--- /dev/null
+++ b/docs/examples/databases/create-string-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md
new file mode 100644
index 0000000..8e75aff
--- /dev/null
+++ b/docs/examples/databases/create-url-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.createUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md
new file mode 100644
index 0000000..7936a85
--- /dev/null
+++ b/docs/examples/databases/create.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.create('[DATABASE_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md
new file mode 100644
index 0000000..8a2ec9b
--- /dev/null
+++ b/docs/examples/databases/delete-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.deleteAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md
new file mode 100644
index 0000000..724ae21
--- /dev/null
+++ b/docs/examples/databases/delete-collection.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.deleteCollection('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md
new file mode 100644
index 0000000..e201280
--- /dev/null
+++ b/docs/examples/databases/delete-document.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md
new file mode 100644
index 0000000..ecd0b48
--- /dev/null
+++ b/docs/examples/databases/delete-index.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.deleteIndex('[DATABASE_ID]', '[COLLECTION_ID]', '');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md
new file mode 100644
index 0000000..a625395
--- /dev/null
+++ b/docs/examples/databases/delete.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.delete('[DATABASE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md
new file mode 100644
index 0000000..de43524
--- /dev/null
+++ b/docs/examples/databases/get-attribute.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-collection-usage.md b/docs/examples/databases/get-collection-usage.md
new file mode 100644
index 0000000..67fc170
--- /dev/null
+++ b/docs/examples/databases/get-collection-usage.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getCollectionUsage('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md
new file mode 100644
index 0000000..ec069bc
--- /dev/null
+++ b/docs/examples/databases/get-collection.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getCollection('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-database-usage.md b/docs/examples/databases/get-database-usage.md
new file mode 100644
index 0000000..d9cbedc
--- /dev/null
+++ b/docs/examples/databases/get-database-usage.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getDatabaseUsage('[DATABASE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md
new file mode 100644
index 0000000..89314e8
--- /dev/null
+++ b/docs/examples/databases/get-document.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md
new file mode 100644
index 0000000..ccb1913
--- /dev/null
+++ b/docs/examples/databases/get-index.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getIndex('[DATABASE_ID]', '[COLLECTION_ID]', '');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get-usage.md b/docs/examples/databases/get-usage.md
new file mode 100644
index 0000000..9408c58
--- /dev/null
+++ b/docs/examples/databases/get-usage.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.getUsage();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md
new file mode 100644
index 0000000..0f37613
--- /dev/null
+++ b/docs/examples/databases/get.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.get('[DATABASE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md
new file mode 100644
index 0000000..22f0df4
--- /dev/null
+++ b/docs/examples/databases/list-attributes.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listAttributes('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-collection-logs.md b/docs/examples/databases/list-collection-logs.md
new file mode 100644
index 0000000..d8cf623
--- /dev/null
+++ b/docs/examples/databases/list-collection-logs.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listCollectionLogs('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md
new file mode 100644
index 0000000..5f75702
--- /dev/null
+++ b/docs/examples/databases/list-collections.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listCollections('[DATABASE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-document-logs.md b/docs/examples/databases/list-document-logs.md
new file mode 100644
index 0000000..220fb28
--- /dev/null
+++ b/docs/examples/databases/list-document-logs.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listDocumentLogs('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md
new file mode 100644
index 0000000..a4afd21
--- /dev/null
+++ b/docs/examples/databases/list-documents.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listDocuments('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md
new file mode 100644
index 0000000..33dfdd3
--- /dev/null
+++ b/docs/examples/databases/list-indexes.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listIndexes('[DATABASE_ID]', '[COLLECTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list-logs.md b/docs/examples/databases/list-logs.md
new file mode 100644
index 0000000..e9af319
--- /dev/null
+++ b/docs/examples/databases/list-logs.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.listLogs('[DATABASE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md
new file mode 100644
index 0000000..44a0fd9
--- /dev/null
+++ b/docs/examples/databases/list.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.list();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md
new file mode 100644
index 0000000..a46583f
--- /dev/null
+++ b/docs/examples/databases/update-collection.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md
new file mode 100644
index 0000000..2d59a8a
--- /dev/null
+++ b/docs/examples/databases/update-document.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.updateDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md
new file mode 100644
index 0000000..3bb577d
--- /dev/null
+++ b/docs/examples/databases/update.md
@@ -0,0 +1,18 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+const databases = new Databases(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = databases.update('[DATABASE_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md
new file mode 100644
index 0000000..6e99308
--- /dev/null
+++ b/docs/examples/functions/create-build.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.createBuild('[FUNCTION_ID]', '[DEPLOYMENT_ID]', '[BUILD_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md
new file mode 100644
index 0000000..57687bc
--- /dev/null
+++ b/docs/examples/functions/create-deployment.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.createDeployment('[FUNCTION_ID]', '[ENTRYPOINT]', document.getElementById('uploader').files[0], false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md
new file mode 100644
index 0000000..2b64bc9
--- /dev/null
+++ b/docs/examples/functions/create-execution.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.createExecution('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md
new file mode 100644
index 0000000..9728307
--- /dev/null
+++ b/docs/examples/functions/create-variable.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.createVariable('[FUNCTION_ID]', '[KEY]', '[VALUE]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md
new file mode 100644
index 0000000..4fe6fec
--- /dev/null
+++ b/docs/examples/functions/create.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.create('[FUNCTION_ID]', '[NAME]', ["any"], 'node-14.5');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md
new file mode 100644
index 0000000..8f2c646
--- /dev/null
+++ b/docs/examples/functions/delete-deployment.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.deleteDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md
new file mode 100644
index 0000000..5cb80d2
--- /dev/null
+++ b/docs/examples/functions/delete-variable.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.deleteVariable('[FUNCTION_ID]', '[VARIABLE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md
new file mode 100644
index 0000000..4ac987d
--- /dev/null
+++ b/docs/examples/functions/delete.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.delete('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md
new file mode 100644
index 0000000..a07fb7e
--- /dev/null
+++ b/docs/examples/functions/get-deployment.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.getDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md
new file mode 100644
index 0000000..f5046a0
--- /dev/null
+++ b/docs/examples/functions/get-execution.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get-function-usage.md b/docs/examples/functions/get-function-usage.md
new file mode 100644
index 0000000..f9d4163
--- /dev/null
+++ b/docs/examples/functions/get-function-usage.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.getFunctionUsage('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get-usage.md b/docs/examples/functions/get-usage.md
new file mode 100644
index 0000000..d183a45
--- /dev/null
+++ b/docs/examples/functions/get-usage.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.getUsage();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md
new file mode 100644
index 0000000..cca9639
--- /dev/null
+++ b/docs/examples/functions/get-variable.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.getVariable('[FUNCTION_ID]', '[VARIABLE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md
new file mode 100644
index 0000000..b6e32b5
--- /dev/null
+++ b/docs/examples/functions/get.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.get('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md
new file mode 100644
index 0000000..843dd07
--- /dev/null
+++ b/docs/examples/functions/list-deployments.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.listDeployments('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md
new file mode 100644
index 0000000..99186a9
--- /dev/null
+++ b/docs/examples/functions/list-executions.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.listExecutions('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md
new file mode 100644
index 0000000..d5e1f66
--- /dev/null
+++ b/docs/examples/functions/list-runtimes.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.listRuntimes();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md
new file mode 100644
index 0000000..9461ce6
--- /dev/null
+++ b/docs/examples/functions/list-variables.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.listVariables('[FUNCTION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md
new file mode 100644
index 0000000..730a90f
--- /dev/null
+++ b/docs/examples/functions/list.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.list();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md
new file mode 100644
index 0000000..b231ae5
--- /dev/null
+++ b/docs/examples/functions/update-deployment.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.updateDeployment('[FUNCTION_ID]', '[DEPLOYMENT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md
new file mode 100644
index 0000000..b3f0439
--- /dev/null
+++ b/docs/examples/functions/update-variable.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.updateVariable('[FUNCTION_ID]', '[VARIABLE_ID]', '[KEY]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md
new file mode 100644
index 0000000..c025fc7
--- /dev/null
+++ b/docs/examples/functions/update.md
@@ -0,0 +1,18 @@
+import { Client, Functions } from "appwrite";
+
+const client = new Client();
+
+const functions = new Functions(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = functions.update('[FUNCTION_ID]', '[NAME]', ["any"]);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md
new file mode 100644
index 0000000..331e828
--- /dev/null
+++ b/docs/examples/graphql/mutation.md
@@ -0,0 +1,18 @@
+import { Client, Graphql } from "appwrite";
+
+const client = new Client();
+
+const graphql = new Graphql(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = graphql.mutation({});
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md
new file mode 100644
index 0000000..b56829c
--- /dev/null
+++ b/docs/examples/graphql/query.md
@@ -0,0 +1,18 @@
+import { Client, Graphql } from "appwrite";
+
+const client = new Client();
+
+const graphql = new Graphql(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = graphql.query({});
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md
new file mode 100644
index 0000000..0b14fa8
--- /dev/null
+++ b/docs/examples/health/get-antivirus.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getAntivirus();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md
new file mode 100644
index 0000000..a754f9b
--- /dev/null
+++ b/docs/examples/health/get-cache.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getCache();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md
new file mode 100644
index 0000000..86ff4a7
--- /dev/null
+++ b/docs/examples/health/get-d-b.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getDB();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md
new file mode 100644
index 0000000..2b4dc05
--- /dev/null
+++ b/docs/examples/health/get-queue-certificates.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getQueueCertificates();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md
new file mode 100644
index 0000000..9d6f3b7
--- /dev/null
+++ b/docs/examples/health/get-queue-functions.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getQueueFunctions();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md
new file mode 100644
index 0000000..010e603
--- /dev/null
+++ b/docs/examples/health/get-queue-logs.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getQueueLogs();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md
new file mode 100644
index 0000000..2687863
--- /dev/null
+++ b/docs/examples/health/get-queue-webhooks.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getQueueWebhooks();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md
new file mode 100644
index 0000000..b11daa2
--- /dev/null
+++ b/docs/examples/health/get-storage-local.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getStorageLocal();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md
new file mode 100644
index 0000000..1f617e1
--- /dev/null
+++ b/docs/examples/health/get-time.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.getTime();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md
new file mode 100644
index 0000000..b1d6be4
--- /dev/null
+++ b/docs/examples/health/get.md
@@ -0,0 +1,18 @@
+import { Client, Health } from "appwrite";
+
+const client = new Client();
+
+const health = new Health(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = health.get();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md
new file mode 100644
index 0000000..634256c
--- /dev/null
+++ b/docs/examples/locale/get.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.get();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md
new file mode 100644
index 0000000..e79a8ea
--- /dev/null
+++ b/docs/examples/locale/list-continents.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listContinents();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md
new file mode 100644
index 0000000..964bed3
--- /dev/null
+++ b/docs/examples/locale/list-countries-e-u.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listCountriesEU();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md
new file mode 100644
index 0000000..65ec4f4
--- /dev/null
+++ b/docs/examples/locale/list-countries-phones.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listCountriesPhones();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md
new file mode 100644
index 0000000..6b7e8e6
--- /dev/null
+++ b/docs/examples/locale/list-countries.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listCountries();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md
new file mode 100644
index 0000000..3638c2e
--- /dev/null
+++ b/docs/examples/locale/list-currencies.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listCurrencies();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md
new file mode 100644
index 0000000..bffa5eb
--- /dev/null
+++ b/docs/examples/locale/list-languages.md
@@ -0,0 +1,18 @@
+import { Client, Locale } from "appwrite";
+
+const client = new Client();
+
+const locale = new Locale(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = locale.listLanguages();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/create-domain.md b/docs/examples/projects/create-domain.md
new file mode 100644
index 0000000..452a594
--- /dev/null
+++ b/docs/examples/projects/create-domain.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.createDomain('[PROJECT_ID]', '');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/create-key.md b/docs/examples/projects/create-key.md
new file mode 100644
index 0000000..8bd57d5
--- /dev/null
+++ b/docs/examples/projects/create-key.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.createKey('[PROJECT_ID]', '[NAME]', []);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/create-platform.md b/docs/examples/projects/create-platform.md
new file mode 100644
index 0000000..c2c6a03
--- /dev/null
+++ b/docs/examples/projects/create-platform.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.createPlatform('[PROJECT_ID]', 'web', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/create-webhook.md b/docs/examples/projects/create-webhook.md
new file mode 100644
index 0000000..1469e6b
--- /dev/null
+++ b/docs/examples/projects/create-webhook.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.createWebhook('[PROJECT_ID]', '[NAME]', [], 'https://example.com', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/create.md b/docs/examples/projects/create.md
new file mode 100644
index 0000000..792515c
--- /dev/null
+++ b/docs/examples/projects/create.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.create('[PROJECT_ID]', '[NAME]', '[TEAM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/delete-domain.md b/docs/examples/projects/delete-domain.md
new file mode 100644
index 0000000..266d343
--- /dev/null
+++ b/docs/examples/projects/delete-domain.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.deleteDomain('[PROJECT_ID]', '[DOMAIN_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/delete-key.md b/docs/examples/projects/delete-key.md
new file mode 100644
index 0000000..0b227e7
--- /dev/null
+++ b/docs/examples/projects/delete-key.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.deleteKey('[PROJECT_ID]', '[KEY_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/delete-platform.md b/docs/examples/projects/delete-platform.md
new file mode 100644
index 0000000..6813620
--- /dev/null
+++ b/docs/examples/projects/delete-platform.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.deletePlatform('[PROJECT_ID]', '[PLATFORM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/delete-webhook.md b/docs/examples/projects/delete-webhook.md
new file mode 100644
index 0000000..3edbdad
--- /dev/null
+++ b/docs/examples/projects/delete-webhook.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.deleteWebhook('[PROJECT_ID]', '[WEBHOOK_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/delete.md b/docs/examples/projects/delete.md
new file mode 100644
index 0000000..1e47970
--- /dev/null
+++ b/docs/examples/projects/delete.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.delete('[PROJECT_ID]', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get-domain.md b/docs/examples/projects/get-domain.md
new file mode 100644
index 0000000..a90d5ee
--- /dev/null
+++ b/docs/examples/projects/get-domain.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.getDomain('[PROJECT_ID]', '[DOMAIN_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get-key.md b/docs/examples/projects/get-key.md
new file mode 100644
index 0000000..59a4224
--- /dev/null
+++ b/docs/examples/projects/get-key.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.getKey('[PROJECT_ID]', '[KEY_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get-platform.md b/docs/examples/projects/get-platform.md
new file mode 100644
index 0000000..8eaea33
--- /dev/null
+++ b/docs/examples/projects/get-platform.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.getPlatform('[PROJECT_ID]', '[PLATFORM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get-usage.md b/docs/examples/projects/get-usage.md
new file mode 100644
index 0000000..be7ee43
--- /dev/null
+++ b/docs/examples/projects/get-usage.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.getUsage('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get-webhook.md b/docs/examples/projects/get-webhook.md
new file mode 100644
index 0000000..b636a79
--- /dev/null
+++ b/docs/examples/projects/get-webhook.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.getWebhook('[PROJECT_ID]', '[WEBHOOK_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/get.md b/docs/examples/projects/get.md
new file mode 100644
index 0000000..ac20f56
--- /dev/null
+++ b/docs/examples/projects/get.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.get('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/list-domains.md b/docs/examples/projects/list-domains.md
new file mode 100644
index 0000000..2c4a741
--- /dev/null
+++ b/docs/examples/projects/list-domains.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.listDomains('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/list-keys.md b/docs/examples/projects/list-keys.md
new file mode 100644
index 0000000..957531a
--- /dev/null
+++ b/docs/examples/projects/list-keys.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.listKeys('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/list-platforms.md b/docs/examples/projects/list-platforms.md
new file mode 100644
index 0000000..100be04
--- /dev/null
+++ b/docs/examples/projects/list-platforms.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.listPlatforms('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/list-webhooks.md b/docs/examples/projects/list-webhooks.md
new file mode 100644
index 0000000..093b9e9
--- /dev/null
+++ b/docs/examples/projects/list-webhooks.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.listWebhooks('[PROJECT_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/list.md b/docs/examples/projects/list.md
new file mode 100644
index 0000000..a576843
--- /dev/null
+++ b/docs/examples/projects/list.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.list();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-auth-duration.md b/docs/examples/projects/update-auth-duration.md
new file mode 100644
index 0000000..ab7b010
--- /dev/null
+++ b/docs/examples/projects/update-auth-duration.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateAuthDuration('[PROJECT_ID]', 0);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-auth-limit.md b/docs/examples/projects/update-auth-limit.md
new file mode 100644
index 0000000..7cc850a
--- /dev/null
+++ b/docs/examples/projects/update-auth-limit.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateAuthLimit('[PROJECT_ID]', 0);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-auth-sessions-limit.md b/docs/examples/projects/update-auth-sessions-limit.md
new file mode 100644
index 0000000..52954d7
--- /dev/null
+++ b/docs/examples/projects/update-auth-sessions-limit.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateAuthSessionsLimit('[PROJECT_ID]', 1);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-auth-status.md b/docs/examples/projects/update-auth-status.md
new file mode 100644
index 0000000..400d5a4
--- /dev/null
+++ b/docs/examples/projects/update-auth-status.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateAuthStatus('[PROJECT_ID]', 'email-password', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-domain-verification.md b/docs/examples/projects/update-domain-verification.md
new file mode 100644
index 0000000..c632ad1
--- /dev/null
+++ b/docs/examples/projects/update-domain-verification.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateDomainVerification('[PROJECT_ID]', '[DOMAIN_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-key.md b/docs/examples/projects/update-key.md
new file mode 100644
index 0000000..627bf6c
--- /dev/null
+++ b/docs/examples/projects/update-key.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateKey('[PROJECT_ID]', '[KEY_ID]', '[NAME]', []);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-o-auth2.md b/docs/examples/projects/update-o-auth2.md
new file mode 100644
index 0000000..df22de5
--- /dev/null
+++ b/docs/examples/projects/update-o-auth2.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateOAuth2('[PROJECT_ID]', 'amazon');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-platform.md b/docs/examples/projects/update-platform.md
new file mode 100644
index 0000000..0d6b919
--- /dev/null
+++ b/docs/examples/projects/update-platform.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updatePlatform('[PROJECT_ID]', '[PLATFORM_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-service-status.md b/docs/examples/projects/update-service-status.md
new file mode 100644
index 0000000..ae95091
--- /dev/null
+++ b/docs/examples/projects/update-service-status.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateServiceStatus('[PROJECT_ID]', 'account', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-webhook-signature.md b/docs/examples/projects/update-webhook-signature.md
new file mode 100644
index 0000000..3545f9a
--- /dev/null
+++ b/docs/examples/projects/update-webhook-signature.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateWebhookSignature('[PROJECT_ID]', '[WEBHOOK_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update-webhook.md b/docs/examples/projects/update-webhook.md
new file mode 100644
index 0000000..45ecb8b
--- /dev/null
+++ b/docs/examples/projects/update-webhook.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], 'https://example.com', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/projects/update.md b/docs/examples/projects/update.md
new file mode 100644
index 0000000..661eb11
--- /dev/null
+++ b/docs/examples/projects/update.md
@@ -0,0 +1,18 @@
+import { Client, Projects } from "appwrite";
+
+const client = new Client();
+
+const projects = new Projects(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = projects.update('[PROJECT_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md
new file mode 100644
index 0000000..e2c8bb3
--- /dev/null
+++ b/docs/examples/storage/create-bucket.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.createBucket('[BUCKET_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md
new file mode 100644
index 0000000..10992d2
--- /dev/null
+++ b/docs/examples/storage/create-file.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.createFile('[BUCKET_ID]', '[FILE_ID]', document.getElementById('uploader').files[0]);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md
new file mode 100644
index 0000000..a8580f9
--- /dev/null
+++ b/docs/examples/storage/delete-bucket.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.deleteBucket('[BUCKET_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md
new file mode 100644
index 0000000..4512a8c
--- /dev/null
+++ b/docs/examples/storage/delete-file.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.deleteFile('[BUCKET_ID]', '[FILE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/get-bucket-usage.md b/docs/examples/storage/get-bucket-usage.md
new file mode 100644
index 0000000..61ef7fa
--- /dev/null
+++ b/docs/examples/storage/get-bucket-usage.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.getBucketUsage('[BUCKET_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md
new file mode 100644
index 0000000..3ffd9f3
--- /dev/null
+++ b/docs/examples/storage/get-bucket.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.getBucket('[BUCKET_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md
new file mode 100644
index 0000000..17c0660
--- /dev/null
+++ b/docs/examples/storage/get-file-download.md
@@ -0,0 +1,14 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md
new file mode 100644
index 0000000..52866d1
--- /dev/null
+++ b/docs/examples/storage/get-file-preview.md
@@ -0,0 +1,14 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = storage.getFilePreview('[BUCKET_ID]', '[FILE_ID]');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md
new file mode 100644
index 0000000..7bb6c67
--- /dev/null
+++ b/docs/examples/storage/get-file-view.md
@@ -0,0 +1,14 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]');
+
+console.log(result); // Resource URL
\ No newline at end of file
diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md
new file mode 100644
index 0000000..3263865
--- /dev/null
+++ b/docs/examples/storage/get-file.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/get-usage.md b/docs/examples/storage/get-usage.md
new file mode 100644
index 0000000..a5ce585
--- /dev/null
+++ b/docs/examples/storage/get-usage.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.getUsage();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md
new file mode 100644
index 0000000..4f916c1
--- /dev/null
+++ b/docs/examples/storage/list-buckets.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.listBuckets();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md
new file mode 100644
index 0000000..92d7574
--- /dev/null
+++ b/docs/examples/storage/list-files.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.listFiles('[BUCKET_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md
new file mode 100644
index 0000000..c0b6b41
--- /dev/null
+++ b/docs/examples/storage/update-bucket.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.updateBucket('[BUCKET_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md
new file mode 100644
index 0000000..1313e30
--- /dev/null
+++ b/docs/examples/storage/update-file.md
@@ -0,0 +1,18 @@
+import { Client, Storage } from "appwrite";
+
+const client = new Client();
+
+const storage = new Storage(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = storage.updateFile('[BUCKET_ID]', '[FILE_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md
new file mode 100644
index 0000000..6cb7d87
--- /dev/null
+++ b/docs/examples/teams/create-membership.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.createMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md
new file mode 100644
index 0000000..2c40c90
--- /dev/null
+++ b/docs/examples/teams/create.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.create('[TEAM_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md
new file mode 100644
index 0000000..828674a
--- /dev/null
+++ b/docs/examples/teams/delete-membership.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.deleteMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md
new file mode 100644
index 0000000..b9b79ed
--- /dev/null
+++ b/docs/examples/teams/delete.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.delete('[TEAM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md
new file mode 100644
index 0000000..cce63e7
--- /dev/null
+++ b/docs/examples/teams/get-membership.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md
new file mode 100644
index 0000000..3a71853
--- /dev/null
+++ b/docs/examples/teams/get.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.get('[TEAM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/list-logs.md b/docs/examples/teams/list-logs.md
new file mode 100644
index 0000000..f5120d5
--- /dev/null
+++ b/docs/examples/teams/list-logs.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.listLogs('[TEAM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md
new file mode 100644
index 0000000..12bef1a
--- /dev/null
+++ b/docs/examples/teams/list-memberships.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.listMemberships('[TEAM_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md
new file mode 100644
index 0000000..1aea267
--- /dev/null
+++ b/docs/examples/teams/list.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.list();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership-roles.md
new file mode 100644
index 0000000..ca76ead
--- /dev/null
+++ b/docs/examples/teams/update-membership-roles.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.updateMembershipRoles('[TEAM_ID]', '[MEMBERSHIP_ID]', []);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md
new file mode 100644
index 0000000..4a29cdc
--- /dev/null
+++ b/docs/examples/teams/update-membership-status.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.updateMembershipStatus('[TEAM_ID]', '[MEMBERSHIP_ID]', '[USER_ID]', '[SECRET]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/teams/update.md b/docs/examples/teams/update.md
new file mode 100644
index 0000000..a59cc80
--- /dev/null
+++ b/docs/examples/teams/update.md
@@ -0,0 +1,18 @@
+import { Client, Teams } from "appwrite";
+
+const client = new Client();
+
+const teams = new Teams(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = teams.update('[TEAM_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md
new file mode 100644
index 0000000..e63f9cc
--- /dev/null
+++ b/docs/examples/users/create-argon2user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createArgon2User('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md
new file mode 100644
index 0000000..615ebcd
--- /dev/null
+++ b/docs/examples/users/create-bcrypt-user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createBcryptUser('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md
new file mode 100644
index 0000000..75778f0
--- /dev/null
+++ b/docs/examples/users/create-m-d5user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createMD5User('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md
new file mode 100644
index 0000000..054ae92
--- /dev/null
+++ b/docs/examples/users/create-p-h-pass-user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createPHPassUser('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md
new file mode 100644
index 0000000..1213596
--- /dev/null
+++ b/docs/examples/users/create-s-h-a-user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createSHAUser('[USER_ID]', 'email@example.com', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md
new file mode 100644
index 0000000..de022f1
--- /dev/null
+++ b/docs/examples/users/create-scrypt-modified-user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createScryptModifiedUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', '[PASSWORD_SALT_SEPARATOR]', '[PASSWORD_SIGNER_KEY]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md
new file mode 100644
index 0000000..a6050ac
--- /dev/null
+++ b/docs/examples/users/create-scrypt-user.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.createScryptUser('[USER_ID]', 'email@example.com', 'password', '[PASSWORD_SALT]', null, null, null, null);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md
new file mode 100644
index 0000000..7c96447
--- /dev/null
+++ b/docs/examples/users/create.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.create('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md
new file mode 100644
index 0000000..90f0f30
--- /dev/null
+++ b/docs/examples/users/delete-session.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.deleteSession('[USER_ID]', '[SESSION_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md
new file mode 100644
index 0000000..3df8c7b
--- /dev/null
+++ b/docs/examples/users/delete-sessions.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.deleteSessions('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md
new file mode 100644
index 0000000..f7c21f3
--- /dev/null
+++ b/docs/examples/users/delete.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.delete('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md
new file mode 100644
index 0000000..959c68c
--- /dev/null
+++ b/docs/examples/users/get-prefs.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.getPrefs('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/get-usage.md b/docs/examples/users/get-usage.md
new file mode 100644
index 0000000..cca80da
--- /dev/null
+++ b/docs/examples/users/get-usage.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.getUsage();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md
new file mode 100644
index 0000000..500263d
--- /dev/null
+++ b/docs/examples/users/get.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.get('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md
new file mode 100644
index 0000000..9b2d31d
--- /dev/null
+++ b/docs/examples/users/list-logs.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.listLogs('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md
new file mode 100644
index 0000000..ebd6a38
--- /dev/null
+++ b/docs/examples/users/list-memberships.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.listMemberships('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md
new file mode 100644
index 0000000..c932d6f
--- /dev/null
+++ b/docs/examples/users/list-sessions.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.listSessions('[USER_ID]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md
new file mode 100644
index 0000000..49838da
--- /dev/null
+++ b/docs/examples/users/list.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.list();
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md
new file mode 100644
index 0000000..2abfff8
--- /dev/null
+++ b/docs/examples/users/update-email-verification.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updateEmailVerification('[USER_ID]', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md
new file mode 100644
index 0000000..c0427ac
--- /dev/null
+++ b/docs/examples/users/update-email.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updateEmail('[USER_ID]', 'email@example.com');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md
new file mode 100644
index 0000000..ed13672
--- /dev/null
+++ b/docs/examples/users/update-name.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updateName('[USER_ID]', '[NAME]');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md
new file mode 100644
index 0000000..e13d9bc
--- /dev/null
+++ b/docs/examples/users/update-password.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updatePassword('[USER_ID]', 'password');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md
new file mode 100644
index 0000000..63edc56
--- /dev/null
+++ b/docs/examples/users/update-phone-verification.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updatePhoneVerification('[USER_ID]', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md
new file mode 100644
index 0000000..502bb04
--- /dev/null
+++ b/docs/examples/users/update-phone.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updatePhone('[USER_ID]', '+12065550100');
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md
new file mode 100644
index 0000000..d1d0a8b
--- /dev/null
+++ b/docs/examples/users/update-prefs.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updatePrefs('[USER_ID]', {});
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md
new file mode 100644
index 0000000..189cbca
--- /dev/null
+++ b/docs/examples/users/update-status.md
@@ -0,0 +1,18 @@
+import { Client, Users } from "appwrite";
+
+const client = new Client();
+
+const users = new Users(client);
+
+client
+ .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2') // Your project ID
+;
+
+const promise = users.updateStatus('[USER_ID]', false);
+
+promise.then(function (response) {
+ console.log(response); // Success
+}, function (error) {
+ console.log(error); // Failure
+});
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..58311f4
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "appwrite",
+ "homepage": "https://appwrite.io/support",
+ "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
+ "version": "0.0.1",
+ "license": "BSD-3-Clause",
+ "main": "dist/cjs/sdk.js",
+ "exports": {
+ ".": {
+ "import": "./dist/esm/sdk.js",
+ "require": "./dist/cjs/sdk.js"
+ },
+ "./package.json": "./package.json"
+ },
+ "module": "dist/esm/sdk.js",
+ "types": "types/index.d.ts",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/appwrite/sdk-for-console"
+ },
+ "scripts": {
+ "build": "npm run build:types && npm run build:libs",
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir types",
+ "build:libs": "rollup -c"
+ },
+ "devDependencies": {
+ "@rollup/plugin-typescript": "8.3.2",
+ "playwright": "1.15.0",
+ "rollup": "2.75.4",
+ "serve-handler": "6.1.0",
+ "tslib": "2.4.0",
+ "typescript": "4.7.2"
+ },
+ "dependencies": {
+ "cross-fetch": "3.1.5",
+ "isomorphic-form-data": "2.0.0"
+ },
+ "jsdelivr": "dist/iife/sdk.js",
+ "unpkg": "dist/iife/sdk.js"
+}
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..a9c3354
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,31 @@
+import pkg from "./package.json";
+import typescript from "@rollup/plugin-typescript";
+
+export default {
+ external: Object.keys(pkg.dependencies),
+ input: "src/index.ts",
+ plugins: [typescript()],
+ output: [
+ {
+ format: "cjs",
+ file: pkg.main,
+ esModule: false,
+ sourcemap: true,
+ },
+ {
+ format: "es",
+ file: pkg.module,
+ sourcemap: true,
+ },
+ {
+ format: "iife",
+ file: pkg.jsdelivr,
+ name: "Appwrite",
+ extend: true,
+ globals: {
+ "cross-fetch": "window",
+ "FormData": "FormData",
+ },
+ },
+ ],
+};
diff --git a/src/client.ts b/src/client.ts
new file mode 100644
index 0000000..7143b54
--- /dev/null
+++ b/src/client.ts
@@ -0,0 +1,472 @@
+import 'isomorphic-form-data';
+import { fetch } from 'cross-fetch';
+import { Models } from './models';
+import { Service } from './service';
+
+type Payload = {
+ [key: string]: any;
+}
+
+type Headers = {
+ [key: string]: string;
+}
+
+type RealtimeResponse = {
+ type: 'error' | 'event' | 'connected' | 'response';
+ data: RealtimeResponseAuthenticated | RealtimeResponseConnected | RealtimeResponseError | RealtimeResponseEvent;
+}
+
+type RealtimeRequest = {
+ type: 'authentication';
+ data: RealtimeRequestAuthenticate;
+}
+
+export type RealtimeResponseEvent = {
+ events: string[];
+ channels: string[];
+ timestamp: number;
+ payload: T;
+}
+
+type RealtimeResponseError = {
+ code: number;
+ message: string;
+}
+
+type RealtimeResponseConnected = {
+ channels: string[];
+ user?: object;
+}
+
+type RealtimeResponseAuthenticated = {
+ to: string;
+ success: boolean;
+ user: object;
+}
+
+type RealtimeRequestAuthenticate = {
+ session: string;
+}
+
+type Realtime = {
+ socket?: WebSocket;
+ timeout?: number;
+ url?: string;
+ lastMessage?: RealtimeResponse;
+ channels: Set;
+ subscriptions: Map) => void
+ }>;
+ subscriptionsCounter: number;
+ reconnect: boolean;
+ reconnectAttempts: number;
+ getTimeout: () => number;
+ connect: () => void;
+ createSocket: () => void;
+ cleanUp: (channels: string[]) => void;
+ onMessage: (event: MessageEvent) => void;
+}
+
+export type UploadProgress = {
+ $id: string;
+ progress: number;
+ sizeUploaded: number;
+ chunksTotal: number;
+ chunksUploaded: number;
+}
+
+class AppwriteException extends Error {
+ code: number;
+ response: string;
+ type: string;
+ constructor(message: string, code: number = 0, type: string = '', response: string = '') {
+ super(message);
+ this.name = 'AppwriteException';
+ this.message = message;
+ this.code = code;
+ this.type = type;
+ this.response = response;
+ }
+}
+
+class Client {
+ config = {
+ endpoint: 'https://HOSTNAME/v1',
+ endpointRealtime: '',
+ project: '',
+ key: '',
+ jwt: '',
+ locale: '',
+ mode: '',
+ };
+ headers: Headers = {
+ 'x-sdk-name': 'Console',
+ 'x-sdk-platform': 'console',
+ 'x-sdk-language': 'web',
+ 'x-sdk-version': '0.0.1',
+ 'X-Appwrite-Response-Format': '1.0.0',
+ };
+
+ /**
+ * Set Endpoint
+ *
+ * Your project endpoint
+ *
+ * @param {string} endpoint
+ *
+ * @returns {this}
+ */
+ setEndpoint(endpoint: string): this {
+ this.config.endpoint = endpoint;
+ this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://');
+
+ return this;
+ }
+
+ /**
+ * Set Realtime Endpoint
+ *
+ * @param {string} endpointRealtime
+ *
+ * @returns {this}
+ */
+ setEndpointRealtime(endpointRealtime: string): this {
+ this.config.endpointRealtime = endpointRealtime;
+
+ return this;
+ }
+
+ /**
+ * Set Project
+ *
+ * Your project ID
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setProject(value: string): this {
+ this.headers['X-Appwrite-Project'] = value;
+ this.config.project = value;
+ return this;
+ }
+
+ /**
+ * Set Key
+ *
+ * Your secret API key
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setKey(value: string): this {
+ this.headers['X-Appwrite-Key'] = value;
+ this.config.key = value;
+ return this;
+ }
+
+ /**
+ * Set JWT
+ *
+ * Your secret JSON Web Token
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setJWT(value: string): this {
+ this.headers['X-Appwrite-JWT'] = value;
+ this.config.jwt = value;
+ return this;
+ }
+
+ /**
+ * Set Locale
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setLocale(value: string): this {
+ this.headers['X-Appwrite-Locale'] = value;
+ this.config.locale = value;
+ return this;
+ }
+
+ /**
+ * Set Mode
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setMode(value: string): this {
+ this.headers['X-Appwrite-Mode'] = value;
+ this.config.mode = value;
+ return this;
+ }
+
+
+ private realtime: Realtime = {
+ socket: undefined,
+ timeout: undefined,
+ url: '',
+ channels: new Set(),
+ subscriptions: new Map(),
+ subscriptionsCounter: 0,
+ reconnect: true,
+ reconnectAttempts: 0,
+ lastMessage: undefined,
+ connect: () => {
+ clearTimeout(this.realtime.timeout);
+ this.realtime.timeout = window?.setTimeout(() => {
+ this.realtime.createSocket();
+ }, 50);
+ },
+ getTimeout: () => {
+ switch (true) {
+ case this.realtime.reconnectAttempts < 5:
+ return 1000;
+ case this.realtime.reconnectAttempts < 15:
+ return 5000;
+ case this.realtime.reconnectAttempts < 100:
+ return 10_000;
+ default:
+ return 60_000;
+ }
+ },
+ createSocket: () => {
+ if (this.realtime.channels.size < 1) return;
+
+ const channels = new URLSearchParams();
+ channels.set('project', this.config.project);
+ this.realtime.channels.forEach(channel => {
+ channels.append('channels[]', channel);
+ });
+
+ const url = this.config.endpointRealtime + '/realtime?' + channels.toString();
+
+ if (
+ url !== this.realtime.url || // Check if URL is present
+ !this.realtime.socket || // Check if WebSocket has not been created
+ this.realtime.socket?.readyState > WebSocket.OPEN // Check if WebSocket is CLOSING (3) or CLOSED (4)
+ ) {
+ if (
+ this.realtime.socket &&
+ this.realtime.socket?.readyState < WebSocket.CLOSING // Close WebSocket if it is CONNECTING (0) or OPEN (1)
+ ) {
+ this.realtime.reconnect = false;
+ this.realtime.socket.close();
+ }
+
+ this.realtime.url = url;
+ this.realtime.socket = new WebSocket(url);
+ this.realtime.socket.addEventListener('message', this.realtime.onMessage);
+ this.realtime.socket.addEventListener('open', _event => {
+ this.realtime.reconnectAttempts = 0;
+ });
+ this.realtime.socket.addEventListener('close', event => {
+ if (
+ !this.realtime.reconnect ||
+ (
+ this.realtime?.lastMessage?.type === 'error' && // Check if last message was of type error
+ (this.realtime?.lastMessage.data).code === 1008 // Check for policy violation 1008
+ )
+ ) {
+ this.realtime.reconnect = true;
+ return;
+ }
+
+ const timeout = this.realtime.getTimeout();
+ console.error(`Realtime got disconnected. Reconnect will be attempted in ${timeout / 1000} seconds.`, event.reason);
+
+ setTimeout(() => {
+ this.realtime.reconnectAttempts++;
+ this.realtime.createSocket();
+ }, timeout);
+ })
+ }
+ },
+ onMessage: (event) => {
+ try {
+ const message: RealtimeResponse = JSON.parse(event.data);
+ this.realtime.lastMessage = message;
+ switch (message.type) {
+ case 'connected':
+ const cookie = JSON.parse(window.localStorage.getItem('cookieFallback') ?? '{}');
+ const session = cookie?.[`a_session_${this.config.project}`];
+ const messageData = message.data;
+
+ if (session && !messageData.user) {
+ this.realtime.socket?.send(JSON.stringify({
+ type: 'authentication',
+ data: {
+ session
+ }
+ }));
+ }
+ break;
+ case 'event':
+ let data = >message.data;
+ if (data?.channels) {
+ const isSubscribed = data.channels.some(channel => this.realtime.channels.has(channel));
+ if (!isSubscribed) return;
+ this.realtime.subscriptions.forEach(subscription => {
+ if (data.channels.some(channel => subscription.channels.includes(channel))) {
+ setTimeout(() => subscription.callback(data));
+ }
+ })
+ }
+ break;
+ case 'error':
+ throw message.data;
+ default:
+ break;
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ },
+ cleanUp: channels => {
+ this.realtime.channels.forEach(channel => {
+ if (channels.includes(channel)) {
+ let found = Array.from(this.realtime.subscriptions).some(([_key, subscription] )=> {
+ return subscription.channels.includes(channel);
+ })
+
+ if (!found) {
+ this.realtime.channels.delete(channel);
+ }
+ }
+ })
+ }
+ }
+
+ /**
+ * Subscribes to Appwrite events and passes you the payload in realtime.
+ *
+ * @param {string|string[]} channels
+ * Channel to subscribe - pass a single channel as a string or multiple with an array of strings.
+ *
+ * Possible channels are:
+ * - account
+ * - collections
+ * - collections.[ID]
+ * - collections.[ID].documents
+ * - documents
+ * - documents.[ID]
+ * - files
+ * - files.[ID]
+ * - executions
+ * - executions.[ID]
+ * - functions.[ID]
+ * - teams
+ * - teams.[ID]
+ * - memberships
+ * - memberships.[ID]
+ * @param {(payload: RealtimeMessage) => void} callback Is called on every realtime update.
+ * @returns {() => void} Unsubscribes from events.
+ */
+ subscribe(channels: string | string[], callback: (payload: RealtimeResponseEvent) => void): () => void {
+ let channelArray = typeof channels === 'string' ? [channels] : channels;
+ channelArray.forEach(channel => this.realtime.channels.add(channel));
+
+ const counter = this.realtime.subscriptionsCounter++;
+ this.realtime.subscriptions.set(counter, {
+ channels: channelArray,
+ callback
+ });
+
+ this.realtime.connect();
+
+ return () => {
+ this.realtime.subscriptions.delete(counter);
+ this.realtime.cleanUp(channelArray);
+ this.realtime.connect();
+ }
+ }
+
+ async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise {
+ method = method.toUpperCase();
+
+
+ headers = Object.assign({}, this.headers, headers);
+
+ let options: RequestInit = {
+ method,
+ headers,
+ credentials: 'include'
+ };
+
+ if (typeof window !== 'undefined' && window.localStorage) {
+ headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? '';
+ }
+
+ if (method === 'GET') {
+ for (const [key, value] of Object.entries(Service.flatten(params))) {
+ url.searchParams.append(key, value);
+ }
+ } else {
+ switch (headers['content-type']) {
+ case 'application/json':
+ options.body = JSON.stringify(params);
+ break;
+
+ case 'multipart/form-data':
+ let formData = new FormData();
+
+ for (const key in params) {
+ if (Array.isArray(params[key])) {
+ params[key].forEach((value: any) => {
+ formData.append(key + '[]', value);
+ })
+ } else {
+ formData.append(key, params[key]);
+ }
+ }
+
+ options.body = formData;
+ delete headers['content-type'];
+ break;
+ }
+ }
+
+ try {
+ let data = null;
+ const response = await fetch(url.toString(), options);
+
+ if (response.headers.get('content-type')?.includes('application/json')) {
+ data = await response.json();
+ } else {
+ data = {
+ message: await response.text()
+ };
+ }
+
+ if (400 <= response.status) {
+ throw new AppwriteException(data?.message, response.status, data?.type, data);
+ }
+
+ const cookieFallback = response.headers.get('X-Fallback-Cookies');
+
+ if (typeof window !== 'undefined' && window.localStorage && cookieFallback) {
+ window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.');
+ window.localStorage.setItem('cookieFallback', cookieFallback);
+ }
+
+ return data;
+ } catch (e) {
+ if (e instanceof AppwriteException) {
+ throw e;
+ }
+ throw new AppwriteException((e).message);
+ }
+ }
+}
+
+export { Client, AppwriteException };
+export { Query } from './query';
+export type { Models, Payload };
+export type { QueryTypes, QueryTypesList } from './query';
diff --git a/src/id.ts b/src/id.ts
new file mode 100644
index 0000000..9577e4b
--- /dev/null
+++ b/src/id.ts
@@ -0,0 +1,9 @@
+export class ID {
+ public static custom(id: string): string {
+ return id
+ }
+
+ public static unique(): string {
+ return 'unique()'
+ }
+}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..70723b8
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,17 @@
+export { Client, Query, AppwriteException } from './client';
+export { Account } from './services/account';
+export { Avatars } from './services/avatars';
+export { Databases } from './services/databases';
+export { Functions } from './services/functions';
+export { Graphql } from './services/graphql';
+export { Health } from './services/health';
+export { Locale } from './services/locale';
+export { Projects } from './services/projects';
+export { Storage } from './services/storage';
+export { Teams } from './services/teams';
+export { Users } from './services/users';
+export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client';
+export type { QueryTypes, QueryTypesList } from './query';
+export { Permission } from './permission';
+export { Role } from './role';
+export { ID } from './id';
\ No newline at end of file
diff --git a/src/models.ts b/src/models.ts
new file mode 100644
index 0000000..4c96322
--- /dev/null
+++ b/src/models.ts
@@ -0,0 +1,2540 @@
+export namespace Models {
+ /**
+ * Documents List
+ */
+ export type DocumentList = {
+ /**
+ * Total number of documents documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of documents.
+ */
+ documents: Document[];
+ }
+ /**
+ * Collections List
+ */
+ export type CollectionList = {
+ /**
+ * Total number of collections documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of collections.
+ */
+ collections: Collection[];
+ }
+ /**
+ * Databases List
+ */
+ export type DatabaseList = {
+ /**
+ * Total number of databases documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of databases.
+ */
+ databases: Database[];
+ }
+ /**
+ * Indexes List
+ */
+ export type IndexList = {
+ /**
+ * Total number of indexes documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of indexes.
+ */
+ indexes: Index[];
+ }
+ /**
+ * Users List
+ */
+ export type UserList = {
+ /**
+ * Total number of users documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of users.
+ */
+ users: User[];
+ }
+ /**
+ * Sessions List
+ */
+ export type SessionList = {
+ /**
+ * Total number of sessions documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of sessions.
+ */
+ sessions: Session[];
+ }
+ /**
+ * Logs List
+ */
+ export type LogList = {
+ /**
+ * Total number of logs documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of logs.
+ */
+ logs: Log[];
+ }
+ /**
+ * Files List
+ */
+ export type FileList = {
+ /**
+ * Total number of files documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of files.
+ */
+ files: File[];
+ }
+ /**
+ * Buckets List
+ */
+ export type BucketList = {
+ /**
+ * Total number of buckets documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of buckets.
+ */
+ buckets: Bucket[];
+ }
+ /**
+ * Teams List
+ */
+ export type TeamList = {
+ /**
+ * Total number of teams documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of teams.
+ */
+ teams: Team[];
+ }
+ /**
+ * Memberships List
+ */
+ export type MembershipList = {
+ /**
+ * Total number of memberships documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of memberships.
+ */
+ memberships: Membership[];
+ }
+ /**
+ * Functions List
+ */
+ export type FunctionList = {
+ /**
+ * Total number of functions documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of functions.
+ */
+ functions: Function[];
+ }
+ /**
+ * Runtimes List
+ */
+ export type RuntimeList = {
+ /**
+ * Total number of runtimes documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of runtimes.
+ */
+ runtimes: Runtime[];
+ }
+ /**
+ * Deployments List
+ */
+ export type DeploymentList = {
+ /**
+ * Total number of deployments documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of deployments.
+ */
+ deployments: Deployment[];
+ }
+ /**
+ * Executions List
+ */
+ export type ExecutionList = {
+ /**
+ * Total number of executions documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of executions.
+ */
+ executions: Execution[];
+ }
+ /**
+ * Projects List
+ */
+ export type ProjectList = {
+ /**
+ * Total number of projects documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of projects.
+ */
+ projects: Project[];
+ }
+ /**
+ * Webhooks List
+ */
+ export type WebhookList = {
+ /**
+ * Total number of webhooks documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of webhooks.
+ */
+ webhooks: Webhook[];
+ }
+ /**
+ * API Keys List
+ */
+ export type KeyList = {
+ /**
+ * Total number of keys documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of keys.
+ */
+ keys: Key[];
+ }
+ /**
+ * Platforms List
+ */
+ export type PlatformList = {
+ /**
+ * Total number of platforms documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of platforms.
+ */
+ platforms: Platform[];
+ }
+ /**
+ * Domains List
+ */
+ export type DomainList = {
+ /**
+ * Total number of domains documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of domains.
+ */
+ domains: Domain[];
+ }
+ /**
+ * Countries List
+ */
+ export type CountryList = {
+ /**
+ * Total number of countries documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of countries.
+ */
+ countries: Country[];
+ }
+ /**
+ * Continents List
+ */
+ export type ContinentList = {
+ /**
+ * Total number of continents documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of continents.
+ */
+ continents: Continent[];
+ }
+ /**
+ * Languages List
+ */
+ export type LanguageList = {
+ /**
+ * Total number of languages documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of languages.
+ */
+ languages: Language[];
+ }
+ /**
+ * Currencies List
+ */
+ export type CurrencyList = {
+ /**
+ * Total number of currencies documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of currencies.
+ */
+ currencies: Currency[];
+ }
+ /**
+ * Phones List
+ */
+ export type PhoneList = {
+ /**
+ * Total number of phones documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of phones.
+ */
+ phones: Phone[];
+ }
+ /**
+ * Variables List
+ */
+ export type VariableList = {
+ /**
+ * Total number of variables documents that matched your query.
+ */
+ total: number;
+ /**
+ * List of variables.
+ */
+ variables: Variable[];
+ }
+ /**
+ * Database
+ */
+ export type Database = {
+ /**
+ * Database ID.
+ */
+ $id: string;
+ /**
+ * Database name.
+ */
+ name: string;
+ /**
+ * Database creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Database update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ }
+ /**
+ * Collection
+ */
+ export type Collection = {
+ /**
+ * Collection ID.
+ */
+ $id: string;
+ /**
+ * Collection creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Collection update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Collection permissions. [Learn more about permissions](/docs/permissions).
+ */
+ $permissions: string[];
+ /**
+ * Database ID.
+ */
+ databaseId: string;
+ /**
+ * Collection name.
+ */
+ name: string;
+ /**
+ * Collection enabled.
+ */
+ enabled: boolean;
+ /**
+ * Whether document-level permissions are enabled. [Learn more about permissions](/docs/permissions).
+ */
+ documentSecurity: boolean;
+ /**
+ * Collection attributes.
+ */
+ attributes: string[];
+ /**
+ * Collection indexes.
+ */
+ indexes: Index[];
+ }
+ /**
+ * Attributes List
+ */
+ export type AttributeList = {
+ /**
+ * Total number of attributes in the given collection.
+ */
+ total: number;
+ /**
+ * List of attributes.
+ */
+ attributes: string[];
+ }
+ /**
+ * AttributeString
+ */
+ export type AttributeString = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * Attribute size.
+ */
+ size: number;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: string;
+ }
+ /**
+ * AttributeInteger
+ */
+ export type AttributeInteger = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * Minimum value to enforce for new documents.
+ */
+ min?: number;
+ /**
+ * Maximum value to enforce for new documents.
+ */
+ max?: number;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: number;
+ }
+ /**
+ * AttributeFloat
+ */
+ export type AttributeFloat = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * Minimum value to enforce for new documents.
+ */
+ min?: number;
+ /**
+ * Maximum value to enforce for new documents.
+ */
+ max?: number;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: number;
+ }
+ /**
+ * AttributeBoolean
+ */
+ export type AttributeBoolean = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: boolean;
+ }
+ /**
+ * AttributeEmail
+ */
+ export type AttributeEmail = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * String format.
+ */
+ format: string;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: string;
+ }
+ /**
+ * AttributeEnum
+ */
+ export type AttributeEnum = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * Array of elements in enumerated type.
+ */
+ elements: string[];
+ /**
+ * String format.
+ */
+ format: string;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: string;
+ }
+ /**
+ * AttributeIP
+ */
+ export type AttributeIp = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * String format.
+ */
+ format: string;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: string;
+ }
+ /**
+ * AttributeURL
+ */
+ export type AttributeUrl = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * String format.
+ */
+ format: string;
+ /**
+ * Default value for attribute when not provided. Cannot be set when attribute is required.
+ */
+ default?: string;
+ }
+ /**
+ * AttributeDatetime
+ */
+ export type AttributeDatetime = {
+ /**
+ * Attribute Key.
+ */
+ key: string;
+ /**
+ * Attribute type.
+ */
+ type: string;
+ /**
+ * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Is attribute required?
+ */
+ required: boolean;
+ /**
+ * Is attribute an array?
+ */
+ array?: boolean;
+ /**
+ * ISO 8601 format.
+ */
+ format: string;
+ /**
+ * Default value for attribute when not provided. Only null is optional
+ */
+ default?: string;
+ }
+ /**
+ * Index
+ */
+ export type Index = {
+ /**
+ * Index Key.
+ */
+ key: string;
+ /**
+ * Index type.
+ */
+ type: string;
+ /**
+ * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
+ */
+ status: string;
+ /**
+ * Index attributes.
+ */
+ attributes: string[];
+ /**
+ * Index orders.
+ */
+ orders?: string[];
+ }
+ /**
+ * Document
+ */
+ export type Document = {
+ /**
+ * Document ID.
+ */
+ $id: string;
+ /**
+ * Collection ID.
+ */
+ $collectionId: string;
+ /**
+ * Database ID.
+ */
+ $databaseId: string;
+ /**
+ * Document creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Document update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Document permissions. [Learn more about permissions](/docs/permissions).
+ */
+ $permissions: string[];
+ [key: string]: any;
+ }
+ /**
+ * Log
+ */
+ export type Log = {
+ /**
+ * Event name.
+ */
+ event: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * User Email.
+ */
+ userEmail: string;
+ /**
+ * User Name.
+ */
+ userName: string;
+ /**
+ * API mode when event triggered.
+ */
+ mode: string;
+ /**
+ * IP session in use when the session was created.
+ */
+ ip: string;
+ /**
+ * Log creation date in ISO 8601 format.
+ */
+ time: string;
+ /**
+ * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
+ */
+ osCode: string;
+ /**
+ * Operating system name.
+ */
+ osName: string;
+ /**
+ * Operating system version.
+ */
+ osVersion: string;
+ /**
+ * Client type.
+ */
+ clientType: string;
+ /**
+ * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).
+ */
+ clientCode: string;
+ /**
+ * Client name.
+ */
+ clientName: string;
+ /**
+ * Client version.
+ */
+ clientVersion: string;
+ /**
+ * Client engine name.
+ */
+ clientEngine: string;
+ /**
+ * Client engine name.
+ */
+ clientEngineVersion: string;
+ /**
+ * Device name.
+ */
+ deviceName: string;
+ /**
+ * Device brand name.
+ */
+ deviceBrand: string;
+ /**
+ * Device model name.
+ */
+ deviceModel: string;
+ /**
+ * Country two-character ISO 3166-1 alpha code.
+ */
+ countryCode: string;
+ /**
+ * Country name.
+ */
+ countryName: string;
+ }
+ /**
+ * User
+ */
+ export type User = {
+ /**
+ * User ID.
+ */
+ $id: string;
+ /**
+ * User creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * User update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * User name.
+ */
+ name: string;
+ /**
+ * Hashed user password.
+ */
+ password: string;
+ /**
+ * Password hashing algorithm.
+ */
+ hash: string;
+ /**
+ * Password hashing algorithm configuration.
+ */
+ hashOptions: object;
+ /**
+ * User registration date in ISO 8601 format.
+ */
+ registration: string;
+ /**
+ * User status. Pass `true` for enabled and `false` for disabled.
+ */
+ status: boolean;
+ /**
+ * Password update time in ISO 8601 format.
+ */
+ passwordUpdate: string;
+ /**
+ * User email address.
+ */
+ email: string;
+ /**
+ * User phone number in E.164 format.
+ */
+ phone: string;
+ /**
+ * Email verification status.
+ */
+ emailVerification: boolean;
+ /**
+ * Phone verification status.
+ */
+ phoneVerification: boolean;
+ /**
+ * User preferences as a key-value object
+ */
+ prefs: Preferences;
+ }
+ /**
+ * AlgoMD5
+ */
+ export type AlgoMd5 = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ }
+ /**
+ * AlgoSHA
+ */
+ export type AlgoSha = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ }
+ /**
+ * AlgoPHPass
+ */
+ export type AlgoPhpass = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ }
+ /**
+ * AlgoBcrypt
+ */
+ export type AlgoBcrypt = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ }
+ /**
+ * AlgoScrypt
+ */
+ export type AlgoScrypt = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ /**
+ * CPU complexity of computed hash.
+ */
+ costCpu: number;
+ /**
+ * Memory complexity of computed hash.
+ */
+ costMemory: number;
+ /**
+ * Parallelization of computed hash.
+ */
+ costParallel: number;
+ /**
+ * Length used to compute hash.
+ */
+ length: number;
+ }
+ /**
+ * AlgoScryptModified
+ */
+ export type AlgoScryptModified = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ /**
+ * Salt used to compute hash.
+ */
+ salt: string;
+ /**
+ * Separator used to compute hash.
+ */
+ saltSeparator: string;
+ /**
+ * Key used to compute hash.
+ */
+ signerKey: string;
+ }
+ /**
+ * AlgoArgon2
+ */
+ export type AlgoArgon2 = {
+ /**
+ * Algo type.
+ */
+ type: string;
+ /**
+ * Memory used to compute hash.
+ */
+ memoryCost: number;
+ /**
+ * Amount of time consumed to compute hash
+ */
+ timeCost: number;
+ /**
+ * Number of threads used to compute hash.
+ */
+ threads: number;
+ }
+ /**
+ * Account
+ */
+ export type Account = {
+ /**
+ * User ID.
+ */
+ $id: string;
+ /**
+ * User creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * User update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * User name.
+ */
+ name: string;
+ /**
+ * User registration date in ISO 8601 format.
+ */
+ registration: string;
+ /**
+ * User status. Pass `true` for enabled and `false` for disabled.
+ */
+ status: boolean;
+ /**
+ * Password update time in ISO 8601 format.
+ */
+ passwordUpdate: string;
+ /**
+ * User email address.
+ */
+ email: string;
+ /**
+ * User phone number in E.164 format.
+ */
+ phone: string;
+ /**
+ * Email verification status.
+ */
+ emailVerification: boolean;
+ /**
+ * Phone verification status.
+ */
+ phoneVerification: boolean;
+ /**
+ * User preferences as a key-value object
+ */
+ prefs: Preferences;
+ }
+ /**
+ * Preferences
+ */
+ export type Preferences = {
+ [key: string]: any;
+ }
+ /**
+ * Session
+ */
+ export type Session = {
+ /**
+ * Session ID.
+ */
+ $id: string;
+ /**
+ * Session creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * Session expiration date in ISO 8601 format.
+ */
+ expire: string;
+ /**
+ * Session Provider.
+ */
+ provider: string;
+ /**
+ * Session Provider User ID.
+ */
+ providerUid: string;
+ /**
+ * Session Provider Access Token.
+ */
+ providerAccessToken: string;
+ /**
+ * The date of when the access token expires in ISO 8601 format.
+ */
+ providerAccessTokenExpiry: string;
+ /**
+ * Session Provider Refresh Token.
+ */
+ providerRefreshToken: string;
+ /**
+ * IP in use when the session was created.
+ */
+ ip: string;
+ /**
+ * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
+ */
+ osCode: string;
+ /**
+ * Operating system name.
+ */
+ osName: string;
+ /**
+ * Operating system version.
+ */
+ osVersion: string;
+ /**
+ * Client type.
+ */
+ clientType: string;
+ /**
+ * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).
+ */
+ clientCode: string;
+ /**
+ * Client name.
+ */
+ clientName: string;
+ /**
+ * Client version.
+ */
+ clientVersion: string;
+ /**
+ * Client engine name.
+ */
+ clientEngine: string;
+ /**
+ * Client engine name.
+ */
+ clientEngineVersion: string;
+ /**
+ * Device name.
+ */
+ deviceName: string;
+ /**
+ * Device brand name.
+ */
+ deviceBrand: string;
+ /**
+ * Device model name.
+ */
+ deviceModel: string;
+ /**
+ * Country two-character ISO 3166-1 alpha code.
+ */
+ countryCode: string;
+ /**
+ * Country name.
+ */
+ countryName: string;
+ /**
+ * Returns true if this the current user session.
+ */
+ current: boolean;
+ }
+ /**
+ * Token
+ */
+ export type Token = {
+ /**
+ * Token ID.
+ */
+ $id: string;
+ /**
+ * Token creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
+ */
+ secret: string;
+ /**
+ * Token expiration date in ISO 8601 format.
+ */
+ expire: string;
+ }
+ /**
+ * JWT
+ */
+ export type Jwt = {
+ /**
+ * JWT encoded string.
+ */
+ jwt: string;
+ }
+ /**
+ * Locale
+ */
+ export type Locale = {
+ /**
+ * User IP address.
+ */
+ ip: string;
+ /**
+ * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format
+ */
+ countryCode: string;
+ /**
+ * Country name. This field support localization.
+ */
+ country: string;
+ /**
+ * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America.
+ */
+ continentCode: string;
+ /**
+ * Continent name. This field support localization.
+ */
+ continent: string;
+ /**
+ * True if country is part of the Europian Union.
+ */
+ eu: boolean;
+ /**
+ * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format
+ */
+ currency: string;
+ }
+ /**
+ * File
+ */
+ export type File = {
+ /**
+ * File ID.
+ */
+ $id: string;
+ /**
+ * Bucket ID.
+ */
+ bucketId: string;
+ /**
+ * File creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * File update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * File permissions. [Learn more about permissions](/docs/permissions).
+ */
+ $permissions: string[];
+ /**
+ * File name.
+ */
+ name: string;
+ /**
+ * File MD5 signature.
+ */
+ signature: string;
+ /**
+ * File mime type.
+ */
+ mimeType: string;
+ /**
+ * File original size in bytes.
+ */
+ sizeOriginal: number;
+ /**
+ * Total number of chunks available
+ */
+ chunksTotal: number;
+ /**
+ * Total number of chunks uploaded
+ */
+ chunksUploaded: number;
+ }
+ /**
+ * Bucket
+ */
+ export type Bucket = {
+ /**
+ * Bucket ID.
+ */
+ $id: string;
+ /**
+ * Bucket creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Bucket update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Bucket permissions. [Learn more about permissions](/docs/permissions).
+ */
+ $permissions: string[];
+ /**
+ * Whether file-level security is enabled. [Learn more about permissions](/docs/permissions).
+ */
+ fileSecurity: boolean;
+ /**
+ * Bucket name.
+ */
+ name: string;
+ /**
+ * Bucket enabled.
+ */
+ enabled: boolean;
+ /**
+ * Maximum file size supported.
+ */
+ maximumFileSize: number;
+ /**
+ * Allowed file extensions.
+ */
+ allowedFileExtensions: string[];
+ /**
+ * Compression algorithm choosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd).
+ */
+ compression: string;
+ /**
+ * Bucket is encrypted.
+ */
+ encryption: boolean;
+ /**
+ * Virus scanning is enabled.
+ */
+ antivirus: boolean;
+ }
+ /**
+ * Team
+ */
+ export type Team = {
+ /**
+ * Team ID.
+ */
+ $id: string;
+ /**
+ * Team creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Team update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Team name.
+ */
+ name: string;
+ /**
+ * Total number of team members.
+ */
+ total: number;
+ }
+ /**
+ * Membership
+ */
+ export type Membership = {
+ /**
+ * Membership ID.
+ */
+ $id: string;
+ /**
+ * Membership creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Membership update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * User name.
+ */
+ userName: string;
+ /**
+ * User email address.
+ */
+ userEmail: string;
+ /**
+ * Team ID.
+ */
+ teamId: string;
+ /**
+ * Team name.
+ */
+ teamName: string;
+ /**
+ * Date, the user has been invited to join the team in ISO 8601 format.
+ */
+ invited: string;
+ /**
+ * Date, the user has accepted the invitation to join the team in ISO 8601 format.
+ */
+ joined: string;
+ /**
+ * User confirmation status, true if the user has joined the team or false otherwise.
+ */
+ confirm: boolean;
+ /**
+ * User list of roles
+ */
+ roles: string[];
+ }
+ /**
+ * Function
+ */
+ export type Function = {
+ /**
+ * Function ID.
+ */
+ $id: string;
+ /**
+ * Function creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Function update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Execution permissions.
+ */
+ execute: string[];
+ /**
+ * Function name.
+ */
+ name: string;
+ /**
+ * Function enabled.
+ */
+ enabled: boolean;
+ /**
+ * Function execution runtime.
+ */
+ runtime: string;
+ /**
+ * Function's active deployment ID.
+ */
+ deployment: string;
+ /**
+ * Function variables.
+ */
+ vars: Variable[];
+ /**
+ * Function trigger events.
+ */
+ events: string[];
+ /**
+ * Function execution schedult in CRON format.
+ */
+ schedule: string;
+ /**
+ * Function's next scheduled execution time in ISO 8601 format.
+ */
+ scheduleNext: string;
+ /**
+ * Function's previous scheduled execution time in ISO 8601 format.
+ */
+ schedulePrevious: string;
+ /**
+ * Function execution timeout in seconds.
+ */
+ timeout: number;
+ }
+ /**
+ * Runtime
+ */
+ export type Runtime = {
+ /**
+ * Runtime ID.
+ */
+ $id: string;
+ /**
+ * Runtime Name.
+ */
+ name: string;
+ /**
+ * Runtime version.
+ */
+ version: string;
+ /**
+ * Base Docker image used to build the runtime.
+ */
+ base: string;
+ /**
+ * Image name of Docker Hub.
+ */
+ image: string;
+ /**
+ * Name of the logo image.
+ */
+ logo: string;
+ /**
+ * List of supported architectures.
+ */
+ supports: string[];
+ }
+ /**
+ * Deployment
+ */
+ export type Deployment = {
+ /**
+ * Deployment ID.
+ */
+ $id: string;
+ /**
+ * Deployment creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Deployment update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Resource ID.
+ */
+ resourceId: string;
+ /**
+ * Resource type.
+ */
+ resourceType: string;
+ /**
+ * The entrypoint file to use to execute the deployment code.
+ */
+ entrypoint: string;
+ /**
+ * The code size in bytes.
+ */
+ size: number;
+ /**
+ * The current build ID.
+ */
+ buildId: string;
+ /**
+ * Whether the deployment should be automatically activated.
+ */
+ activate: boolean;
+ /**
+ * The deployment status. Possible values are "processing", "building", "pending", "ready", and "failed".
+ */
+ status: string;
+ /**
+ * The build stdout.
+ */
+ buildStdout: string;
+ /**
+ * The build stderr.
+ */
+ buildStderr: string;
+ /**
+ * The current build time in seconds.
+ */
+ buildTime: number;
+ }
+ /**
+ * Execution
+ */
+ export type Execution = {
+ /**
+ * Execution ID.
+ */
+ $id: string;
+ /**
+ * Execution creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Execution upate date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Execution roles.
+ */
+ $permissions: string[];
+ /**
+ * Function ID.
+ */
+ functionId: string;
+ /**
+ * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.
+ */
+ trigger: string;
+ /**
+ * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.
+ */
+ status: string;
+ /**
+ * The script status code.
+ */
+ statusCode: number;
+ /**
+ * The script response output string. Logs the last 4,000 characters of the execution response output.
+ */
+ response: string;
+ /**
+ * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
+ */
+ stdout: string;
+ /**
+ * The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
+ */
+ stderr: string;
+ /**
+ * The script execution duration in seconds.
+ */
+ duration: number;
+ }
+ /**
+ * Project
+ */
+ export type Project = {
+ /**
+ * Project ID.
+ */
+ $id: string;
+ /**
+ * Project creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Project update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Project name.
+ */
+ name: string;
+ /**
+ * Project description.
+ */
+ description: string;
+ /**
+ * Project team ID.
+ */
+ teamId: string;
+ /**
+ * Project logo file ID.
+ */
+ logo: string;
+ /**
+ * Project website URL.
+ */
+ url: string;
+ /**
+ * Company legal name.
+ */
+ legalName: string;
+ /**
+ * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format.
+ */
+ legalCountry: string;
+ /**
+ * State name.
+ */
+ legalState: string;
+ /**
+ * City name.
+ */
+ legalCity: string;
+ /**
+ * Company Address.
+ */
+ legalAddress: string;
+ /**
+ * Company Tax ID.
+ */
+ legalTaxId: string;
+ /**
+ * Session duration in seconds.
+ */
+ authDuration: number;
+ /**
+ * Max users allowed. 0 is unlimited.
+ */
+ authLimit: number;
+ /**
+ * Max sessions allowed per user. 100 maximum.
+ */
+ authSessionsLimit: number;
+ /**
+ * List of Providers.
+ */
+ providers: Provider[];
+ /**
+ * List of Platforms.
+ */
+ platforms: Platform[];
+ /**
+ * List of Webhooks.
+ */
+ webhooks: Webhook[];
+ /**
+ * List of API Keys.
+ */
+ keys: Key[];
+ /**
+ * List of Domains.
+ */
+ domains: Domain[];
+ /**
+ * Email/Password auth method status
+ */
+ authEmailPassword: boolean;
+ /**
+ * Magic URL auth method status
+ */
+ authUsersAuthMagicURL: boolean;
+ /**
+ * Anonymous auth method status
+ */
+ authAnonymous: boolean;
+ /**
+ * Invites auth method status
+ */
+ authInvites: boolean;
+ /**
+ * JWT auth method status
+ */
+ authJWT: boolean;
+ /**
+ * Phone auth method status
+ */
+ authPhone: boolean;
+ /**
+ * Account service status
+ */
+ serviceStatusForAccount: boolean;
+ /**
+ * Avatars service status
+ */
+ serviceStatusForAvatars: boolean;
+ /**
+ * Databases service status
+ */
+ serviceStatusForDatabases: boolean;
+ /**
+ * Locale service status
+ */
+ serviceStatusForLocale: boolean;
+ /**
+ * Health service status
+ */
+ serviceStatusForHealth: boolean;
+ /**
+ * Storage service status
+ */
+ serviceStatusForStorage: boolean;
+ /**
+ * Teams service status
+ */
+ serviceStatusForTeams: boolean;
+ /**
+ * Users service status
+ */
+ serviceStatusForUsers: boolean;
+ /**
+ * Functions service status
+ */
+ serviceStatusForFunctions: boolean;
+ /**
+ * GraphQL service status
+ */
+ serviceStatusForGraphql: boolean;
+ }
+ /**
+ * Webhook
+ */
+ export type Webhook = {
+ /**
+ * Webhook ID.
+ */
+ $id: string;
+ /**
+ * Webhook creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Webhook update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Webhook name.
+ */
+ name: string;
+ /**
+ * Webhook URL endpoint.
+ */
+ url: string;
+ /**
+ * Webhook trigger events.
+ */
+ events: string[];
+ /**
+ * Indicated if SSL / TLS Certificate verification is enabled.
+ */
+ security: boolean;
+ /**
+ * HTTP basic authentication username.
+ */
+ httpUser: string;
+ /**
+ * HTTP basic authentication password.
+ */
+ httpPass: string;
+ /**
+ * Signature key which can be used to validated incoming
+ */
+ signatureKey: string;
+ }
+ /**
+ * Key
+ */
+ export type Key = {
+ /**
+ * Key ID.
+ */
+ $id: string;
+ /**
+ * Key creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Key update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Key name.
+ */
+ name: string;
+ /**
+ * Key expiration date in ISO 8601 format.
+ */
+ expire: string;
+ /**
+ * Allowed permission scopes.
+ */
+ scopes: string[];
+ /**
+ * Secret key.
+ */
+ secret: string;
+ /**
+ * Most recent access date in ISO 8601 format.
+ */
+ accessedAt: string;
+ /**
+ * List of SDK user agents that used this key.
+ */
+ sdks: string[];
+ }
+ /**
+ * Domain
+ */
+ export type Domain = {
+ /**
+ * Domain ID.
+ */
+ $id: string;
+ /**
+ * Domain creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Domain update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Domain name.
+ */
+ domain: string;
+ /**
+ * Registerable domain name.
+ */
+ registerable: string;
+ /**
+ * TLD name.
+ */
+ tld: string;
+ /**
+ * Verification process status.
+ */
+ verification: boolean;
+ /**
+ * Certificate ID.
+ */
+ certificateId: string;
+ }
+ /**
+ * Provider
+ */
+ export type Provider = {
+ /**
+ * Provider name.
+ */
+ name: string;
+ /**
+ * OAuth 2.0 application ID.
+ */
+ appId: string;
+ /**
+ * OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration.
+ */
+ secret: string;
+ /**
+ * Provider is active and can be used to create session.
+ */
+ enabled: boolean;
+ }
+ /**
+ * Platform
+ */
+ export type Platform = {
+ /**
+ * Platform ID.
+ */
+ $id: string;
+ /**
+ * Platform creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Platform update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Platform name.
+ */
+ name: string;
+ /**
+ * Platform type. Possible values are: web, flutter-ios, flutter-android, ios, android, and unity.
+ */
+ type: string;
+ /**
+ * Platform Key. iOS bundle ID or Android package name. Empty string for other platforms.
+ */
+ key: string;
+ /**
+ * App store or Google Play store ID.
+ */
+ store: string;
+ /**
+ * Web app hostname. Empty string for other platforms.
+ */
+ hostname: string;
+ /**
+ * HTTP basic authentication username.
+ */
+ httpUser: string;
+ /**
+ * HTTP basic authentication password.
+ */
+ httpPass: string;
+ }
+ /**
+ * Variable
+ */
+ export type Variable = {
+ /**
+ * Variable ID.
+ */
+ $id: string;
+ /**
+ * Variable creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Variable creation date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Variable key.
+ */
+ key: string;
+ /**
+ * Variable value.
+ */
+ value: string;
+ /**
+ * Function ID.
+ */
+ functionId: string;
+ }
+ /**
+ * Country
+ */
+ export type Country = {
+ /**
+ * Country name.
+ */
+ name: string;
+ /**
+ * Country two-character ISO 3166-1 alpha code.
+ */
+ code: string;
+ }
+ /**
+ * Continent
+ */
+ export type Continent = {
+ /**
+ * Continent name.
+ */
+ name: string;
+ /**
+ * Continent two letter code.
+ */
+ code: string;
+ }
+ /**
+ * Language
+ */
+ export type Language = {
+ /**
+ * Language name.
+ */
+ name: string;
+ /**
+ * Language two-character ISO 639-1 codes.
+ */
+ code: string;
+ /**
+ * Language native name.
+ */
+ nativeName: string;
+ }
+ /**
+ * Currency
+ */
+ export type Currency = {
+ /**
+ * Currency symbol.
+ */
+ symbol: string;
+ /**
+ * Currency name.
+ */
+ name: string;
+ /**
+ * Currency native symbol.
+ */
+ symbolNative: string;
+ /**
+ * Number of decimal digits.
+ */
+ decimalDigits: number;
+ /**
+ * Currency digit rounding.
+ */
+ rounding: number;
+ /**
+ * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format.
+ */
+ code: string;
+ /**
+ * Currency plural name
+ */
+ namePlural: string;
+ }
+ /**
+ * Phone
+ */
+ export type Phone = {
+ /**
+ * Phone code.
+ */
+ code: string;
+ /**
+ * Country two-character ISO 3166-1 alpha code.
+ */
+ countryCode: string;
+ /**
+ * Country name.
+ */
+ countryName: string;
+ }
+ /**
+ * Health Antivirus
+ */
+ export type HealthAntivirus = {
+ /**
+ * Antivirus version.
+ */
+ version: string;
+ /**
+ * Antivirus status. Possible values can are: `disabled`, `offline`, `online`
+ */
+ status: string;
+ }
+ /**
+ * Health Queue
+ */
+ export type HealthQueue = {
+ /**
+ * Amount of actions in the queue.
+ */
+ size: number;
+ }
+ /**
+ * Health Status
+ */
+ export type HealthStatus = {
+ /**
+ * Duration in milliseconds how long the health check took.
+ */
+ ping: number;
+ /**
+ * Service status. Possible values can are: `pass`, `fail`
+ */
+ status: string;
+ }
+ /**
+ * Health Time
+ */
+ export type HealthTime = {
+ /**
+ * Current unix timestamp on trustful remote server.
+ */
+ remoteTime: number;
+ /**
+ * Current unix timestamp of local server where Appwrite runs.
+ */
+ localTime: number;
+ /**
+ * Difference of unix remote and local timestamps in milliseconds.
+ */
+ diff: number;
+ }
+ /**
+ * Metric
+ */
+ export type Metric = {
+ /**
+ * The value of this metric at the timestamp.
+ */
+ value: number;
+ /**
+ * The date at which this metric was aggregated in ISO 8601 format.
+ */
+ date: string;
+ }
+ /**
+ * UsageDatabases
+ */
+ export type UsageDatabases = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for total number of documents.
+ */
+ databasesCount: Metric[];
+ /**
+ * Aggregated stats for total number of documents.
+ */
+ documentsCount: Metric[];
+ /**
+ * Aggregated stats for total number of collections.
+ */
+ collectionsCount: Metric[];
+ /**
+ * Aggregated stats for documents created.
+ */
+ databasesCreate: Metric[];
+ /**
+ * Aggregated stats for documents read.
+ */
+ databasesRead: Metric[];
+ /**
+ * Aggregated stats for documents updated.
+ */
+ databasesUpdate: Metric[];
+ /**
+ * Aggregated stats for total number of collections.
+ */
+ databasesDelete: Metric[];
+ /**
+ * Aggregated stats for documents created.
+ */
+ documentsCreate: Metric[];
+ /**
+ * Aggregated stats for documents read.
+ */
+ documentsRead: Metric[];
+ /**
+ * Aggregated stats for documents updated.
+ */
+ documentsUpdate: Metric[];
+ /**
+ * Aggregated stats for documents deleted.
+ */
+ documentsDelete: Metric[];
+ /**
+ * Aggregated stats for collections created.
+ */
+ collectionsCreate: Metric[];
+ /**
+ * Aggregated stats for collections read.
+ */
+ collectionsRead: Metric[];
+ /**
+ * Aggregated stats for collections updated.
+ */
+ collectionsUpdate: Metric[];
+ /**
+ * Aggregated stats for collections delete.
+ */
+ collectionsDelete: Metric[];
+ }
+ /**
+ * UsageDatabase
+ */
+ export type UsageDatabase = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for total number of documents.
+ */
+ documentsCount: Metric[];
+ /**
+ * Aggregated stats for total number of collections.
+ */
+ collectionsCount: Metric[];
+ /**
+ * Aggregated stats for documents created.
+ */
+ documentsCreate: Metric[];
+ /**
+ * Aggregated stats for documents read.
+ */
+ documentsRead: Metric[];
+ /**
+ * Aggregated stats for documents updated.
+ */
+ documentsUpdate: Metric[];
+ /**
+ * Aggregated stats for documents deleted.
+ */
+ documentsDelete: Metric[];
+ /**
+ * Aggregated stats for collections created.
+ */
+ collectionsCreate: Metric[];
+ /**
+ * Aggregated stats for collections read.
+ */
+ collectionsRead: Metric[];
+ /**
+ * Aggregated stats for collections updated.
+ */
+ collectionsUpdate: Metric[];
+ /**
+ * Aggregated stats for collections delete.
+ */
+ collectionsDelete: Metric[];
+ }
+ /**
+ * UsageCollection
+ */
+ export type UsageCollection = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for total number of documents.
+ */
+ documentsCount: Metric[];
+ /**
+ * Aggregated stats for documents created.
+ */
+ documentsCreate: Metric[];
+ /**
+ * Aggregated stats for documents read.
+ */
+ documentsRead: Metric[];
+ /**
+ * Aggregated stats for documents updated.
+ */
+ documentsUpdate: Metric[];
+ /**
+ * Aggregated stats for documents deleted.
+ */
+ documentsDelete: Metric[];
+ }
+ /**
+ * UsageUsers
+ */
+ export type UsageUsers = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for total number of users.
+ */
+ usersCount: Metric[];
+ /**
+ * Aggregated stats for users created.
+ */
+ usersCreate: Metric[];
+ /**
+ * Aggregated stats for users read.
+ */
+ usersRead: Metric[];
+ /**
+ * Aggregated stats for users updated.
+ */
+ usersUpdate: Metric[];
+ /**
+ * Aggregated stats for users deleted.
+ */
+ usersDelete: Metric[];
+ /**
+ * Aggregated stats for sessions created.
+ */
+ sessionsCreate: Metric[];
+ /**
+ * Aggregated stats for sessions created for a provider ( email, anonymous or oauth2 ).
+ */
+ sessionsProviderCreate: Metric[];
+ /**
+ * Aggregated stats for sessions deleted.
+ */
+ sessionsDelete: Metric[];
+ }
+ /**
+ * StorageUsage
+ */
+ export type UsageStorage = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for the occupied storage size (in bytes).
+ */
+ storage: Metric[];
+ /**
+ * Aggregated stats for total number of files.
+ */
+ filesCount: Metric[];
+ /**
+ * Aggregated stats for total number of buckets.
+ */
+ bucketsCount: Metric[];
+ /**
+ * Aggregated stats for buckets created.
+ */
+ bucketsCreate: Metric[];
+ /**
+ * Aggregated stats for buckets read.
+ */
+ bucketsRead: Metric[];
+ /**
+ * Aggregated stats for buckets updated.
+ */
+ bucketsUpdate: Metric[];
+ /**
+ * Aggregated stats for buckets deleted.
+ */
+ bucketsDelete: Metric[];
+ /**
+ * Aggregated stats for files created.
+ */
+ filesCreate: Metric[];
+ /**
+ * Aggregated stats for files read.
+ */
+ filesRead: Metric[];
+ /**
+ * Aggregated stats for files updated.
+ */
+ filesUpdate: Metric[];
+ /**
+ * Aggregated stats for files deleted.
+ */
+ filesDelete: Metric[];
+ }
+ /**
+ * UsageBuckets
+ */
+ export type UsageBuckets = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for total number of files in this bucket.
+ */
+ filesCount: Metric[];
+ /**
+ * Aggregated stats for total storage of files in this bucket.
+ */
+ filesStorage: Metric[];
+ /**
+ * Aggregated stats for files created.
+ */
+ filesCreate: Metric[];
+ /**
+ * Aggregated stats for files read.
+ */
+ filesRead: Metric[];
+ /**
+ * Aggregated stats for files updated.
+ */
+ filesUpdate: Metric[];
+ /**
+ * Aggregated stats for files deleted.
+ */
+ filesDelete: Metric[];
+ }
+ /**
+ * UsageFunctions
+ */
+ export type UsageFunctions = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for number of function executions.
+ */
+ executionsTotal: Metric[];
+ /**
+ * Aggregated stats for function execution failures.
+ */
+ executionsFailure: Metric[];
+ /**
+ * Aggregated stats for function execution successes.
+ */
+ executionsSuccess: Metric[];
+ /**
+ * Aggregated stats for function execution duration.
+ */
+ executionsTime: Metric[];
+ /**
+ * Aggregated stats for number of function builds.
+ */
+ buildsTotal: Metric[];
+ /**
+ * Aggregated stats for function build failures.
+ */
+ buildsFailure: Metric[];
+ /**
+ * Aggregated stats for function build successes.
+ */
+ buildsSuccess: Metric[];
+ /**
+ * Aggregated stats for function build duration.
+ */
+ buildsTime: Metric[];
+ }
+ /**
+ * UsageProject
+ */
+ export type UsageProject = {
+ /**
+ * The time range of the usage stats.
+ */
+ range: string;
+ /**
+ * Aggregated stats for number of requests.
+ */
+ requests: Metric[];
+ /**
+ * Aggregated stats for consumed bandwidth.
+ */
+ network: Metric[];
+ /**
+ * Aggregated stats for function executions.
+ */
+ executions: Metric[];
+ /**
+ * Aggregated stats for number of documents.
+ */
+ documents: Metric[];
+ /**
+ * Aggregated stats for number of databases.
+ */
+ databases: Metric[];
+ /**
+ * Aggregated stats for number of users.
+ */
+ users: Metric[];
+ /**
+ * Aggregated stats for the occupied storage size (in bytes).
+ */
+ storage: Metric[];
+ /**
+ * Aggregated stats for number of buckets.
+ */
+ buckets: Metric[];
+ }
+}
diff --git a/src/permission.ts b/src/permission.ts
new file mode 100644
index 0000000..bfc330a
--- /dev/null
+++ b/src/permission.ts
@@ -0,0 +1,22 @@
+export class Permission {
+
+ static read = (role: string): string => {
+ return `read("${role}")`
+ }
+
+ static write = (role: string): string => {
+ return `write("${role}")`
+ }
+
+ static create = (role: string): string => {
+ return `create("${role}")`
+ }
+
+ static update = (role: string): string => {
+ return `update("${role}")`
+ }
+
+ static delete = (role: string): string => {
+ return `delete("${role}")`
+ }
+}
diff --git a/src/query.ts b/src/query.ts
new file mode 100644
index 0000000..962a6c8
--- /dev/null
+++ b/src/query.ts
@@ -0,0 +1,56 @@
+type QueryTypesSingle = string | number | boolean;
+export type QueryTypesList = string[] | number[] | boolean[];
+export type QueryTypes = QueryTypesSingle | QueryTypesList;
+
+export class Query {
+ static equal = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "equal", value);
+
+ static notEqual = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "notEqual", value);
+
+ static lessThan = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "lessThan", value);
+
+ static lessThanEqual = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "lessThanEqual", value);
+
+ static greaterThan = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "greaterThan", value);
+
+ static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
+ Query.addQuery(attribute, "greaterThanEqual", value);
+
+ static search = (attribute: string, value: string): string =>
+ Query.addQuery(attribute, "search", value);
+
+ static orderDesc = (attribute: string): string =>
+ `orderDesc("${attribute}")`;
+
+ static orderAsc = (attribute: string): string =>
+ `orderAsc("${attribute}")`;
+
+ static cursorAfter = (documentId: string): string =>
+ `cursorAfter("${documentId}")`;
+
+ static cursorBefore = (documentId: string): string =>
+ `cursorBefore("${documentId}")`;
+
+ static limit = (limit: number): string =>
+ `limit(${limit})`;
+
+ static offset = (offset: number): string =>
+ `offset(${offset})`;
+
+ private static addQuery = (attribute: string, method: string, value: QueryTypes): string =>
+ value instanceof Array
+ ? `${method}("${attribute}", [${value
+ .map((v: QueryTypesSingle) => Query.parseValues(v))
+ .join(",")}])`
+ : `${method}("${attribute}", [${Query.parseValues(value)}])`;
+
+ private static parseValues = (value: QueryTypes): string =>
+ typeof value === "string" || value instanceof String
+ ? `"${value}"`
+ : `${value}`;
+}
\ No newline at end of file
diff --git a/src/role.ts b/src/role.ts
new file mode 100644
index 0000000..d94e398
--- /dev/null
+++ b/src/role.ts
@@ -0,0 +1,34 @@
+export class Role {
+ public static any(): string {
+ return 'any'
+ }
+
+ public static user(id: string, status: string = ''): string {
+ if(status === '') {
+ return `user:${id}`
+ }
+ return `user:${id}/${status}`
+ }
+
+ public static users(status: string = ''): string {
+ if(status === '') {
+ return 'users'
+ }
+ return `users/${status}`
+ }
+
+ public static guests(): string {
+ return 'guests'
+ }
+
+ public static team(id: string, role: string = ''): string {
+ if(role === '') {
+ return `team:${id}`
+ }
+ return `team:${id}/${role}`
+ }
+
+ public static member(id: string): string {
+ return `member:${id}`
+ }
+}
\ No newline at end of file
diff --git a/src/service.ts b/src/service.ts
new file mode 100644
index 0000000..0c9662b
--- /dev/null
+++ b/src/service.ts
@@ -0,0 +1,30 @@
+import { Client } from './client';
+import type { Payload } from './client';
+
+export class Service {
+ static CHUNK_SIZE = 5*1024*1024; // 5MB
+
+ client: Client;
+
+ constructor(client: Client) {
+ this.client = client;
+ }
+
+ static flatten(data: Payload, prefix = ''): Payload {
+ let output: Payload = {};
+
+ 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));
+ }
+ else {
+ output[finalKey] = value;
+ }
+ }
+
+ return output;
+ }
+}
\ No newline at end of file
diff --git a/src/services/account.ts b/src/services/account.ts
new file mode 100644
index 0000000..4e89060
--- /dev/null
+++ b/src/services/account.ts
@@ -0,0 +1,1009 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Account extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * Get Account
+ *
+ * Get currently logged in user data as JSON object.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(): Promise> {
+ let path = '/account';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Account
+ *
+ * Use this endpoint to allow a new user to register a new account in your
+ * project. After the user registration completes successfully, you can use
+ * the [/account/verfication](/docs/client/account#accountCreateVerification)
+ * route to start verifying the user email address. To allow the new user to
+ * login to their new account, you need to create a new [account
+ * session](/docs/client/account#accountCreateSession).
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(userId: string, email: string, password: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/account';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Email
+ *
+ * Update currently logged in user account email address. After changing user
+ * address, the user confirmation status will get reset. A new confirmation
+ * email is not sent automatically however you can use the send confirmation
+ * email endpoint again to send the confirmation email. For security measures,
+ * user password is required to complete this request.
+ * This endpoint can also be used to convert an anonymous account to a normal
+ * one, by passing an email address and a new password.
+ *
+ *
+ * @param {string} email
+ * @param {string} password
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateEmail(email: string, password: string): Promise> {
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/account/email';
+ let payload: Payload = {};
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create JWT
+ *
+ * Use this endpoint to create a JSON Web Token. You can use the resulting JWT
+ * to authenticate on behalf of the current user when working with the
+ * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
+ * from its creation and will be invalid if the user will logout in that time
+ * frame.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createJWT(): Promise {
+ let path = '/account/jwt';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Logs
+ *
+ * Get currently logged in user list of latest security activity logs. Each
+ * log returns user IP address, location and date and time of log.
+ *
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listLogs(queries?: string[]): Promise {
+ let path = '/account/logs';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Name
+ *
+ * Update currently logged in user account name.
+ *
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateName(name: string): Promise> {
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/account/name';
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Password
+ *
+ * Update currently logged in user password. For validation, user is required
+ * to pass in the new password, and the old password. For users created with
+ * OAuth, Team Invites and Magic URL, oldPassword is optional.
+ *
+ * @param {string} password
+ * @param {string} oldPassword
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePassword(password: string, oldPassword?: string): Promise> {
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/account/password';
+ let payload: Payload = {};
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof oldPassword !== 'undefined') {
+ payload['oldPassword'] = oldPassword;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Phone
+ *
+ * Update the currently logged in user's phone number. After updating the
+ * phone number, the phone verification status will be reset. A confirmation
+ * SMS is not sent automatically, however you can use the [POST
+ * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification)
+ * endpoint to send a confirmation SMS.
+ *
+ * @param {string} phone
+ * @param {string} password
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePhone(phone: string, password: string): Promise> {
+ if (typeof phone === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "phone"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/account/phone';
+ let payload: Payload = {};
+
+ if (typeof phone !== 'undefined') {
+ payload['phone'] = phone;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Account Preferences
+ *
+ * Get currently logged in user preferences as a key-value object.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getPrefs(): Promise {
+ let path = '/account/prefs';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Preferences
+ *
+ * Update currently logged in user account preferences. The object you pass is
+ * stored as is, and replaces any previous value. The maximum allowed prefs
+ * size is 64kB and throws error if exceeded.
+ *
+ * @param {object} prefs
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePrefs(prefs: object): Promise> {
+ if (typeof prefs === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "prefs"');
+ }
+
+ let path = '/account/prefs';
+ let payload: Payload = {};
+
+ if (typeof prefs !== 'undefined') {
+ payload['prefs'] = prefs;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Password Recovery
+ *
+ * Sends the user an email with a temporary secret key for password reset.
+ * When the user clicks the confirmation link he is redirected back to your
+ * app password reset URL with the secret key and email address values
+ * attached to the URL query string. Use the query string params to submit a
+ * request to the [PUT
+ * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to
+ * complete the process. The verification link sent to the user's email
+ * address is valid for 1 hour.
+ *
+ * @param {string} email
+ * @param {string} url
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createRecovery(email: string, url: string): Promise {
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ let path = '/account/recovery';
+ let payload: Payload = {};
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Password Recovery (confirmation)
+ *
+ * Use this endpoint to complete the user account password reset. Both the
+ * **userId** and **secret** arguments will be passed as query parameters to
+ * the redirect URL you have provided when sending your request to the [POST
+ * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint.
+ *
+ * Please note that in order to avoid a [Redirect
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
+ * the only valid redirect URLs are the ones from domains you have set when
+ * adding your platforms in the console interface.
+ *
+ * @param {string} userId
+ * @param {string} secret
+ * @param {string} password
+ * @param {string} passwordAgain
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateRecovery(userId: string, secret: string, password: string, passwordAgain: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ if (typeof passwordAgain === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordAgain"');
+ }
+
+ let path = '/account/recovery';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof passwordAgain !== 'undefined') {
+ payload['passwordAgain'] = passwordAgain;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Sessions
+ *
+ * Get currently logged in user list of active sessions across different
+ * devices.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listSessions(): Promise {
+ let path = '/account/sessions';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Sessions
+ *
+ * Delete all sessions from the user account and remove any sessions cookies
+ * from the end client.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteSessions(): Promise<{}> {
+ let path = '/account/sessions';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Anonymous Session
+ *
+ * Use this endpoint to allow a new user to register an anonymous account in
+ * your project. This route will also create a new session for the user. To
+ * allow the new user to convert an anonymous account to a normal account, you
+ * need to update its [email and
+ * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
+ * session](/docs/client/account#accountCreateOAuth2Session).
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createAnonymousSession(): Promise {
+ let path = '/account/sessions/anonymous';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Email Session
+ *
+ * Allow the user to login into their account by providing a valid email and
+ * password combination. This route will create a new session for the user.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session limits](/docs/authentication#limits).
+ *
+ * @param {string} email
+ * @param {string} password
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createEmailSession(email: string, password: string): Promise {
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/account/sessions/email';
+ let payload: Payload = {};
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Magic URL session
+ *
+ * Sends the user an email with a secret key for creating a session. If the
+ * provided user ID has not be registered, a new user will be created. When
+ * the user clicks the link in the email, the user is redirected back to the
+ * URL you provided with the secret key and userId values attached to the URL
+ * query string. Use the query string parameters to submit a request to the
+ * [PUT
+ * /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession)
+ * endpoint to complete the login process. The link sent to the user's email
+ * address is valid for 1 hour. If you are on a mobile device you can leave
+ * the URL parameter empty, so that the login completion will be handled by
+ * your Appwrite instance by default.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session limits](/docs/authentication#limits).
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} url
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMagicURLSession(userId: string, email: string, url?: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ let path = '/account/sessions/magic-url';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Magic URL session (confirmation)
+ *
+ * Use this endpoint to complete creating the session with the Magic URL. Both
+ * the **userId** and **secret** arguments will be passed as query parameters
+ * to the redirect URL you have provided when sending your request to the
+ * [POST
+ * /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession)
+ * endpoint.
+ *
+ * Please note that in order to avoid a [Redirect
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
+ * the only valid redirect URLs are the ones from domains you have set when
+ * adding your platforms in the console interface.
+ *
+ * @param {string} userId
+ * @param {string} secret
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMagicURLSession(userId: string, secret: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ let path = '/account/sessions/magic-url';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create OAuth2 Session
+ *
+ * Allow the user to login to their account using the OAuth2 provider of their
+ * choice. Each OAuth2 provider should be enabled from the Appwrite console
+ * first. Use the success and failure arguments to provide a redirect URL's
+ * back to your app when login is completed.
+ *
+ * If there is already an active session, the new session will be attached to
+ * the logged-in account. If there are no active sessions, the server will
+ * attempt to look for a user with the same email address as the email
+ * received from the OAuth2 provider and attach the new session to the
+ * existing user. If no matching user is found - the server will create a new
+ * user.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session limits](/docs/authentication#limits).
+ *
+ *
+ * @param {string} provider
+ * @param {string} success
+ * @param {string} failure
+ * @param {string[]} scopes
+ * @throws {AppwriteException}
+ * @returns {void|string}
+ */
+ createOAuth2Session(provider: string, success?: string, failure?: string, scopes?: string[]): void | URL {
+ if (typeof provider === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "provider"');
+ }
+
+ let path = '/account/sessions/oauth2/{provider}'.replace('{provider}', provider);
+ let payload: Payload = {};
+
+ if (typeof success !== 'undefined') {
+ payload['success'] = success;
+ }
+
+ if (typeof failure !== 'undefined') {
+ payload['failure'] = failure;
+ }
+
+ if (typeof scopes !== 'undefined') {
+ payload['scopes'] = scopes;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ if (typeof window !== 'undefined' && window?.location) {
+ window.location.href = uri.toString();
+ } else {
+ return uri;
+ }
+ }
+
+ /**
+ * Create Phone session
+ *
+ * Sends the user an SMS with a secret key for creating a session. If the
+ * provided user ID has not be registered, a new user will be created. Use the
+ * returned user ID and secret and submit a request to the [PUT
+ * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession)
+ * endpoint to complete the login process. The secret sent to the user's phone
+ * is valid for 15 minutes.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session limits](/docs/authentication#limits).
+ *
+ * @param {string} userId
+ * @param {string} phone
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPhoneSession(userId: string, phone: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof phone === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "phone"');
+ }
+
+ let path = '/account/sessions/phone';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof phone !== 'undefined') {
+ payload['phone'] = phone;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Phone Session (confirmation)
+ *
+ * Use this endpoint to complete creating a session with SMS. Use the
+ * **userId** from the
+ * [createPhoneSession](/docs/client/account#accountCreatePhoneSession)
+ * endpoint and the **secret** received via SMS to successfully update and
+ * confirm the phone session.
+ *
+ * @param {string} userId
+ * @param {string} secret
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePhoneSession(userId: string, secret: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ let path = '/account/sessions/phone';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Session
+ *
+ * Use this endpoint to get a logged in user's session using a Session ID.
+ * Inputting 'current' will return the current session being used.
+ *
+ * @param {string} sessionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getSession(sessionId: string): Promise {
+ if (typeof sessionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "sessionId"');
+ }
+
+ let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update OAuth Session (Refresh Tokens)
+ *
+ * Access tokens have limited lifespan and expire to mitigate security risks.
+ * If session was created using an OAuth provider, this route can be used to
+ * "refresh" the access token.
+ *
+ * @param {string} sessionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateSession(sessionId: string): Promise {
+ if (typeof sessionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "sessionId"');
+ }
+
+ let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Session
+ *
+ * Use this endpoint to log out the currently logged in user from all their
+ * account sessions across all of their different devices. When using the
+ * Session ID argument, only the unique session ID provided is deleted.
+ *
+ *
+ * @param {string} sessionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteSession(sessionId: string): Promise<{}> {
+ if (typeof sessionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "sessionId"');
+ }
+
+ let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Status
+ *
+ * Block the currently logged in user account. Behind the scene, the user
+ * record is not deleted but permanently blocked from any access. To
+ * completely delete a user, use the Users API instead.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateStatus(): Promise> {
+ let path = '/account/status';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Email Verification
+ *
+ * Use this endpoint to send a verification message to your user email address
+ * to confirm they are the valid owners of that address. Both the **userId**
+ * and **secret** arguments will be passed as query parameters to the URL you
+ * have provided to be attached to the verification email. The provided URL
+ * should redirect the user back to your app and allow you to complete the
+ * verification process by verifying both the **userId** and **secret**
+ * parameters. Learn more about how to [complete the verification
+ * process](/docs/client/account#accountUpdateEmailVerification). The
+ * verification link sent to the user's email address is valid for 7 days.
+ *
+ * Please note that in order to avoid a [Redirect
+ * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
+ * the only valid redirect URLs are the ones from domains you have set when
+ * adding your platforms in the console interface.
+ *
+ *
+ * @param {string} url
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createVerification(url: string): Promise {
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ let path = '/account/verification';
+ let payload: Payload = {};
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Email Verification (confirmation)
+ *
+ * Use this endpoint to complete the user email verification process. Use both
+ * the **userId** and **secret** parameters that were attached to your app URL
+ * to verify the user email ownership. If confirmed this route will return a
+ * 200 status code.
+ *
+ * @param {string} userId
+ * @param {string} secret
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateVerification(userId: string, secret: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ let path = '/account/verification';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Phone Verification
+ *
+ * Use this endpoint to send a verification SMS to the currently logged in
+ * user. This endpoint is meant for use after updating a user's phone number
+ * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone)
+ * endpoint. Learn more about how to [complete the verification
+ * process](/docs/client/account#accountUpdatePhoneVerification). The
+ * verification code sent to the user's phone number is valid for 15 minutes.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPhoneVerification(): Promise {
+ let path = '/account/verification/phone';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Phone Verification (confirmation)
+ *
+ * Use this endpoint to complete the user phone verification process. Use the
+ * **userId** and **secret** that were sent to your user's phone number to
+ * verify the user email ownership. If confirmed this route will return a 200
+ * status code.
+ *
+ * @param {string} userId
+ * @param {string} secret
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePhoneVerification(userId: string, secret: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ let path = '/account/verification/phone';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/avatars.ts b/src/services/avatars.ts
new file mode 100644
index 0000000..8887269
--- /dev/null
+++ b/src/services/avatars.ts
@@ -0,0 +1,351 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Avatars extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * Get Browser Icon
+ *
+ * You can use this endpoint to show different browser icons to your users.
+ * The code argument receives the browser code as it appears in your user [GET
+ * /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
+ * width, height and quality arguments to change the output settings.
+ *
+ * When one dimension is specified and the other is 0, the image is scaled
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
+ * image at source quality. If dimensions are not specified, the default size
+ * of image returned is 100x100px.
+ *
+ * @param {string} code
+ * @param {number} width
+ * @param {number} height
+ * @param {number} quality
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getBrowser(code: string, width?: number, height?: number, quality?: number): URL {
+ if (typeof code === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "code"');
+ }
+
+ let path = '/avatars/browsers/{code}'.replace('{code}', code);
+ let payload: Payload = {};
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ if (typeof quality !== 'undefined') {
+ payload['quality'] = quality;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * Get Credit Card Icon
+ *
+ * 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.
+ *
+ * When one dimension is specified and the other is 0, the image is scaled
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
+ * image at source quality. If dimensions are not specified, the default size
+ * of image returned is 100x100px.
+ *
+ *
+ * @param {string} code
+ * @param {number} width
+ * @param {number} height
+ * @param {number} quality
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getCreditCard(code: string, width?: number, height?: number, quality?: number): URL {
+ if (typeof code === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "code"');
+ }
+
+ let path = '/avatars/credit-cards/{code}'.replace('{code}', code);
+ let payload: Payload = {};
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ if (typeof quality !== 'undefined') {
+ payload['quality'] = quality;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * Get Favicon
+ *
+ * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
+ * website URL.
+ *
+ *
+ * @param {string} url
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getFavicon(url: string): URL {
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ let path = '/avatars/favicon';
+ let payload: Payload = {};
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * 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. Country codes
+ * follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard.
+ *
+ * When one dimension is specified and the other is 0, the image is scaled
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
+ * image at source quality. If dimensions are not specified, the default size
+ * of image returned is 100x100px.
+ *
+ *
+ * @param {string} code
+ * @param {number} width
+ * @param {number} height
+ * @param {number} quality
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getFlag(code: string, width?: number, height?: number, quality?: number): URL {
+ if (typeof code === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "code"');
+ }
+
+ let path = '/avatars/flags/{code}'.replace('{code}', code);
+ let payload: Payload = {};
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ if (typeof quality !== 'undefined') {
+ payload['quality'] = quality;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * 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.
+ *
+ * When one dimension is specified and the other is 0, the image is scaled
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
+ * image at source quality. If dimensions are not specified, the default size
+ * of image returned is 400x400px.
+ *
+ *
+ * @param {string} url
+ * @param {number} width
+ * @param {number} height
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getImage(url: string, width?: number, height?: number): URL {
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ let path = '/avatars/image';
+ let payload: Payload = {};
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * Get User Initials
+ *
+ * Use this endpoint to show your user initials avatar icon on your website or
+ * app. By default, this route will try to print your logged-in user name or
+ * email initials. You can also overwrite the user name if you pass the 'name'
+ * parameter. If no name is given and no user is logged, an empty avatar will
+ * be returned.
+ *
+ * You can use the color and background params to change the avatar colors. By
+ * default, a random theme will be selected. The random theme will persist for
+ * the user's initials when reloading the same theme will always return for
+ * the same initials.
+ *
+ * When one dimension is specified and the other is 0, the image is scaled
+ * with preserved aspect ratio. If both dimensions are 0, the API provides an
+ * image at source quality. If dimensions are not specified, the default size
+ * of image returned is 100x100px.
+ *
+ *
+ * @param {string} name
+ * @param {number} width
+ * @param {number} height
+ * @param {string} background
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getInitials(name?: string, width?: number, height?: number, background?: string): URL {
+ let path = '/avatars/initials';
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ if (typeof background !== 'undefined') {
+ payload['background'] = background;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * 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 {boolean} download
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getQR(text: string, size?: number, margin?: number, download?: boolean): URL {
+ if (typeof text === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "text"');
+ }
+
+ let path = '/avatars/qr';
+ let payload: Payload = {};
+
+ if (typeof text !== 'undefined') {
+ payload['text'] = text;
+ }
+
+ if (typeof size !== 'undefined') {
+ payload['size'] = size;
+ }
+
+ if (typeof margin !== 'undefined') {
+ payload['margin'] = margin;
+ }
+
+ if (typeof download !== 'undefined') {
+ payload['download'] = download;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+};
diff --git a/src/services/databases.ts b/src/services/databases.ts
new file mode 100644
index 0000000..64fc009
--- /dev/null
+++ b/src/services/databases.ts
@@ -0,0 +1,1525 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Databases extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List Databases
+ *
+ * Get a list of all databases from the current Appwrite project. You can use
+ * the search parameter to filter your results.
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async list(queries?: string[], search?: string): Promise {
+ let path = '/databases';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Database
+ *
+ * Create a new Database.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(databaseId: string, name: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/databases';
+ let payload: Payload = {};
+
+ if (typeof databaseId !== 'undefined') {
+ payload['databaseId'] = databaseId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for the database
+ *
+ *
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getUsage(range?: string): Promise {
+ let path = '/databases/usage';
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Database
+ *
+ * Get a database by its unique ID. This endpoint response returns a JSON
+ * object with the database metadata.
+ *
+ * @param {string} databaseId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(databaseId: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Database
+ *
+ * Update a database by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async update(databaseId: string, name: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Database
+ *
+ * Delete a database by its unique ID. Only API keys with with databases.write
+ * scope can delete a database.
+ *
+ * @param {string} databaseId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async delete(databaseId: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Collections
+ *
+ * Get a list of all collections that belong to the provided databaseId. You
+ * can use the search parameter to filter your results.
+ *
+ * @param {string} databaseId
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCollections(databaseId: string, queries?: string[], search?: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Collection
+ *
+ * Create a new Collection. Before using this route, you should create a new
+ * database resource using either a [server
+ * integration](/docs/server/databases#databasesCreateCollection) API or
+ * directly from your database console.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} name
+ * @param {string[]} permissions
+ * @param {boolean} documentSecurity
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ if (typeof collectionId !== 'undefined') {
+ payload['collectionId'] = collectionId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ if (typeof documentSecurity !== 'undefined') {
+ payload['documentSecurity'] = documentSecurity;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Collection
+ *
+ * Get a collection by its unique ID. This endpoint response returns a JSON
+ * object with the collection metadata.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getCollection(databaseId: string, collectionId: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Collection
+ *
+ * Update a collection by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} name
+ * @param {string[]} permissions
+ * @param {boolean} documentSecurity
+ * @param {boolean} enabled
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateCollection(databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ if (typeof documentSecurity !== 'undefined') {
+ payload['documentSecurity'] = documentSecurity;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Collection
+ *
+ * Delete a collection by its unique ID. Only users with write permissions
+ * have access to delete this resource.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteCollection(databaseId: string, collectionId: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Attributes
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listAttributes(databaseId: string, collectionId: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Boolean Attribute
+ *
+ * Create a boolean attribute.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {boolean} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createBooleanAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create DateTime Attribute
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createDatetimeAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Email Attribute
+ *
+ * Create an email attribute.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createEmailAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Enum Attribute
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {string[]} elements
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createEnumAttribute(databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof elements === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "elements"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof elements !== 'undefined') {
+ payload['elements'] = elements;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Float Attribute
+ *
+ * Create a float attribute. Optionally, minimum and maximum values can be
+ * provided.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {number} min
+ * @param {number} max
+ * @param {number} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createFloatAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof min !== 'undefined') {
+ payload['min'] = min;
+ }
+
+ if (typeof max !== 'undefined') {
+ payload['max'] = max;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Integer Attribute
+ *
+ * Create an integer attribute. Optionally, minimum and maximum values can be
+ * provided.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {number} min
+ * @param {number} max
+ * @param {number} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createIntegerAttribute(databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof min !== 'undefined') {
+ payload['min'] = min;
+ }
+
+ if (typeof max !== 'undefined') {
+ payload['max'] = max;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create IP Address Attribute
+ *
+ * Create IP address attribute.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createIpAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create String Attribute
+ *
+ * Create a string attribute.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {number} size
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createStringAttribute(databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof size === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "size"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof size !== 'undefined') {
+ payload['size'] = size;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create URL Attribute
+ *
+ * Create a URL attribute.
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {boolean} required
+ * @param {string} xdefault
+ * @param {boolean} array
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createUrlAttribute(databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof required === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "required"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof required !== 'undefined') {
+ payload['required'] = required;
+ }
+
+ if (typeof xdefault !== 'undefined') {
+ payload['default'] = xdefault;
+ }
+
+ if (typeof array !== 'undefined') {
+ payload['array'] = array;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Attribute
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Attribute
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteAttribute(databaseId: string, collectionId: string, key: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Documents
+ *
+ * Get a list of all the user's documents in a given collection. You can use
+ * the query params to filter your results.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Document
+ *
+ * Create a new Document. Before using this route, you should create a new
+ * collection resource using either a [server
+ * integration](/docs/server/databases#databasesCreateCollection) API or
+ * directly from your database console.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} documentId
+ * @param {Omit} data
+ * @param {string[]} permissions
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createDocument(databaseId: string, collectionId: string, documentId: string, data: Omit, permissions?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof documentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "documentId"');
+ }
+
+ if (typeof data === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "data"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof documentId !== 'undefined') {
+ payload['documentId'] = documentId;
+ }
+
+ if (typeof data !== 'undefined') {
+ payload['data'] = data;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Document
+ *
+ * Get a document by its unique ID. This endpoint response returns a JSON
+ * object with the document data.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} documentId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getDocument(databaseId: string, collectionId: string, documentId: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof documentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "documentId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Document
+ *
+ * Update a document by its unique ID. Using the patch method you can pass
+ * only specific fields that will get updated.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} documentId
+ * @param {Partial>} data
+ * @param {string[]} permissions
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateDocument(databaseId: string, collectionId: string, documentId: string, data?: Partial>, permissions?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof documentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "documentId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
+ let payload: Payload = {};
+
+ if (typeof data !== 'undefined') {
+ payload['data'] = data;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Document
+ *
+ * Delete a document by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} documentId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof documentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "documentId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Document Logs
+ *
+ * Get the document activity logs list by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} documentId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listDocumentLogs(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof documentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "documentId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Indexes
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listIndexes(databaseId: string, collectionId: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Index
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @param {string} type
+ * @param {string[]} attributes
+ * @param {string[]} orders
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createIndex(databaseId: string, collectionId: string, key: string, type: string, attributes: string[], orders?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof type === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "type"');
+ }
+
+ if (typeof attributes === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "attributes"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof type !== 'undefined') {
+ payload['type'] = type;
+ }
+
+ if (typeof attributes !== 'undefined') {
+ payload['attributes'] = attributes;
+ }
+
+ if (typeof orders !== 'undefined') {
+ payload['orders'] = orders;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Index
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getIndex(databaseId: string, collectionId: string, key: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Index
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} key
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteIndex(databaseId: string, collectionId: string, key: string): Promise<{}> {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Collection Logs
+ *
+ * Get the collection activity logs list by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCollectionLogs(databaseId: string, collectionId: string, queries?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/logs'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for a collection
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} collectionId
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getCollectionUsage(databaseId: string, collectionId: string, range?: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ if (typeof collectionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "collectionId"');
+ }
+
+ let path = '/databases/{databaseId}/collections/{collectionId}/usage'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId);
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Database Logs
+ *
+ * Get the database activity logs list by its unique ID.
+ *
+ * @param {string} databaseId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listLogs(databaseId: string, queries?: string[]): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ let path = '/databases/{databaseId}/logs'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for the database
+ *
+ *
+ * @param {string} databaseId
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getDatabaseUsage(databaseId: string, range?: string): Promise {
+ if (typeof databaseId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "databaseId"');
+ }
+
+ let path = '/databases/{databaseId}/usage'.replace('{databaseId}', databaseId);
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/functions.ts b/src/services/functions.ts
new file mode 100644
index 0000000..da1ba1f
--- /dev/null
+++ b/src/services/functions.ts
@@ -0,0 +1,814 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Functions extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List Functions
+ *
+ * Get a list of all the project's functions. You can use the query params to
+ * filter your results.
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async list(queries?: string[], search?: string): Promise {
+ let path = '/functions';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Function
+ *
+ * Create a new function. You can pass a list of
+ * [permissions](/docs/permissions) to allow different project users or team
+ * with access to execute the function using the client API.
+ *
+ * @param {string} functionId
+ * @param {string} name
+ * @param {string[]} execute
+ * @param {string} runtime
+ * @param {string[]} events
+ * @param {string} schedule
+ * @param {number} timeout
+ * @param {boolean} enabled
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(functionId: string, name: string, execute: string[], runtime: string, events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof execute === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "execute"');
+ }
+
+ if (typeof runtime === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "runtime"');
+ }
+
+ let path = '/functions';
+ let payload: Payload = {};
+
+ if (typeof functionId !== 'undefined') {
+ payload['functionId'] = functionId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof execute !== 'undefined') {
+ payload['execute'] = execute;
+ }
+
+ if (typeof runtime !== 'undefined') {
+ payload['runtime'] = runtime;
+ }
+
+ if (typeof events !== 'undefined') {
+ payload['events'] = events;
+ }
+
+ if (typeof schedule !== 'undefined') {
+ payload['schedule'] = schedule;
+ }
+
+ if (typeof timeout !== 'undefined') {
+ payload['timeout'] = timeout;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List runtimes
+ *
+ * Get a list of all runtimes that are currently active on your instance.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listRuntimes(): Promise {
+ let path = '/functions/runtimes';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Functions Usage
+ *
+ *
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getUsage(range?: string): Promise {
+ let path = '/functions/usage';
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Function
+ *
+ * Get a function by its unique ID.
+ *
+ * @param {string} functionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(functionId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Function
+ *
+ * Update function by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} name
+ * @param {string[]} execute
+ * @param {string[]} events
+ * @param {string} schedule
+ * @param {number} timeout
+ * @param {boolean} enabled
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async update(functionId: string, name: string, execute: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof execute === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "execute"');
+ }
+
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof execute !== 'undefined') {
+ payload['execute'] = execute;
+ }
+
+ if (typeof events !== 'undefined') {
+ payload['events'] = events;
+ }
+
+ if (typeof schedule !== 'undefined') {
+ payload['schedule'] = schedule;
+ }
+
+ if (typeof timeout !== 'undefined') {
+ payload['timeout'] = timeout;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Function
+ *
+ * Delete a function by its unique ID.
+ *
+ * @param {string} functionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async delete(functionId: string): Promise<{}> {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Deployments
+ *
+ * Get a list of all the project's code deployments. You can use the query
+ * params to filter your results.
+ *
+ * @param {string} functionId
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listDeployments(functionId: string, queries?: string[], search?: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Deployment
+ *
+ * Create a new function code deployment. Use this endpoint to upload a new
+ * version of your code function. To execute your newly uploaded code, you'll
+ * need to update the function's deployment to use your new deployment UID.
+ *
+ * This endpoint accepts a tar.gz file compressed with your code. Make sure to
+ * include any dependencies your code has within the compressed file. You can
+ * learn more about code packaging in the [Appwrite Cloud Functions
+ * tutorial](/docs/functions).
+ *
+ * Use the "command" param to set the entry point used to execute your code.
+ *
+ * @param {string} functionId
+ * @param {string} entrypoint
+ * @param {File} code
+ * @param {boolean} activate
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createDeployment(functionId: string, entrypoint: string, code: File, activate: boolean, onProgress = (progress: UploadProgress) => {}): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof entrypoint === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "entrypoint"');
+ }
+
+ if (typeof code === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "code"');
+ }
+
+ if (typeof activate === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "activate"');
+ }
+
+ let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof entrypoint !== 'undefined') {
+ payload['entrypoint'] = entrypoint;
+ }
+
+ if (typeof code !== 'undefined') {
+ payload['code'] = code;
+ }
+
+ if (typeof activate !== 'undefined') {
+ payload['activate'] = activate;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+
+ if(!(code instanceof File)) {
+ throw new AppwriteException('Parameter "code" has to be a File.');
+ }
+
+ const size = code.size;
+
+ if (size <= Service.CHUNK_SIZE) {
+ return await this.client.call('post', uri, {
+
+ 'content-type': 'multipart/form-data',
+ }, payload);
+ }
+ let id = undefined;
+ let response = undefined;
+
+ const headers: { [header: string]: string } = {
+ 'content-type': 'multipart/form-data',
+ }
+
+ let counter = 0;
+ const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
+
+ for (counter; counter < totalCounters; counter++) {
+ const start = (counter * Service.CHUNK_SIZE);
+ const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
+
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
+
+ if (id) {
+ headers['x-appwrite-id'] = id;
+ }
+
+ const stream = code.slice(start, end + 1);
+ payload['code'] = new File([stream], code.name);
+
+ response = await this.client.call('post', uri, headers, payload);
+
+ if (!id) {
+ id = response['$id'];
+ }
+
+ if (onProgress) {
+ onProgress({
+ $id: response.$id,
+ progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
+ sizeUploaded: end,
+ chunksTotal: response.chunksTotal,
+ chunksUploaded: response.chunksUploaded
+ });
+ }
+ }
+
+ return response;
+ }
+
+ /**
+ * Get Deployment
+ *
+ * Get a code deployment by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} deploymentId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getDeployment(functionId: string, deploymentId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof deploymentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
+ }
+
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Function Deployment
+ *
+ * Update the function code deployment ID using the unique function ID. Use
+ * this endpoint to switch the code deployment that should be executed by the
+ * execution endpoint.
+ *
+ * @param {string} functionId
+ * @param {string} deploymentId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateDeployment(functionId: string, deploymentId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof deploymentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
+ }
+
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Deployment
+ *
+ * Delete a code deployment by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} deploymentId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteDeployment(functionId: string, deploymentId: string): Promise<{}> {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof deploymentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
+ }
+
+ let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Build
+ *
+ *
+ * @param {string} functionId
+ * @param {string} deploymentId
+ * @param {string} buildId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createBuild(functionId: string, deploymentId: string, buildId: string): Promise<{}> {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof deploymentId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "deploymentId"');
+ }
+
+ if (typeof buildId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "buildId"');
+ }
+
+ let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Executions
+ *
+ * Get a list of all the current user function execution logs. You can use the
+ * query params to filter your results.
+ *
+ * @param {string} functionId
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listExecutions(functionId: string, queries?: string[], search?: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Execution
+ *
+ * Trigger a function execution. The returned object will return you the
+ * current execution status. You can ping the `Get Execution` endpoint to get
+ * updates on the current execution status. Once this endpoint is called, your
+ * function execution process will start asynchronously.
+ *
+ * @param {string} functionId
+ * @param {string} data
+ * @param {boolean} async
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createExecution(functionId: string, data?: string, async?: boolean): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof data !== 'undefined') {
+ payload['data'] = data;
+ }
+
+ if (typeof async !== 'undefined') {
+ payload['async'] = async;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Execution
+ *
+ * Get a function execution log by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} executionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getExecution(functionId: string, executionId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof executionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "executionId"');
+ }
+
+ let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Function Usage
+ *
+ *
+ * @param {string} functionId
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getFunctionUsage(functionId: string, range?: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Variables
+ *
+ * Get a list of all variables of a specific function.
+ *
+ * @param {string} functionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listVariables(functionId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Variable
+ *
+ * Create a new function variable. These variables can be accessed within
+ * function in the `env` object under the request variable.
+ *
+ * @param {string} functionId
+ * @param {string} key
+ * @param {string} value
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createVariable(functionId: string, key: string, value: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ if (typeof value === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "value"');
+ }
+
+ let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof value !== 'undefined') {
+ payload['value'] = value;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Variable
+ *
+ * Get a variable by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} variableId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getVariable(functionId: string, variableId: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof variableId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "variableId"');
+ }
+
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Variable
+ *
+ * Update variable by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} variableId
+ * @param {string} key
+ * @param {string} value
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateVariable(functionId: string, variableId: string, key: string, value?: string): Promise {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof variableId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "variableId"');
+ }
+
+ if (typeof key === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "key"');
+ }
+
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
+ let payload: Payload = {};
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof value !== 'undefined') {
+ payload['value'] = value;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Variable
+ *
+ * Delete a variable by its unique ID.
+ *
+ * @param {string} functionId
+ * @param {string} variableId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteVariable(functionId: string, variableId: string): Promise<{}> {
+ if (typeof functionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "functionId"');
+ }
+
+ if (typeof variableId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "variableId"');
+ }
+
+ let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/graphql.ts b/src/services/graphql.ts
new file mode 100644
index 0000000..f2b288d
--- /dev/null
+++ b/src/services/graphql.ts
@@ -0,0 +1,68 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Graphql extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * GraphQL Endpoint
+ *
+ * Execute a GraphQL mutation.
+ *
+ * @param {object} query
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async query(query: object): Promise<{}> {
+ if (typeof query === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "query"');
+ }
+
+ let path = '/graphql';
+ let payload: Payload = {};
+
+ if (typeof query !== 'undefined') {
+ payload['query'] = query;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'x-sdk-graphql': 'true',
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * GraphQL Endpoint
+ *
+ * Execute a GraphQL mutation.
+ *
+ * @param {object} query
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async mutation(query: object): Promise<{}> {
+ if (typeof query === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "query"');
+ }
+
+ let path = '/graphql/mutation';
+ let payload: Payload = {};
+
+ if (typeof query !== 'undefined') {
+ payload['query'] = query;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'x-sdk-graphql': 'true',
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/health.ts b/src/services/health.ts
new file mode 100644
index 0000000..a20b2b7
--- /dev/null
+++ b/src/services/health.ts
@@ -0,0 +1,202 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Health extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * Get HTTP
+ *
+ * Check the Appwrite HTTP server is up and responsive.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(): Promise {
+ let path = '/health';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Antivirus
+ *
+ * Check the Appwrite Antivirus server is up and connection is successful.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getAntivirus(): Promise {
+ let path = '/health/anti-virus';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Cache
+ *
+ * Check the Appwrite in-memory cache server is up and connection is
+ * successful.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getCache(): Promise {
+ let path = '/health/cache';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get DB
+ *
+ * Check the Appwrite database server is up and connection is successful.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getDB(): Promise {
+ let path = '/health/db';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Certificates Queue
+ *
+ * Get the number of certificates that are waiting to be issued against
+ * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue
+ * server.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getQueueCertificates(): Promise {
+ let path = '/health/queue/certificates';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Functions Queue
+ *
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getQueueFunctions(): Promise {
+ let path = '/health/queue/functions';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Logs Queue
+ *
+ * Get the number of logs that are waiting to be processed in the Appwrite
+ * internal queue server.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getQueueLogs(): Promise {
+ let path = '/health/queue/logs';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Webhooks Queue
+ *
+ * Get the number of webhooks that are waiting to be processed in the Appwrite
+ * internal queue server.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getQueueWebhooks(): Promise {
+ let path = '/health/queue/webhooks';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Local Storage
+ *
+ * Check the Appwrite local storage device is up and connection is successful.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getStorageLocal(): Promise {
+ let path = '/health/storage/local';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Time
+ *
+ * Check the Appwrite server time is synced with Google remote NTP server. We
+ * use this technology to smoothly handle leap seconds with no disruptive
+ * events. The [Network Time
+ * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is
+ * used by hundreds of millions of computers and devices to synchronize their
+ * clocks over the Internet. If your computer sets its own clock, it likely
+ * uses NTP.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getTime(): Promise {
+ let path = '/health/time';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/locale.ts b/src/services/locale.ts
new file mode 100644
index 0000000..62a2347
--- /dev/null
+++ b/src/services/locale.ts
@@ -0,0 +1,150 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Locale extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * Get User Locale
+ *
+ * Get the current user location based on IP. Returns an object with user
+ * country code, country name, continent name, continent code, ip address and
+ * suggested currency. You can use the locale header to get the data in a
+ * supported language.
+ *
+ * ([IP Geolocation by DB-IP](https://db-ip.com))
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(): Promise {
+ let path = '/locale';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Continents
+ *
+ * List of all continents. You can use the locale header to get the data in a
+ * supported language.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listContinents(): Promise {
+ let path = '/locale/continents';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Countries
+ *
+ * List of all countries. You can use the locale header to get the data in a
+ * supported language.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCountries(): Promise {
+ let path = '/locale/countries';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * 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 {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCountriesEU(): Promise {
+ let path = '/locale/countries/eu';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * 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 {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCountriesPhones(): Promise {
+ let path = '/locale/countries/phones';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Currencies
+ *
+ * List of all currencies, including currency symbol, 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 {AppwriteException}
+ * @returns {Promise}
+ */
+ async listCurrencies(): Promise {
+ let path = '/locale/currencies';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Languages
+ *
+ * List of all languages classified by ISO 639-1 including 2-letter code, name
+ * in English, and name in the respective language.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listLanguages(): Promise {
+ let path = '/locale/languages';
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/projects.ts b/src/services/projects.ts
new file mode 100644
index 0000000..de50c56
--- /dev/null
+++ b/src/services/projects.ts
@@ -0,0 +1,1235 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Projects extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List Projects
+ *
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async list(queries?: string[], search?: string): Promise {
+ let path = '/projects';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Project
+ *
+ *
+ * @param {string} projectId
+ * @param {string} name
+ * @param {string} teamId
+ * @param {string} region
+ * @param {string} description
+ * @param {string} logo
+ * @param {string} url
+ * @param {string} legalName
+ * @param {string} legalCountry
+ * @param {string} legalState
+ * @param {string} legalCity
+ * @param {string} legalAddress
+ * @param {string} legalTaxId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(projectId: string, name: string, teamId: string, region?: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ let path = '/projects';
+ let payload: Payload = {};
+
+ if (typeof projectId !== 'undefined') {
+ payload['projectId'] = projectId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof teamId !== 'undefined') {
+ payload['teamId'] = teamId;
+ }
+
+ if (typeof region !== 'undefined') {
+ payload['region'] = region;
+ }
+
+ if (typeof description !== 'undefined') {
+ payload['description'] = description;
+ }
+
+ if (typeof logo !== 'undefined') {
+ payload['logo'] = logo;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof legalName !== 'undefined') {
+ payload['legalName'] = legalName;
+ }
+
+ if (typeof legalCountry !== 'undefined') {
+ payload['legalCountry'] = legalCountry;
+ }
+
+ if (typeof legalState !== 'undefined') {
+ payload['legalState'] = legalState;
+ }
+
+ if (typeof legalCity !== 'undefined') {
+ payload['legalCity'] = legalCity;
+ }
+
+ if (typeof legalAddress !== 'undefined') {
+ payload['legalAddress'] = legalAddress;
+ }
+
+ if (typeof legalTaxId !== 'undefined') {
+ payload['legalTaxId'] = legalTaxId;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Project
+ *
+ *
+ * @param {string} projectId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(projectId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project
+ *
+ *
+ * @param {string} projectId
+ * @param {string} name
+ * @param {string} description
+ * @param {string} logo
+ * @param {string} url
+ * @param {string} legalName
+ * @param {string} legalCountry
+ * @param {string} legalState
+ * @param {string} legalCity
+ * @param {string} legalAddress
+ * @param {string} legalTaxId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async update(projectId: string, name: string, description?: string, logo?: string, url?: string, legalName?: string, legalCountry?: string, legalState?: string, legalCity?: string, legalAddress?: string, legalTaxId?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/projects/{projectId}'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof description !== 'undefined') {
+ payload['description'] = description;
+ }
+
+ if (typeof logo !== 'undefined') {
+ payload['logo'] = logo;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof legalName !== 'undefined') {
+ payload['legalName'] = legalName;
+ }
+
+ if (typeof legalCountry !== 'undefined') {
+ payload['legalCountry'] = legalCountry;
+ }
+
+ if (typeof legalState !== 'undefined') {
+ payload['legalState'] = legalState;
+ }
+
+ if (typeof legalCity !== 'undefined') {
+ payload['legalCity'] = legalCity;
+ }
+
+ if (typeof legalAddress !== 'undefined') {
+ payload['legalAddress'] = legalAddress;
+ }
+
+ if (typeof legalTaxId !== 'undefined') {
+ payload['legalTaxId'] = legalTaxId;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Project
+ *
+ *
+ * @param {string} projectId
+ * @param {string} password
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async delete(projectId: string, password: string): Promise<{}> {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/projects/{projectId}'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project Authentication Duration
+ *
+ *
+ * @param {string} projectId
+ * @param {number} duration
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateAuthDuration(projectId: string, duration: number): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof duration === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "duration"');
+ }
+
+ let path = '/projects/{projectId}/auth/duration'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof duration !== 'undefined') {
+ payload['duration'] = duration;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project users limit
+ *
+ *
+ * @param {string} projectId
+ * @param {number} limit
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateAuthLimit(projectId: string, limit: number): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof limit === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "limit"');
+ }
+
+ let path = '/projects/{projectId}/auth/limit'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof limit !== 'undefined') {
+ payload['limit'] = limit;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project user sessions limit
+ *
+ *
+ * @param {string} projectId
+ * @param {number} limit
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateAuthSessionsLimit(projectId: string, limit: number): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof limit === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "limit"');
+ }
+
+ let path = '/projects/{projectId}/auth/max-sessions'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof limit !== 'undefined') {
+ payload['limit'] = limit;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project.
+ *
+ *
+ * @param {string} projectId
+ * @param {string} method
+ * @param {boolean} status
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateAuthStatus(projectId: string, method: string, status: boolean): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof method === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "method"');
+ }
+
+ if (typeof status === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "status"');
+ }
+
+ let path = '/projects/{projectId}/auth/{method}'.replace('{projectId}', projectId).replace('{method}', method);
+ let payload: Payload = {};
+
+ if (typeof status !== 'undefined') {
+ payload['status'] = status;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Domains
+ *
+ *
+ * @param {string} projectId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listDomains(projectId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}/domains'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Domain
+ *
+ *
+ * @param {string} projectId
+ * @param {string} domain
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createDomain(projectId: string, domain: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof domain === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "domain"');
+ }
+
+ let path = '/projects/{projectId}/domains'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof domain !== 'undefined') {
+ payload['domain'] = domain;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Domain
+ *
+ *
+ * @param {string} projectId
+ * @param {string} domainId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getDomain(projectId: string, domainId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof domainId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "domainId"');
+ }
+
+ let path = '/projects/{projectId}/domains/{domainId}'.replace('{projectId}', projectId).replace('{domainId}', domainId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Domain
+ *
+ *
+ * @param {string} projectId
+ * @param {string} domainId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteDomain(projectId: string, domainId: string): Promise<{}> {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof domainId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "domainId"');
+ }
+
+ let path = '/projects/{projectId}/domains/{domainId}'.replace('{projectId}', projectId).replace('{domainId}', domainId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Domain Verification Status
+ *
+ *
+ * @param {string} projectId
+ * @param {string} domainId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateDomainVerification(projectId: string, domainId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof domainId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "domainId"');
+ }
+
+ let path = '/projects/{projectId}/domains/{domainId}/verification'.replace('{projectId}', projectId).replace('{domainId}', domainId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Keys
+ *
+ *
+ * @param {string} projectId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listKeys(projectId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}/keys'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Key
+ *
+ *
+ * @param {string} projectId
+ * @param {string} name
+ * @param {string[]} scopes
+ * @param {string} expire
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createKey(projectId: string, name: string, scopes: string[], expire?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof scopes === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "scopes"');
+ }
+
+ let path = '/projects/{projectId}/keys'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof scopes !== 'undefined') {
+ payload['scopes'] = scopes;
+ }
+
+ if (typeof expire !== 'undefined') {
+ payload['expire'] = expire;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Key
+ *
+ *
+ * @param {string} projectId
+ * @param {string} keyId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getKey(projectId: string, keyId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof keyId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "keyId"');
+ }
+
+ let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Key
+ *
+ *
+ * @param {string} projectId
+ * @param {string} keyId
+ * @param {string} name
+ * @param {string[]} scopes
+ * @param {string} expire
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateKey(projectId: string, keyId: string, name: string, scopes: string[], expire?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof keyId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "keyId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof scopes === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "scopes"');
+ }
+
+ let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof scopes !== 'undefined') {
+ payload['scopes'] = scopes;
+ }
+
+ if (typeof expire !== 'undefined') {
+ payload['expire'] = expire;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Key
+ *
+ *
+ * @param {string} projectId
+ * @param {string} keyId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteKey(projectId: string, keyId: string): Promise<{}> {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof keyId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "keyId"');
+ }
+
+ let path = '/projects/{projectId}/keys/{keyId}'.replace('{projectId}', projectId).replace('{keyId}', keyId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Project OAuth2
+ *
+ *
+ * @param {string} projectId
+ * @param {string} provider
+ * @param {string} appId
+ * @param {string} secret
+ * @param {boolean} enabled
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateOAuth2(projectId: string, provider: string, appId?: string, secret?: string, enabled?: boolean): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof provider === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "provider"');
+ }
+
+ let path = '/projects/{projectId}/oauth2'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof provider !== 'undefined') {
+ payload['provider'] = provider;
+ }
+
+ if (typeof appId !== 'undefined') {
+ payload['appId'] = appId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Platforms
+ *
+ *
+ * @param {string} projectId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listPlatforms(projectId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}/platforms'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Platform
+ *
+ *
+ * @param {string} projectId
+ * @param {string} type
+ * @param {string} name
+ * @param {string} key
+ * @param {string} store
+ * @param {string} hostname
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPlatform(projectId: string, type: string, name: string, key?: string, store?: string, hostname?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof type === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "type"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/projects/{projectId}/platforms'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof type !== 'undefined') {
+ payload['type'] = type;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof store !== 'undefined') {
+ payload['store'] = store;
+ }
+
+ if (typeof hostname !== 'undefined') {
+ payload['hostname'] = hostname;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Platform
+ *
+ *
+ * @param {string} projectId
+ * @param {string} platformId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getPlatform(projectId: string, platformId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof platformId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "platformId"');
+ }
+
+ let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Platform
+ *
+ *
+ * @param {string} projectId
+ * @param {string} platformId
+ * @param {string} name
+ * @param {string} key
+ * @param {string} store
+ * @param {string} hostname
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePlatform(projectId: string, platformId: string, name: string, key?: string, store?: string, hostname?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof platformId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "platformId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof key !== 'undefined') {
+ payload['key'] = key;
+ }
+
+ if (typeof store !== 'undefined') {
+ payload['store'] = store;
+ }
+
+ if (typeof hostname !== 'undefined') {
+ payload['hostname'] = hostname;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Platform
+ *
+ *
+ * @param {string} projectId
+ * @param {string} platformId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deletePlatform(projectId: string, platformId: string): Promise<{}> {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof platformId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "platformId"');
+ }
+
+ let path = '/projects/{projectId}/platforms/{platformId}'.replace('{projectId}', projectId).replace('{platformId}', platformId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update service status
+ *
+ *
+ * @param {string} projectId
+ * @param {string} service
+ * @param {boolean} status
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateServiceStatus(projectId: string, service: string, status: boolean): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof service === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "service"');
+ }
+
+ if (typeof status === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "status"');
+ }
+
+ let path = '/projects/{projectId}/service'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof service !== 'undefined') {
+ payload['service'] = service;
+ }
+
+ if (typeof status !== 'undefined') {
+ payload['status'] = status;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for a project
+ *
+ *
+ * @param {string} projectId
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getUsage(projectId: string, range?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}/usage'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Webhooks
+ *
+ *
+ * @param {string} projectId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listWebhooks(projectId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ let path = '/projects/{projectId}/webhooks'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Webhook
+ *
+ *
+ * @param {string} projectId
+ * @param {string} name
+ * @param {string[]} events
+ * @param {string} url
+ * @param {boolean} security
+ * @param {string} httpUser
+ * @param {string} httpPass
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createWebhook(projectId: string, name: string, events: string[], url: string, security: boolean, httpUser?: string, httpPass?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof events === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "events"');
+ }
+
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ if (typeof security === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "security"');
+ }
+
+ let path = '/projects/{projectId}/webhooks'.replace('{projectId}', projectId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof events !== 'undefined') {
+ payload['events'] = events;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof security !== 'undefined') {
+ payload['security'] = security;
+ }
+
+ if (typeof httpUser !== 'undefined') {
+ payload['httpUser'] = httpUser;
+ }
+
+ if (typeof httpPass !== 'undefined') {
+ payload['httpPass'] = httpPass;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Webhook
+ *
+ *
+ * @param {string} projectId
+ * @param {string} webhookId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getWebhook(projectId: string, webhookId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof webhookId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "webhookId"');
+ }
+
+ let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Webhook
+ *
+ *
+ * @param {string} projectId
+ * @param {string} webhookId
+ * @param {string} name
+ * @param {string[]} events
+ * @param {string} url
+ * @param {boolean} security
+ * @param {string} httpUser
+ * @param {string} httpPass
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateWebhook(projectId: string, webhookId: string, name: string, events: string[], url: string, security: boolean, httpUser?: string, httpPass?: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof webhookId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "webhookId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ if (typeof events === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "events"');
+ }
+
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ if (typeof security === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "security"');
+ }
+
+ let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof events !== 'undefined') {
+ payload['events'] = events;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof security !== 'undefined') {
+ payload['security'] = security;
+ }
+
+ if (typeof httpUser !== 'undefined') {
+ payload['httpUser'] = httpUser;
+ }
+
+ if (typeof httpPass !== 'undefined') {
+ payload['httpPass'] = httpPass;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Webhook
+ *
+ *
+ * @param {string} projectId
+ * @param {string} webhookId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteWebhook(projectId: string, webhookId: string): Promise<{}> {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof webhookId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "webhookId"');
+ }
+
+ let path = '/projects/{projectId}/webhooks/{webhookId}'.replace('{projectId}', projectId).replace('{webhookId}', webhookId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Webhook Signature Key
+ *
+ *
+ * @param {string} projectId
+ * @param {string} webhookId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateWebhookSignature(projectId: string, webhookId: string): Promise {
+ if (typeof projectId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "projectId"');
+ }
+
+ if (typeof webhookId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "webhookId"');
+ }
+
+ let path = '/projects/{projectId}/webhooks/{webhookId}/signature'.replace('{projectId}', projectId).replace('{webhookId}', webhookId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/storage.ts b/src/services/storage.ts
new file mode 100644
index 0000000..174ad6c
--- /dev/null
+++ b/src/services/storage.ts
@@ -0,0 +1,691 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Storage extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List buckets
+ *
+ * Get a list of all the storage buckets. You can use the query params to
+ * filter your results.
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listBuckets(queries?: string[], search?: string): Promise {
+ let path = '/storage/buckets';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create bucket
+ *
+ * Create a new storage bucket.
+ *
+ * @param {string} bucketId
+ * @param {string} name
+ * @param {string[]} permissions
+ * @param {boolean} fileSecurity
+ * @param {boolean} enabled
+ * @param {number} maximumFileSize
+ * @param {string[]} allowedFileExtensions
+ * @param {string} compression
+ * @param {boolean} encryption
+ * @param {boolean} antivirus
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/storage/buckets';
+ let payload: Payload = {};
+
+ if (typeof bucketId !== 'undefined') {
+ payload['bucketId'] = bucketId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ if (typeof fileSecurity !== 'undefined') {
+ payload['fileSecurity'] = fileSecurity;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ if (typeof maximumFileSize !== 'undefined') {
+ payload['maximumFileSize'] = maximumFileSize;
+ }
+
+ if (typeof allowedFileExtensions !== 'undefined') {
+ payload['allowedFileExtensions'] = allowedFileExtensions;
+ }
+
+ if (typeof compression !== 'undefined') {
+ payload['compression'] = compression;
+ }
+
+ if (typeof encryption !== 'undefined') {
+ payload['encryption'] = encryption;
+ }
+
+ if (typeof antivirus !== 'undefined') {
+ payload['antivirus'] = antivirus;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Bucket
+ *
+ * Get a storage bucket by its unique ID. This endpoint response returns a
+ * JSON object with the storage bucket metadata.
+ *
+ * @param {string} bucketId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getBucket(bucketId: string): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Bucket
+ *
+ * Update a storage bucket by its unique ID.
+ *
+ * @param {string} bucketId
+ * @param {string} name
+ * @param {string[]} permissions
+ * @param {boolean} fileSecurity
+ * @param {boolean} enabled
+ * @param {number} maximumFileSize
+ * @param {string[]} allowedFileExtensions
+ * @param {string} compression
+ * @param {boolean} encryption
+ * @param {boolean} antivirus
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ if (typeof fileSecurity !== 'undefined') {
+ payload['fileSecurity'] = fileSecurity;
+ }
+
+ if (typeof enabled !== 'undefined') {
+ payload['enabled'] = enabled;
+ }
+
+ if (typeof maximumFileSize !== 'undefined') {
+ payload['maximumFileSize'] = maximumFileSize;
+ }
+
+ if (typeof allowedFileExtensions !== 'undefined') {
+ payload['allowedFileExtensions'] = allowedFileExtensions;
+ }
+
+ if (typeof compression !== 'undefined') {
+ payload['compression'] = compression;
+ }
+
+ if (typeof encryption !== 'undefined') {
+ payload['encryption'] = encryption;
+ }
+
+ if (typeof antivirus !== 'undefined') {
+ payload['antivirus'] = antivirus;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Bucket
+ *
+ * Delete a storage bucket by its unique ID.
+ *
+ * @param {string} bucketId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteBucket(bucketId: string): Promise<{}> {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Files
+ *
+ * Get a list of all the user files. You can use the query params to filter
+ * your results.
+ *
+ * @param {string} bucketId
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listFiles(bucketId: string, queries?: string[], search?: string): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create File
+ *
+ * Create a new file. Before using this route, you should create a new bucket
+ * resource using either a [server
+ * integration](/docs/server/storage#storageCreateBucket) API or directly from
+ * your Appwrite console.
+ *
+ * Larger files should be uploaded using multiple requests with the
+ * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
+ * header to send a partial request with a maximum supported chunk of `5MB`.
+ * The `content-range` header values should always be in bytes.
+ *
+ * When the first request is sent, the server will return the **File** object,
+ * and the subsequent part request must include the file's **id** in
+ * `x-appwrite-id` header to allow the server to know that the partial upload
+ * is for the existing file and not for a new one.
+ *
+ * If you're creating a new file using one of the Appwrite SDKs, all the
+ * chunking logic will be managed by the SDK internally.
+ *
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @param {File} file
+ * @param {string[]} permissions
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ if (typeof file === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "file"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ if (typeof fileId !== 'undefined') {
+ payload['fileId'] = fileId;
+ }
+
+ if (typeof file !== 'undefined') {
+ payload['file'] = file;
+ }
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+
+ if(!(file instanceof File)) {
+ throw new AppwriteException('Parameter "file" has to be a File.');
+ }
+
+ const size = file.size;
+
+ if (size <= Service.CHUNK_SIZE) {
+ return await this.client.call('post', uri, {
+
+ 'content-type': 'multipart/form-data',
+ }, payload);
+ }
+ let id = undefined;
+ let response = undefined;
+
+ const headers: { [header: string]: string } = {
+ 'content-type': 'multipart/form-data',
+ }
+
+ let counter = 0;
+ const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
+ if(fileId != 'unique()') {
+ try {
+ response = await this.client.call('GET', new URL(this.client.config.endpoint + path + '/' + fileId), headers);
+ counter = response.chunksUploaded;
+ } catch(e) {
+ }
+ }
+
+ for (counter; counter < totalCounters; counter++) {
+ const start = (counter * Service.CHUNK_SIZE);
+ const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
+
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
+
+ if (id) {
+ headers['x-appwrite-id'] = id;
+ }
+
+ const stream = file.slice(start, end + 1);
+ payload['file'] = new File([stream], file.name);
+
+ response = await this.client.call('post', uri, headers, payload);
+
+ if (!id) {
+ id = response['$id'];
+ }
+
+ if (onProgress) {
+ onProgress({
+ $id: response.$id,
+ progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
+ sizeUploaded: end,
+ chunksTotal: response.chunksTotal,
+ chunksUploaded: response.chunksUploaded
+ });
+ }
+ }
+
+ return response;
+ }
+
+ /**
+ * Get File
+ *
+ * Get a file by its unique ID. This endpoint response returns a JSON object
+ * with the file metadata.
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getFile(bucketId: string, fileId: string): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update File
+ *
+ * Update a file by its unique ID. Only users with write permissions have
+ * access to update this resource.
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @param {string[]} permissions
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateFile(bucketId: string, fileId: string, permissions?: string[]): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ if (typeof permissions !== 'undefined') {
+ payload['permissions'] = permissions;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete File
+ *
+ * Delete a file by its unique ID. Only users with write permissions have
+ * access to delete this resource.
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteFile(bucketId: string, fileId: string): Promise<{}> {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get File for Download
+ *
+ * Get a 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} bucketId
+ * @param {string} fileId
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getFileDownload(bucketId: string, fileId: string): URL {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * 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. Preview is
+ * supported only for image files smaller than 10MB.
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @param {number} width
+ * @param {number} height
+ * @param {string} gravity
+ * @param {number} quality
+ * @param {number} borderWidth
+ * @param {string} borderColor
+ * @param {number} borderRadius
+ * @param {number} opacity
+ * @param {number} rotation
+ * @param {string} background
+ * @param {string} output
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ if (typeof width !== 'undefined') {
+ payload['width'] = width;
+ }
+
+ if (typeof height !== 'undefined') {
+ payload['height'] = height;
+ }
+
+ if (typeof gravity !== 'undefined') {
+ payload['gravity'] = gravity;
+ }
+
+ if (typeof quality !== 'undefined') {
+ payload['quality'] = quality;
+ }
+
+ if (typeof borderWidth !== 'undefined') {
+ payload['borderWidth'] = borderWidth;
+ }
+
+ if (typeof borderColor !== 'undefined') {
+ payload['borderColor'] = borderColor;
+ }
+
+ if (typeof borderRadius !== 'undefined') {
+ payload['borderRadius'] = borderRadius;
+ }
+
+ if (typeof opacity !== 'undefined') {
+ payload['opacity'] = opacity;
+ }
+
+ if (typeof rotation !== 'undefined') {
+ payload['rotation'] = rotation;
+ }
+
+ if (typeof background !== 'undefined') {
+ payload['background'] = background;
+ }
+
+ if (typeof output !== 'undefined') {
+ payload['output'] = output;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * Get File for View
+ *
+ * Get a file content by its unique ID. This endpoint is similar to the
+ * download method but returns with no 'Content-Disposition: attachment'
+ * header.
+ *
+ * @param {string} bucketId
+ * @param {string} fileId
+ * @throws {AppwriteException}
+ * @returns {URL}
+ */
+ getFileView(bucketId: string, fileId: string): URL {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ if (typeof fileId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "fileId"');
+ }
+
+ let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ payload['project'] = this.client.config.project;
+
+
+ for (const [key, value] of Object.entries(Service.flatten(payload))) {
+ uri.searchParams.append(key, value);
+ }
+ return uri;
+ }
+
+ /**
+ * Get usage stats for storage
+ *
+ *
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getUsage(range?: string): Promise {
+ let path = '/storage/usage';
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for a storage bucket
+ *
+ *
+ * @param {string} bucketId
+ * @param {string} range
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getBucketUsage(bucketId: string, range?: string): Promise {
+ if (typeof bucketId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "bucketId"');
+ }
+
+ let path = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/teams.ts b/src/services/teams.ts
new file mode 100644
index 0000000..5238f8c
--- /dev/null
+++ b/src/services/teams.ts
@@ -0,0 +1,445 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Teams extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List Teams
+ *
+ * Get a list of all the teams in which the current user is a member. You can
+ * use the parameters to filter your results.
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async list(queries?: string[], search?: string): Promise {
+ let path = '/teams';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Team
+ *
+ * Create a new team. The user who creates the team will automatically be
+ * assigned as the owner of the team. Only the users with the owner role can
+ * invite new members, add new owners and delete or update the team.
+ *
+ * @param {string} teamId
+ * @param {string} name
+ * @param {string[]} roles
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(teamId: string, name: string, roles?: string[]): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/teams';
+ let payload: Payload = {};
+
+ if (typeof teamId !== 'undefined') {
+ payload['teamId'] = teamId;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ if (typeof roles !== 'undefined') {
+ payload['roles'] = roles;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Team
+ *
+ * Get a team by its ID. All team members have read access for this resource.
+ *
+ * @param {string} teamId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(teamId: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ let path = '/teams/{teamId}'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Team
+ *
+ * Update a team using its ID. Only members with the owner role can update the
+ * team.
+ *
+ * @param {string} teamId
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async update(teamId: string, name: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/teams/{teamId}'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Team
+ *
+ * Delete a team using its ID. Only team members with the owner role can
+ * delete the team.
+ *
+ * @param {string} teamId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async delete(teamId: string): Promise<{}> {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ let path = '/teams/{teamId}'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Team Logs
+ *
+ * Get the team activity logs list by its unique ID.
+ *
+ * @param {string} teamId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listLogs(teamId: string, queries?: string[]): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ let path = '/teams/{teamId}/logs'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Team Memberships
+ *
+ * Use this endpoint to list a team's members using the team's ID. All team
+ * members have read access to this endpoint.
+ *
+ * @param {string} teamId
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listMemberships(teamId: string, queries?: string[], search?: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create Team Membership
+ *
+ * Invite a new member to join your team. If initiated from the client SDK, an
+ * email with a link to join the team will be sent to the member's email
+ * address and an account will be created for them should they not be signed
+ * up already. If initiated from server-side SDKs, the new member will
+ * automatically be added to the team.
+ *
+ * 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/client/teams#teamsUpdateMembershipStatus) endpoint to allow
+ * the user to accept the invitation to the team.
+ *
+ * Please note that to avoid a [Redirect
+ * Attack](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
+ * adding your platforms in the console interface.
+ *
+ * @param {string} teamId
+ * @param {string} email
+ * @param {string[]} roles
+ * @param {string} url
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMembership(teamId: string, email: string, roles: string[], url: string, name?: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof roles === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "roles"');
+ }
+
+ if (typeof url === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "url"');
+ }
+
+ let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
+ let payload: Payload = {};
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof roles !== 'undefined') {
+ payload['roles'] = roles;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get Team Membership
+ *
+ * Get a team member by the membership unique id. All team members have read
+ * access for this resource.
+ *
+ * @param {string} teamId
+ * @param {string} membershipId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getMembership(teamId: string, membershipId: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof membershipId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "membershipId"');
+ }
+
+ let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Membership Roles
+ *
+ * Modify the roles of a team member. Only team members with the owner role
+ * have access to this endpoint. Learn more about [roles and
+ * permissions](/docs/permissions).
+ *
+ * @param {string} teamId
+ * @param {string} membershipId
+ * @param {string[]} roles
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMembershipRoles(teamId: string, membershipId: string, roles: string[]): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof membershipId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "membershipId"');
+ }
+
+ if (typeof roles === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "roles"');
+ }
+
+ let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
+ let payload: Payload = {};
+
+ if (typeof roles !== 'undefined') {
+ payload['roles'] = roles;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * 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 it is not accepted.
+ *
+ * @param {string} teamId
+ * @param {string} membershipId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteMembership(teamId: string, membershipId: string): Promise<{}> {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof membershipId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "membershipId"');
+ }
+
+ let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Team Membership Status
+ *
+ * Use this endpoint to allow a user to accept an invitation to join a team
+ * after being redirected back to your app from the invitation email received
+ * by the user.
+ *
+ * If the request is successful, a session for the user is automatically
+ * created.
+ *
+ *
+ * @param {string} teamId
+ * @param {string} membershipId
+ * @param {string} userId
+ * @param {string} secret
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise {
+ if (typeof teamId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "teamId"');
+ }
+
+ if (typeof membershipId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "membershipId"');
+ }
+
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
+ }
+
+ let path = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/users.ts b/src/services/users.ts
new file mode 100644
index 0000000..756073c
--- /dev/null
+++ b/src/services/users.ts
@@ -0,0 +1,1020 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Users extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * List Users
+ *
+ * Get a list of all the project's users. You can use the query params to
+ * filter your results.
+ *
+ * @param {string[]} queries
+ * @param {string} search
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async list(queries?: string[], search?: string): Promise> {
+ let path = '/users';
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ if (typeof search !== 'undefined') {
+ payload['search'] = search;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User
+ *
+ * Create a new user.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} phone
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async create(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof phone !== 'undefined') {
+ payload['phone'] = phone;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with Argon2 Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
+ * /users](/docs/server/users#usersCreate) endpoint to create users with a
+ * plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createArgon2User(userId: string, email: string, password: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/argon2';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with Bcrypt Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
+ * /users](/docs/server/users#usersCreate) endpoint to create users with a
+ * plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createBcryptUser(userId: string, email: string, password: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/bcrypt';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with MD5 Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
+ * /users](/docs/server/users#usersCreate) endpoint to create users with a
+ * plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMD5User(userId: string, email: string, password: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/md5';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with PHPass Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
+ * /users](/docs/server/users#usersCreate) endpoint to create users with a
+ * plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPHPassUser(userId: string, email: string, password: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/phpass';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with Scrypt Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
+ * /users](/docs/server/users#usersCreate) endpoint to create users with a
+ * plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} passwordSalt
+ * @param {number} passwordCpu
+ * @param {number} passwordMemory
+ * @param {number} passwordParallel
+ * @param {number} passwordLength
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createScryptUser(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ if (typeof passwordSalt === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
+ }
+
+ if (typeof passwordCpu === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordCpu"');
+ }
+
+ if (typeof passwordMemory === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordMemory"');
+ }
+
+ if (typeof passwordParallel === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordParallel"');
+ }
+
+ if (typeof passwordLength === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordLength"');
+ }
+
+ let path = '/users/scrypt';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof passwordSalt !== 'undefined') {
+ payload['passwordSalt'] = passwordSalt;
+ }
+
+ if (typeof passwordCpu !== 'undefined') {
+ payload['passwordCpu'] = passwordCpu;
+ }
+
+ if (typeof passwordMemory !== 'undefined') {
+ payload['passwordMemory'] = passwordMemory;
+ }
+
+ if (typeof passwordParallel !== 'undefined') {
+ payload['passwordParallel'] = passwordParallel;
+ }
+
+ if (typeof passwordLength !== 'undefined') {
+ payload['passwordLength'] = passwordLength;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with Scrypt Modified Password
+ *
+ * Create a new user. Password provided must be hashed with the [Scrypt
+ * Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
+ * algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint
+ * to create users with a plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} passwordSalt
+ * @param {string} passwordSaltSeparator
+ * @param {string} passwordSignerKey
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createScryptModifiedUser(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ if (typeof passwordSalt === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
+ }
+
+ if (typeof passwordSaltSeparator === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"');
+ }
+
+ if (typeof passwordSignerKey === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "passwordSignerKey"');
+ }
+
+ let path = '/users/scrypt-modified';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof passwordSalt !== 'undefined') {
+ payload['passwordSalt'] = passwordSalt;
+ }
+
+ if (typeof passwordSaltSeparator !== 'undefined') {
+ payload['passwordSaltSeparator'] = passwordSaltSeparator;
+ }
+
+ if (typeof passwordSignerKey !== 'undefined') {
+ payload['passwordSignerKey'] = passwordSignerKey;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create User with SHA Password
+ *
+ * Create a new user. Password provided must be hashed with the
+ * [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
+ * the [POST /users](/docs/server/users#usersCreate) endpoint to create users
+ * with a plain text password.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} password
+ * @param {string} passwordVersion
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createSHAUser(userId: string, email: string, password: string, passwordVersion?: string, name?: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/sha';
+ let payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ if (typeof passwordVersion !== 'undefined') {
+ payload['passwordVersion'] = passwordVersion;
+ }
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get usage stats for the users API
+ *
+ *
+ * @param {string} range
+ * @param {string} provider
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getUsage(range?: string, provider?: string): Promise {
+ let path = '/users/usage';
+ let payload: Payload = {};
+
+ if (typeof range !== 'undefined') {
+ payload['range'] = range;
+ }
+
+ if (typeof provider !== 'undefined') {
+ payload['provider'] = provider;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get User
+ *
+ * Get a user by its unique ID.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async get(userId: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete User
+ *
+ * Delete a user by its unique ID, thereby releasing it's ID. Since ID is
+ * released and can be reused, all user-related resources like documents or
+ * storage files should be deleted before user deletion. If you want to keep
+ * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
+ * endpoint instead.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async delete(userId: string): Promise<{}> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Email
+ *
+ * Update the user email by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateEmail(userId: string, email: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ let path = '/users/{userId}/email'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List User Logs
+ *
+ * Get the user activity logs list by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string[]} queries
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listLogs(userId: string, queries?: string[]): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}/logs'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List User Memberships
+ *
+ * Get the user membership list by its unique ID.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listMemberships(userId: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}/memberships'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Name
+ *
+ * Update the user name by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string} name
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateName(userId: string, name: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof name === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "name"');
+ }
+
+ let path = '/users/{userId}/name'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof name !== 'undefined') {
+ payload['name'] = name;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Password
+ *
+ * Update the user password by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string} password
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePassword(userId: string, password: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof password === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "password"');
+ }
+
+ let path = '/users/{userId}/password'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof password !== 'undefined') {
+ payload['password'] = password;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Phone
+ *
+ * Update the user phone by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string} number
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePhone(userId: string, number: string): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof number === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "number"');
+ }
+
+ let path = '/users/{userId}/phone'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof number !== 'undefined') {
+ payload['number'] = number;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get User Preferences
+ *
+ * Get the user preferences by its unique ID.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getPrefs(userId: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}/prefs'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update User Preferences
+ *
+ * Update the user preferences by its unique ID. The object you pass is stored
+ * as is, and replaces any previous value. The maximum allowed prefs size is
+ * 64kB and throws error if exceeded.
+ *
+ * @param {string} userId
+ * @param {object} prefs
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePrefs(userId: string, prefs: object): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof prefs === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "prefs"');
+ }
+
+ let path = '/users/{userId}/prefs'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof prefs !== 'undefined') {
+ payload['prefs'] = prefs;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List User Sessions
+ *
+ * Get the user sessions list by its unique ID.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listSessions(userId: string): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}/sessions'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete User Sessions
+ *
+ * Delete all user's sessions by using the user's unique ID.
+ *
+ * @param {string} userId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteSessions(userId: string): Promise<{}> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ let path = '/users/{userId}/sessions'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete User Session
+ *
+ * Delete a user sessions by its unique ID.
+ *
+ * @param {string} userId
+ * @param {string} sessionId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteSession(userId: string, sessionId: string): Promise<{}> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof sessionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "sessionId"');
+ }
+
+ let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
+ let payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update User Status
+ *
+ * Update the user status by its unique ID. Use this endpoint as an
+ * alternative to deleting a user if you want to keep user's ID reserved.
+ *
+ * @param {string} userId
+ * @param {boolean} status
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateStatus(userId: string, status: boolean): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof status === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "status"');
+ }
+
+ let path = '/users/{userId}/status'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof status !== 'undefined') {
+ payload['status'] = status;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Email Verification
+ *
+ * Update the user email verification status by its unique ID.
+ *
+ * @param {string} userId
+ * @param {boolean} emailVerification
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateEmailVerification(userId: string, emailVerification: boolean): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof emailVerification === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "emailVerification"');
+ }
+
+ let path = '/users/{userId}/verification'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof emailVerification !== 'undefined') {
+ payload['emailVerification'] = emailVerification;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update Phone Verification
+ *
+ * Update the user phone verification status by its unique ID.
+ *
+ * @param {string} userId
+ * @param {boolean} phoneVerification
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePhoneVerification(userId: string, phoneVerification: boolean): Promise> {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof phoneVerification === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "phoneVerification"');
+ }
+
+ let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
+ let payload: Payload = {};
+
+ if (typeof phoneVerification !== 'undefined') {
+ payload['phoneVerification'] = phoneVerification;
+ }
+
+ const uri = new URL(this.client.config.endpoint + path);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..8a27d1f
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "allowJs": true,
+ "allowSyntheticDefaultImports": true,
+ "baseUrl": "src",
+ "declaration": false,
+ "esModuleInterop": true,
+ "inlineSourceMap": false,
+ "lib": ["ESNext", "DOM"],
+ "listEmittedFiles": false,
+ "listFiles": false,
+ "moduleResolution": "node",
+ "noFallthroughCasesInSwitch": true,
+ "pretty": true,
+ "rootDir": "src",
+ "skipLibCheck": true,
+ "strict": true,
+ "target": "ES6",
+ "traceResolution": false,
+ },
+ "compileOnSave": false,
+ "exclude": ["node_modules", "dist"],
+ "include": ["src"]
+}
\ No newline at end of file