diff --git a/.travis.yml b/.travis.yml
index 0c3793f..aae2399 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ node_js:
jobs:
include:
- stage: NPM RC Release
- if: tag =~ /-(rc|RC)/
+ if: tag == *-rc*
node_js: "14.16"
script:
- npm install
@@ -17,7 +17,7 @@ jobs:
api_key: $NPM_API_KEY
tag: next
- stage: NPM Release
- if: not tag =~ /-(rc|RC)/
+ if: tag != *-rc*
node_js: "14.16"
script:
- npm install
@@ -29,4 +29,4 @@ jobs:
api_key: $NPM_API_KEY
skip_cleanup: true
on:
- tags: true
+ tags: true
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 47cfdfb..5479bb8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors.
+Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
diff --git a/README.md b/README.md
index a4e4814..3877566 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,16 @@
# Appwrite Web SDK
![License](https://img.shields.io/github/license/appwrite/sdk-for-web.svg?style=flat-square)
-![Version](https://img.shields.io/badge/api%20version-1.4.12-blue.svg?style=flat-square)
+![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
-**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-web/releases).**
+**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-web/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 Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
-![Appwrite](https://appwrite.io/images/github.png)
+![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png)
## Installation
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
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
-
+
```
@@ -64,7 +64,7 @@ Once your SDK object is set, access any of the Appwrite services and choose any
const account = new Account(client);
// Register User
-account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe')
+account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien")
.then(function (response) {
console.log(response);
}, function (error) {
@@ -86,7 +86,7 @@ client
const account = new Account(client);
// Register User
-account.create(ID.unique(), 'me@example.com', 'password', 'Jane Doe')
+account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien")
.then(function (response) {
console.log(response);
}, function (error) {
diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md
index c331fc8..618b003 100644
--- a/docs/examples/account/create-anonymous-session.md
+++ b/docs/examples/account/create-anonymous-session.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.createAnonymousSession();
+const result = await account.createAnonymousSession();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md
new file mode 100644
index 0000000..7bbb30e
--- /dev/null
+++ b/docs/examples/account/create-email-password-session.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createEmailPasswordSession(
+ 'email@example.com', // email
+ 'password' // password
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-email-session.md b/docs/examples/account/create-email-session.md
deleted file mode 100644
index 76e2e31..0000000
--- a/docs/examples/account/create-email-session.md
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Client, Account } from "appwrite";
-
-const client = new Client();
-
-const account = new Account(client);
-
-client
- .setEndpoint('https://cloud.appwrite.io/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-email-token.md b/docs/examples/account/create-email-token.md
new file mode 100644
index 0000000..3591fcd
--- /dev/null
+++ b/docs/examples/account/create-email-token.md
@@ -0,0 +1,15 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createEmailToken(
+ '', // userId
+ 'email@example.com', // email
+ false // phrase (optional)
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md
index f388a3d..467d7ab 100644
--- a/docs/examples/account/create-j-w-t.md
+++ b/docs/examples/account/create-j-w-t.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.createJWT();
+const result = await account.createJWT();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/create-magic-u-r-l-session.md b/docs/examples/account/create-magic-u-r-l-session.md
deleted file mode 100644
index d48f031..0000000
--- a/docs/examples/account/create-magic-u-r-l-session.md
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Client, Account } from "appwrite";
-
-const client = new Client();
-
-const account = new Account(client);
-
-client
- .setEndpoint('https://cloud.appwrite.io/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-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md
new file mode 100644
index 0000000..c65b5e5
--- /dev/null
+++ b/docs/examples/account/create-magic-u-r-l-token.md
@@ -0,0 +1,16 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createMagicURLToken(
+ '', // userId
+ 'email@example.com', // email
+ 'https://example.com', // url (optional)
+ false // phrase (optional)
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md
new file mode 100644
index 0000000..e367f24
--- /dev/null
+++ b/docs/examples/account/create-mfa-authenticator.md
@@ -0,0 +1,13 @@
+import { Client, Account, AuthenticatorType } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createMfaAuthenticator(
+ AuthenticatorType.Totp // type
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md
new file mode 100644
index 0000000..48318c7
--- /dev/null
+++ b/docs/examples/account/create-mfa-challenge.md
@@ -0,0 +1,13 @@
+import { Client, Account, AuthenticationFactor } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createMfaChallenge(
+ AuthenticationFactor.Email // factor
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md
new file mode 100644
index 0000000..ef5d35d
--- /dev/null
+++ b/docs/examples/account/create-mfa-recovery-codes.md
@@ -0,0 +1,11 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createMfaRecoveryCodes();
+
+console.log(response);
diff --git a/docs/examples/account/create-o-auth2session.md b/docs/examples/account/create-o-auth2session.md
index 3757a1c..c158e3e 100644
--- a/docs/examples/account/create-o-auth2session.md
+++ b/docs/examples/account/create-o-auth2session.md
@@ -1,14 +1,15 @@
-import { Client, Account } from "appwrite";
+import { Client, Account, OAuthProvider } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-// Go to OAuth provider login page
-account.createOAuth2Session('amazon');
+account.createOAuth2Session(
+ OAuthProvider.Amazon, // provider
+ 'https://example.com', // success (optional)
+ 'https://example.com', // failure (optional)
+ [] // scopes (optional)
+);
diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md
new file mode 100644
index 0000000..a4ca049
--- /dev/null
+++ b/docs/examples/account/create-o-auth2token.md
@@ -0,0 +1,15 @@
+import { Client, Account, OAuthProvider } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+account.createOAuth2Token(
+ OAuthProvider.Amazon, // provider
+ 'https://example.com', // success (optional)
+ 'https://example.com', // failure (optional)
+ [] // scopes (optional)
+);
+
diff --git a/docs/examples/account/create-phone-session.md b/docs/examples/account/create-phone-session.md
deleted file mode 100644
index e5a23aa..0000000
--- a/docs/examples/account/create-phone-session.md
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Client, Account } from "appwrite";
-
-const client = new Client();
-
-const account = new Account(client);
-
-client
- .setEndpoint('https://cloud.appwrite.io/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-token.md b/docs/examples/account/create-phone-token.md
new file mode 100644
index 0000000..d67892a
--- /dev/null
+++ b/docs/examples/account/create-phone-token.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createPhoneToken(
+ '', // userId
+ '+12065550100' // phone
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md
index a1cbd55..cdb4629 100644
--- a/docs/examples/account/create-phone-verification.md
+++ b/docs/examples/account/create-phone-verification.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.createPhoneVerification();
+const result = await account.createPhoneVerification();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/create-push-target.md b/docs/examples/account/create-push-target.md
new file mode 100644
index 0000000..fe6dd99
--- /dev/null
+++ b/docs/examples/account/create-push-target.md
@@ -0,0 +1,15 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createPushTarget(
+ '', // targetId
+ '', // identifier
+ '' // providerId (optional)
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md
index 1838c04..d6014cd 100644
--- a/docs/examples/account/create-recovery.md
+++ b/docs/examples/account/create-recovery.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.createRecovery('email@example.com', 'https://example.com');
+const result = await account.createRecovery(
+ 'email@example.com', // email
+ 'https://example.com' // url
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md
new file mode 100644
index 0000000..a3ee7cc
--- /dev/null
+++ b/docs/examples/account/create-session.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.createSession(
+ '', // userId
+ '' // secret
+);
+
+console.log(response);
diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md
index 4d8446e..1757f3c 100644
--- a/docs/examples/account/create-verification.md
+++ b/docs/examples/account/create-verification.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.createVerification('https://example.com');
+const result = await account.createVerification(
+ 'https://example.com' // url
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md
index fda1d88..069ade2 100644
--- a/docs/examples/account/create.md
+++ b/docs/examples/account/create.md
@@ -1,18 +1,16 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.create('[USER_ID]', 'email@example.com', '');
+const result = await account.create(
+ '', // userId
+ 'email@example.com', // email
+ '', // password
+ '' // name (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md
index b4230ce..07558e0 100644
--- a/docs/examples/account/delete-identity.md
+++ b/docs/examples/account/delete-identity.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.deleteIdentity('[IDENTITY_ID]');
+const result = await account.deleteIdentity(
+ '' // identityId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md
new file mode 100644
index 0000000..6d38924
--- /dev/null
+++ b/docs/examples/account/delete-mfa-authenticator.md
@@ -0,0 +1,14 @@
+import { Client, Account, AuthenticatorType } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.deleteMfaAuthenticator(
+ AuthenticatorType.Totp, // type
+ '' // otp
+);
+
+console.log(response);
diff --git a/docs/examples/account/delete-push-target.md b/docs/examples/account/delete-push-target.md
new file mode 100644
index 0000000..a5e7cb3
--- /dev/null
+++ b/docs/examples/account/delete-push-target.md
@@ -0,0 +1,13 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.deletePushTarget(
+ '' // targetId
+);
+
+console.log(response);
diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md
index c342afb..4d5129f 100644
--- a/docs/examples/account/delete-session.md
+++ b/docs/examples/account/delete-session.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.deleteSession('[SESSION_ID]');
+const result = await account.deleteSession(
+ '' // sessionId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md
index 82133e3..a15d130 100644
--- a/docs/examples/account/delete-sessions.md
+++ b/docs/examples/account/delete-sessions.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.deleteSessions();
+const result = await account.deleteSessions();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md
new file mode 100644
index 0000000..fe3b7a3
--- /dev/null
+++ b/docs/examples/account/get-mfa-recovery-codes.md
@@ -0,0 +1,11 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.getMfaRecoveryCodes();
+
+console.log(response);
diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md
index b98776f..a658911 100644
--- a/docs/examples/account/get-prefs.md
+++ b/docs/examples/account/get-prefs.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.getPrefs();
+const result = await account.getPrefs();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md
index 43edd7d..b11278b 100644
--- a/docs/examples/account/get-session.md
+++ b/docs/examples/account/get-session.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.getSession('[SESSION_ID]');
+const result = await account.getSession(
+ '' // sessionId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md
index 878227f..7c000bb 100644
--- a/docs/examples/account/get.md
+++ b/docs/examples/account/get.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.get();
+const result = await account.get();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md
index 91e01e2..4c627ce 100644
--- a/docs/examples/account/list-identities.md
+++ b/docs/examples/account/list-identities.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.listIdentities();
+const result = await account.listIdentities(
+ [] // queries (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md
index d710f7d..973e37b 100644
--- a/docs/examples/account/list-logs.md
+++ b/docs/examples/account/list-logs.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.listLogs();
+const result = await account.listLogs(
+ [] // queries (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md
new file mode 100644
index 0000000..2e7a6f1
--- /dev/null
+++ b/docs/examples/account/list-mfa-factors.md
@@ -0,0 +1,11 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.listMfaFactors();
+
+console.log(response);
diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md
index ce6ec74..0220b3a 100644
--- a/docs/examples/account/list-sessions.md
+++ b/docs/examples/account/list-sessions.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.listSessions();
+const result = await account.listSessions();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md
index baac3a0..06fabe0 100644
--- a/docs/examples/account/update-email.md
+++ b/docs/examples/account/update-email.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateEmail('email@example.com', 'password');
+const result = await account.updateEmail(
+ 'email@example.com', // email
+ 'password' // password
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md
new file mode 100644
index 0000000..4e6bb65
--- /dev/null
+++ b/docs/examples/account/update-m-f-a.md
@@ -0,0 +1,13 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.updateMFA(
+ false // mfa
+);
+
+console.log(response);
diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md
index c07fee2..665b9f2 100644
--- a/docs/examples/account/update-magic-u-r-l-session.md
+++ b/docs/examples/account/update-magic-u-r-l-session.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateMagicURLSession('[USER_ID]', '[SECRET]');
+const result = await account.updateMagicURLSession(
+ '', // userId
+ '' // secret
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md
new file mode 100644
index 0000000..50bd121
--- /dev/null
+++ b/docs/examples/account/update-mfa-authenticator.md
@@ -0,0 +1,14 @@
+import { Client, Account, AuthenticatorType } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.updateMfaAuthenticator(
+ AuthenticatorType.Totp, // type
+ '' // otp
+);
+
+console.log(response);
diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md
new file mode 100644
index 0000000..ca9a85d
--- /dev/null
+++ b/docs/examples/account/update-mfa-challenge.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.updateMfaChallenge(
+ '', // challengeId
+ '' // otp
+);
+
+console.log(response);
diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md
new file mode 100644
index 0000000..529fbae
--- /dev/null
+++ b/docs/examples/account/update-mfa-recovery-codes.md
@@ -0,0 +1,11 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.updateMfaRecoveryCodes();
+
+console.log(response);
diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md
index 4af963d..ac11894 100644
--- a/docs/examples/account/update-name.md
+++ b/docs/examples/account/update-name.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateName('[NAME]');
+const result = await account.updateName(
+ '' // name
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md
index 2404a74..f7c815b 100644
--- a/docs/examples/account/update-password.md
+++ b/docs/examples/account/update-password.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updatePassword('');
+const result = await account.updatePassword(
+ '', // password
+ 'password' // oldPassword (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md
index b3b2948..1d64eb5 100644
--- a/docs/examples/account/update-phone-session.md
+++ b/docs/examples/account/update-phone-session.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updatePhoneSession('[USER_ID]', '[SECRET]');
+const result = await account.updatePhoneSession(
+ '', // userId
+ '' // secret
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md
index a274c9b..5325169 100644
--- a/docs/examples/account/update-phone-verification.md
+++ b/docs/examples/account/update-phone-verification.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updatePhoneVerification('[USER_ID]', '[SECRET]');
+const result = await account.updatePhoneVerification(
+ '', // userId
+ '' // secret
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md
index a1017fc..87779d4 100644
--- a/docs/examples/account/update-phone.md
+++ b/docs/examples/account/update-phone.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updatePhone('+12065550100', 'password');
+const result = await account.updatePhone(
+ '+12065550100', // phone
+ 'password' // password
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md
index ecceff3..d97cd05 100644
--- a/docs/examples/account/update-prefs.md
+++ b/docs/examples/account/update-prefs.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updatePrefs({});
+const result = await account.updatePrefs(
+ {} // prefs
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-push-target.md b/docs/examples/account/update-push-target.md
new file mode 100644
index 0000000..a8ac97c
--- /dev/null
+++ b/docs/examples/account/update-push-target.md
@@ -0,0 +1,14 @@
+import { Client, Account } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const account = new Account(client);
+
+const result = await account.updatePushTarget(
+ '', // targetId
+ '' // identifier
+);
+
+console.log(response);
diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md
index eb78a8a..90bfb6d 100644
--- a/docs/examples/account/update-recovery.md
+++ b/docs/examples/account/update-recovery.md
@@ -1,18 +1,15 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateRecovery('[USER_ID]', '[SECRET]', 'password', 'password');
+const result = await account.updateRecovery(
+ '', // userId
+ '', // secret
+ '' // password
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md
index a7a42c6..5f30f17 100644
--- a/docs/examples/account/update-session.md
+++ b/docs/examples/account/update-session.md
@@ -1,18 +1,13 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateSession('[SESSION_ID]');
+const result = await account.updateSession(
+ '' // sessionId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md
index 9cbe78c..e67bc78 100644
--- a/docs/examples/account/update-status.md
+++ b/docs/examples/account/update-status.md
@@ -1,18 +1,11 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateStatus();
+const result = await account.updateStatus();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md
index 73338da..a57fe4b 100644
--- a/docs/examples/account/update-verification.md
+++ b/docs/examples/account/update-verification.md
@@ -1,18 +1,14 @@
import { Client, Account } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const account = new Account(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = account.updateVerification('[USER_ID]', '[SECRET]');
+const result = await account.updateVerification(
+ '', // userId
+ '' // secret
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md
index 0b4c2de..682ba98 100644
--- a/docs/examples/avatars/get-browser.md
+++ b/docs/examples/avatars/get-browser.md
@@ -1,14 +1,16 @@
-import { Client, Avatars } from "appwrite";
+import { Client, Avatars, Browser } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getBrowser('aa');
+const result = avatars.getBrowser(
+ Browser.AvantBrowser, // code
+ 0, // width (optional)
+ 0, // height (optional)
+ 0 // quality (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md
index 082ed92..68b5337 100644
--- a/docs/examples/avatars/get-credit-card.md
+++ b/docs/examples/avatars/get-credit-card.md
@@ -1,14 +1,16 @@
-import { Client, Avatars } from "appwrite";
+import { Client, Avatars, CreditCard } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getCreditCard('amex');
+const result = avatars.getCreditCard(
+ CreditCard.AmericanExpress, // code
+ 0, // width (optional)
+ 0, // height (optional)
+ 0 // quality (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md
index 7ee6bd3..5d5e93b 100644
--- a/docs/examples/avatars/get-favicon.md
+++ b/docs/examples/avatars/get-favicon.md
@@ -1,14 +1,13 @@
import { Client, Avatars } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getFavicon('https://example.com');
+const result = avatars.getFavicon(
+ 'https://example.com' // url
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md
index a43827a..e8521c9 100644
--- a/docs/examples/avatars/get-flag.md
+++ b/docs/examples/avatars/get-flag.md
@@ -1,14 +1,16 @@
-import { Client, Avatars } from "appwrite";
+import { Client, Avatars, Flag } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getFlag('af');
+const result = avatars.getFlag(
+ Flag.Afghanistan, // code
+ 0, // width (optional)
+ 0, // height (optional)
+ 0 // quality (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md
index ea186a1..8b8fbd9 100644
--- a/docs/examples/avatars/get-image.md
+++ b/docs/examples/avatars/get-image.md
@@ -1,14 +1,15 @@
import { Client, Avatars } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getImage('https://example.com');
+const result = avatars.getImage(
+ 'https://example.com', // url
+ 0, // width (optional)
+ 0 // height (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md
index 7e8c8ec..cc456a4 100644
--- a/docs/examples/avatars/get-initials.md
+++ b/docs/examples/avatars/get-initials.md
@@ -1,14 +1,16 @@
import { Client, Avatars } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getInitials();
+const result = avatars.getInitials(
+ '', // name (optional)
+ 0, // width (optional)
+ 0, // height (optional)
+ '' // background (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md
index b957084..5254a56 100644
--- a/docs/examples/avatars/get-q-r.md
+++ b/docs/examples/avatars/get-q-r.md
@@ -1,14 +1,16 @@
import { Client, Avatars } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const avatars = new Avatars(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = avatars.getQR('[TEXT]');
+const result = avatars.getQR(
+ '', // text
+ 1, // size (optional)
+ 0, // margin (optional)
+ false // download (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md
index 9279206..3a4d53d 100644
--- a/docs/examples/databases/create-document.md
+++ b/docs/examples/databases/create-document.md
@@ -1,18 +1,17 @@
import { Client, Databases } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const databases = new Databases(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = databases.createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', {});
+const result = await databases.createDocument(
+ '', // databaseId
+ '', // collectionId
+ '', // documentId
+ {}, // data
+ ["read("any")"] // permissions (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md
index 9e281e7..a08b3c7 100644
--- a/docs/examples/databases/delete-document.md
+++ b/docs/examples/databases/delete-document.md
@@ -1,18 +1,15 @@
import { Client, Databases } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const databases = new Databases(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = databases.deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+const result = await databases.deleteDocument(
+ '', // databaseId
+ '', // collectionId
+ '' // documentId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md
index ea80328..d8fe456 100644
--- a/docs/examples/databases/get-document.md
+++ b/docs/examples/databases/get-document.md
@@ -1,18 +1,16 @@
import { Client, Databases } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const databases = new Databases(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = databases.getDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+const result = await databases.getDocument(
+ '', // databaseId
+ '', // collectionId
+ '', // documentId
+ [] // queries (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md
index 4a94c99..3070b00 100644
--- a/docs/examples/databases/list-documents.md
+++ b/docs/examples/databases/list-documents.md
@@ -1,18 +1,15 @@
import { Client, Databases } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const databases = new Databases(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = databases.listDocuments('[DATABASE_ID]', '[COLLECTION_ID]');
+const result = await databases.listDocuments(
+ '', // databaseId
+ '', // collectionId
+ [] // queries (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md
index cc5ef1c..1daaf01 100644
--- a/docs/examples/databases/update-document.md
+++ b/docs/examples/databases/update-document.md
@@ -1,18 +1,17 @@
import { Client, Databases } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const databases = new Databases(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = databases.updateDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]');
+const result = await databases.updateDocument(
+ '', // databaseId
+ '', // collectionId
+ '', // documentId
+ {}, // data (optional)
+ ["read("any")"] // permissions (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md
index 4fc7ac7..4a62462 100644
--- a/docs/examples/functions/create-execution.md
+++ b/docs/examples/functions/create-execution.md
@@ -1,18 +1,18 @@
-import { Client, Functions } from "appwrite";
+import { Client, Functions, ExecutionMethod } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const functions = new Functions(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = functions.createExecution('[FUNCTION_ID]');
+const result = await functions.createExecution(
+ '', // functionId
+ '', // body (optional)
+ false, // async (optional)
+ '', // path (optional)
+ ExecutionMethod.GET, // method (optional)
+ {} // headers (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md
index 2473572..06f9e48 100644
--- a/docs/examples/functions/get-execution.md
+++ b/docs/examples/functions/get-execution.md
@@ -1,18 +1,14 @@
import { Client, Functions } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const functions = new Functions(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
+const result = await functions.getExecution(
+ '', // functionId
+ '' // executionId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md
index 481986e..f6a1c1f 100644
--- a/docs/examples/functions/list-executions.md
+++ b/docs/examples/functions/list-executions.md
@@ -1,18 +1,15 @@
import { Client, Functions } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const functions = new Functions(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = functions.listExecutions('[FUNCTION_ID]');
+const result = await functions.listExecutions(
+ '', // functionId
+ [], // queries (optional)
+ '' // search (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md
index 1a0b61c..ca03455 100644
--- a/docs/examples/graphql/mutation.md
+++ b/docs/examples/graphql/mutation.md
@@ -1,18 +1,13 @@
import { Client, Graphql } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const graphql = new Graphql(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = graphql.mutation({});
+const result = await graphql.mutation(
+ {} // query
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md
index e507fbb..305e4c1 100644
--- a/docs/examples/graphql/query.md
+++ b/docs/examples/graphql/query.md
@@ -1,18 +1,13 @@
import { Client, Graphql } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const graphql = new Graphql(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = graphql.query({});
+const result = await graphql.query(
+ {} // query
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md
index e15bad2..006f339 100644
--- a/docs/examples/locale/get.md
+++ b/docs/examples/locale/get.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.get();
+const result = await locale.get();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md
index a18baa0..ca73077 100644
--- a/docs/examples/locale/list-codes.md
+++ b/docs/examples/locale/list-codes.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listCodes();
+const result = await locale.listCodes();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md
index aa3716e..83e35e2 100644
--- a/docs/examples/locale/list-continents.md
+++ b/docs/examples/locale/list-continents.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listContinents();
+const result = await locale.listContinents();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md
index c924b8d..7a18ab1 100644
--- a/docs/examples/locale/list-countries-e-u.md
+++ b/docs/examples/locale/list-countries-e-u.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listCountriesEU();
+const result = await locale.listCountriesEU();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md
index 0ab6076..2e0daa1 100644
--- a/docs/examples/locale/list-countries-phones.md
+++ b/docs/examples/locale/list-countries-phones.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listCountriesPhones();
+const result = await locale.listCountriesPhones();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md
index ee8c454..28ce9cc 100644
--- a/docs/examples/locale/list-countries.md
+++ b/docs/examples/locale/list-countries.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listCountries();
+const result = await locale.listCountries();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md
index dd37b14..9ab5b13 100644
--- a/docs/examples/locale/list-currencies.md
+++ b/docs/examples/locale/list-currencies.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listCurrencies();
+const result = await locale.listCurrencies();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md
index 89ae06d..ea02c7f 100644
--- a/docs/examples/locale/list-languages.md
+++ b/docs/examples/locale/list-languages.md
@@ -1,18 +1,11 @@
import { Client, Locale } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const locale = new Locale(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = locale.listLanguages();
+const result = await locale.listLanguages();
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md
new file mode 100644
index 0000000..6485fe3
--- /dev/null
+++ b/docs/examples/messaging/create-subscriber.md
@@ -0,0 +1,15 @@
+import { Client, Messaging } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const messaging = new Messaging(client);
+
+const result = await messaging.createSubscriber(
+ '', // topicId
+ '', // subscriberId
+ '' // targetId
+);
+
+console.log(response);
diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md
new file mode 100644
index 0000000..1319c9a
--- /dev/null
+++ b/docs/examples/messaging/delete-subscriber.md
@@ -0,0 +1,14 @@
+import { Client, Messaging } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
+
+const messaging = new Messaging(client);
+
+const result = await messaging.deleteSubscriber(
+ '', // topicId
+ '' // subscriberId
+);
+
+console.log(response);
diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md
index 0cddb08..644fc65 100644
--- a/docs/examples/storage/create-file.md
+++ b/docs/examples/storage/create-file.md
@@ -1,18 +1,16 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = storage.createFile('[BUCKET_ID]', '[FILE_ID]', document.getElementById('uploader').files[0]);
+const result = await storage.createFile(
+ '', // bucketId
+ '', // fileId
+ document.getElementById('uploader').files[0], // file
+ ["read("any")"] // permissions (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md
index 257d855..aefef46 100644
--- a/docs/examples/storage/delete-file.md
+++ b/docs/examples/storage/delete-file.md
@@ -1,18 +1,14 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = storage.deleteFile('[BUCKET_ID]', '[FILE_ID]');
+const result = await storage.deleteFile(
+ '', // bucketId
+ '' // fileId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md
index d8a3542..4ec5e63 100644
--- a/docs/examples/storage/get-file-download.md
+++ b/docs/examples/storage/get-file-download.md
@@ -1,14 +1,14 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]');
+const result = storage.getFileDownload(
+ '', // bucketId
+ '' // fileId
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md
index f0588ba..c674e93 100644
--- a/docs/examples/storage/get-file-preview.md
+++ b/docs/examples/storage/get-file-preview.md
@@ -1,14 +1,25 @@
-import { Client, Storage } from "appwrite";
+import { Client, Storage, ImageGravity, ImageFormat } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = storage.getFilePreview('[BUCKET_ID]', '[FILE_ID]');
+const result = storage.getFilePreview(
+ '', // bucketId
+ '', // fileId
+ 0, // width (optional)
+ 0, // height (optional)
+ ImageGravity.Center, // gravity (optional)
+ 0, // quality (optional)
+ 0, // borderWidth (optional)
+ '', // borderColor (optional)
+ 0, // borderRadius (optional)
+ 0, // opacity (optional)
+ -360, // rotation (optional)
+ '', // background (optional)
+ ImageFormat.Jpg // output (optional)
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md
index 5eb2855..db16105 100644
--- a/docs/examples/storage/get-file-view.md
+++ b/docs/examples/storage/get-file-view.md
@@ -1,14 +1,14 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]');
+const result = storage.getFileView(
+ '', // bucketId
+ '' // fileId
+);
-console.log(result); // Resource URL
\ No newline at end of file
+console.log(result);
diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md
index 6b39ee3..e52dc19 100644
--- a/docs/examples/storage/get-file.md
+++ b/docs/examples/storage/get-file.md
@@ -1,18 +1,14 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]');
+const result = await storage.getFile(
+ '', // bucketId
+ '' // fileId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md
index 696d401..ab5a755 100644
--- a/docs/examples/storage/list-files.md
+++ b/docs/examples/storage/list-files.md
@@ -1,18 +1,15 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = storage.listFiles('[BUCKET_ID]');
+const result = await storage.listFiles(
+ '', // bucketId
+ [], // queries (optional)
+ '' // search (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md
index d22a2f6..8eac864 100644
--- a/docs/examples/storage/update-file.md
+++ b/docs/examples/storage/update-file.md
@@ -1,18 +1,16 @@
import { Client, Storage } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const storage = new Storage(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = storage.updateFile('[BUCKET_ID]', '[FILE_ID]');
+const result = await storage.updateFile(
+ '', // bucketId
+ '', // fileId
+ '', // name (optional)
+ ["read("any")"] // permissions (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md
index 3e47077..9d255ec 100644
--- a/docs/examples/teams/create-membership.md
+++ b/docs/examples/teams/create-membership.md
@@ -1,18 +1,19 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.createMembership('[TEAM_ID]', []);
+const result = await teams.createMembership(
+ '', // teamId
+ [], // roles
+ 'email@example.com', // email (optional)
+ '', // userId (optional)
+ '+12065550100', // phone (optional)
+ 'https://example.com', // url (optional)
+ '' // name (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md
index c9037e9..00ca64d 100644
--- a/docs/examples/teams/create.md
+++ b/docs/examples/teams/create.md
@@ -1,18 +1,15 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.create('[TEAM_ID]', '[NAME]');
+const result = await teams.create(
+ '', // teamId
+ '', // name
+ [] // roles (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md
index c42d669..c2045cd 100644
--- a/docs/examples/teams/delete-membership.md
+++ b/docs/examples/teams/delete-membership.md
@@ -1,18 +1,14 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.deleteMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
+const result = await teams.deleteMembership(
+ '', // teamId
+ '' // membershipId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md
index 0c99b7a..f6e5cb7 100644
--- a/docs/examples/teams/delete.md
+++ b/docs/examples/teams/delete.md
@@ -1,18 +1,13 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.delete('[TEAM_ID]');
+const result = await teams.delete(
+ '' // teamId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md
index d4d3c5a..9871a42 100644
--- a/docs/examples/teams/get-membership.md
+++ b/docs/examples/teams/get-membership.md
@@ -1,18 +1,14 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.getMembership('[TEAM_ID]', '[MEMBERSHIP_ID]');
+const result = await teams.getMembership(
+ '', // teamId
+ '' // membershipId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md
index bcf3f43..a3d036b 100644
--- a/docs/examples/teams/get-prefs.md
+++ b/docs/examples/teams/get-prefs.md
@@ -1,18 +1,13 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.getPrefs('[TEAM_ID]');
+const result = await teams.getPrefs(
+ '' // teamId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md
index 396916e..f54180f 100644
--- a/docs/examples/teams/get.md
+++ b/docs/examples/teams/get.md
@@ -1,18 +1,13 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.get('[TEAM_ID]');
+const result = await teams.get(
+ '' // teamId
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md
index dfa0163..436a79b 100644
--- a/docs/examples/teams/list-memberships.md
+++ b/docs/examples/teams/list-memberships.md
@@ -1,18 +1,15 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.listMemberships('[TEAM_ID]');
+const result = await teams.listMemberships(
+ '', // teamId
+ [], // queries (optional)
+ '' // search (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md
index daf799b..2376863 100644
--- a/docs/examples/teams/list.md
+++ b/docs/examples/teams/list.md
@@ -1,18 +1,14 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.list();
+const result = await teams.list(
+ [], // queries (optional)
+ '' // search (optional)
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md
index de1b7f8..2e240fa 100644
--- a/docs/examples/teams/update-membership-status.md
+++ b/docs/examples/teams/update-membership-status.md
@@ -1,18 +1,16 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.updateMembershipStatus('[TEAM_ID]', '[MEMBERSHIP_ID]', '[USER_ID]', '[SECRET]');
+const result = await teams.updateMembershipStatus(
+ '', // teamId
+ '', // membershipId
+ '', // userId
+ '' // secret
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md
index 662cb91..dc55d04 100644
--- a/docs/examples/teams/update-membership.md
+++ b/docs/examples/teams/update-membership.md
@@ -1,18 +1,15 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.updateMembership('[TEAM_ID]', '[MEMBERSHIP_ID]', []);
+const result = await teams.updateMembership(
+ '', // teamId
+ '', // membershipId
+ [] // roles
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md
index 3159d51..c000401 100644
--- a/docs/examples/teams/update-name.md
+++ b/docs/examples/teams/update-name.md
@@ -1,18 +1,14 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.updateName('[TEAM_ID]', '[NAME]');
+const result = await teams.updateName(
+ '', // teamId
+ '' // name
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md
index 36f60b1..e0fbb76 100644
--- a/docs/examples/teams/update-prefs.md
+++ b/docs/examples/teams/update-prefs.md
@@ -1,18 +1,14 @@
import { Client, Teams } from "appwrite";
-const client = new Client();
+const client = new Client()
+ .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject('5df5acd0d48c2'); // Your project ID
const teams = new Teams(client);
-client
- .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
- .setProject('5df5acd0d48c2') // Your project ID
-;
-
-const promise = teams.updatePrefs('[TEAM_ID]', {});
+const result = await teams.updatePrefs(
+ '', // teamId
+ {} // prefs
+);
-promise.then(function (response) {
- console.log(response); // Success
-}, function (error) {
- console.log(error); // Failure
-});
\ No newline at end of file
+console.log(response);
diff --git a/package.json b/package.json
index 7b03dd8..4ad4a3c 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"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": "13.0.2",
+ "version": "14.0.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
diff --git a/src/client.ts b/src/client.ts
index 98d758e..39cead4 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -92,18 +92,19 @@ class AppwriteException extends Error {
class Client {
config = {
- endpoint: 'https://HOSTNAME/v1',
+ endpoint: 'https://cloud.appwrite.io/v1',
endpointRealtime: '',
project: '',
jwt: '',
locale: '',
+ session: '',
};
headers: Headers = {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
- 'x-sdk-version': '13.0.2',
- 'X-Appwrite-Response-Format': '1.4.0',
+ 'x-sdk-version': '14.0.0',
+ 'X-Appwrite-Response-Format': '1.5.0',
};
/**
@@ -178,6 +179,21 @@ class Client {
return this;
}
+ /**
+ * Set Session
+ *
+ * The user session to authenticate with
+ *
+ * @param value string
+ *
+ * @return {this}
+ */
+ setSession(value: string): this {
+ this.headers['X-Appwrite-Session'] = value;
+ this.config.session = value;
+ return this;
+ }
+
private realtime: Realtime = {
socket: undefined,
diff --git a/src/enums/authentication-factor.ts b/src/enums/authentication-factor.ts
new file mode 100644
index 0000000..928c407
--- /dev/null
+++ b/src/enums/authentication-factor.ts
@@ -0,0 +1,6 @@
+export enum AuthenticationFactor {
+ Email = 'email',
+ Phone = 'phone',
+ Totp = 'totp',
+ Recoverycode = 'recoverycode',
+}
\ No newline at end of file
diff --git a/src/enums/authenticator-type.ts b/src/enums/authenticator-type.ts
new file mode 100644
index 0000000..34db0cc
--- /dev/null
+++ b/src/enums/authenticator-type.ts
@@ -0,0 +1,3 @@
+export enum AuthenticatorType {
+ Totp = 'totp',
+}
\ No newline at end of file
diff --git a/src/enums/browser.ts b/src/enums/browser.ts
new file mode 100644
index 0000000..cec52fb
--- /dev/null
+++ b/src/enums/browser.ts
@@ -0,0 +1,16 @@
+export enum Browser {
+ AvantBrowser = 'aa',
+ AndroidWebViewBeta = 'an',
+ GoogleChrome = 'ch',
+ GoogleChromeIOS = 'ci',
+ GoogleChromeMobile = 'cm',
+ Chromium = 'cr',
+ MozillaFirefox = 'ff',
+ Safari = 'sf',
+ MobileSafari = 'mf',
+ MicrosoftEdge = 'ps',
+ MicrosoftEdgeIOS = 'oi',
+ OperaMini = 'om',
+ Opera = 'op',
+ OperaNext = 'on',
+}
\ No newline at end of file
diff --git a/src/enums/credit-card.ts b/src/enums/credit-card.ts
new file mode 100644
index 0000000..ae917a8
--- /dev/null
+++ b/src/enums/credit-card.ts
@@ -0,0 +1,18 @@
+export enum CreditCard {
+ AmericanExpress = 'amex',
+ Argencard = 'argencard',
+ Cabal = 'cabal',
+ Consosud = 'censosud',
+ DinersClub = 'diners',
+ Discover = 'discover',
+ Elo = 'elo',
+ Hipercard = 'hipercard',
+ JCB = 'jcb',
+ Mastercard = 'mastercard',
+ Naranja = 'naranja',
+ TarjetaShopping = 'targeta-shopping',
+ UnionChinaPay = 'union-china-pay',
+ Visa = 'visa',
+ MIR = 'mir',
+ Maestro = 'maestro',
+}
\ No newline at end of file
diff --git a/src/enums/execution-method.ts b/src/enums/execution-method.ts
new file mode 100644
index 0000000..fc63b07
--- /dev/null
+++ b/src/enums/execution-method.ts
@@ -0,0 +1,8 @@
+export enum ExecutionMethod {
+ GET = 'GET',
+ POST = 'POST',
+ PUT = 'PUT',
+ PATCH = 'PATCH',
+ DELETE = 'DELETE',
+ OPTIONS = 'OPTIONS',
+}
\ No newline at end of file
diff --git a/src/enums/flag.ts b/src/enums/flag.ts
new file mode 100644
index 0000000..07416a4
--- /dev/null
+++ b/src/enums/flag.ts
@@ -0,0 +1,196 @@
+export enum Flag {
+ Afghanistan = 'af',
+ Angola = 'ao',
+ Albania = 'al',
+ Andorra = 'ad',
+ UnitedArabEmirates = 'ae',
+ Argentina = 'ar',
+ Armenia = 'am',
+ AntiguaAndBarbuda = 'ag',
+ Australia = 'au',
+ Austria = 'at',
+ Azerbaijan = 'az',
+ Burundi = 'bi',
+ Belgium = 'be',
+ Benin = 'bj',
+ BurkinaFaso = 'bf',
+ Bangladesh = 'bd',
+ Bulgaria = 'bg',
+ Bahrain = 'bh',
+ Bahamas = 'bs',
+ BosniaAndHerzegovina = 'ba',
+ Belarus = 'by',
+ Belize = 'bz',
+ Bolivia = 'bo',
+ Brazil = 'br',
+ Barbados = 'bb',
+ BruneiDarussalam = 'bn',
+ Bhutan = 'bt',
+ Botswana = 'bw',
+ CentralAfricanRepublic = 'cf',
+ Canada = 'ca',
+ Switzerland = 'ch',
+ Chile = 'cl',
+ China = 'cn',
+ CoteDIvoire = 'ci',
+ Cameroon = 'cm',
+ DemocraticRepublicOfTheCongo = 'cd',
+ RepublicOfTheCongo = 'cg',
+ Colombia = 'co',
+ Comoros = 'km',
+ CapeVerde = 'cv',
+ CostaRica = 'cr',
+ Cuba = 'cu',
+ Cyprus = 'cy',
+ CzechRepublic = 'cz',
+ Germany = 'de',
+ Djibouti = 'dj',
+ Dominica = 'dm',
+ Denmark = 'dk',
+ DominicanRepublic = 'do',
+ Algeria = 'dz',
+ Ecuador = 'ec',
+ Egypt = 'eg',
+ Eritrea = 'er',
+ Spain = 'es',
+ Estonia = 'ee',
+ Ethiopia = 'et',
+ Finland = 'fi',
+ Fiji = 'fj',
+ France = 'fr',
+ MicronesiaFederatedStatesOf = 'fm',
+ Gabon = 'ga',
+ UnitedKingdom = 'gb',
+ Georgia = 'ge',
+ Ghana = 'gh',
+ Guinea = 'gn',
+ Gambia = 'gm',
+ GuineaBissau = 'gw',
+ EquatorialGuinea = 'gq',
+ Greece = 'gr',
+ Grenada = 'gd',
+ Guatemala = 'gt',
+ Guyana = 'gy',
+ Honduras = 'hn',
+ Croatia = 'hr',
+ Haiti = 'ht',
+ Hungary = 'hu',
+ Indonesia = 'id',
+ India = 'in',
+ Ireland = 'ie',
+ IranIslamicRepublicOf = 'ir',
+ Iraq = 'iq',
+ Iceland = 'is',
+ Israel = 'il',
+ Italy = 'it',
+ Jamaica = 'jm',
+ Jordan = 'jo',
+ Japan = 'jp',
+ Kazakhstan = 'kz',
+ Kenya = 'ke',
+ Kyrgyzstan = 'kg',
+ Cambodia = 'kh',
+ Kiribati = 'ki',
+ SaintKittsAndNevis = 'kn',
+ SouthKorea = 'kr',
+ Kuwait = 'kw',
+ LaoPeopleSDemocraticRepublic = 'la',
+ Lebanon = 'lb',
+ Liberia = 'lr',
+ Libya = 'ly',
+ SaintLucia = 'lc',
+ Liechtenstein = 'li',
+ SriLanka = 'lk',
+ Lesotho = 'ls',
+ Lithuania = 'lt',
+ Luxembourg = 'lu',
+ Latvia = 'lv',
+ Morocco = 'ma',
+ Monaco = 'mc',
+ Moldova = 'md',
+ Madagascar = 'mg',
+ Maldives = 'mv',
+ Mexico = 'mx',
+ MarshallIslands = 'mh',
+ NorthMacedonia = 'mk',
+ Mali = 'ml',
+ Malta = 'mt',
+ Myanmar = 'mm',
+ Montenegro = 'me',
+ Mongolia = 'mn',
+ Mozambique = 'mz',
+ Mauritania = 'mr',
+ Mauritius = 'mu',
+ Malawi = 'mw',
+ Malaysia = 'my',
+ Namibia = 'na',
+ Niger = 'ne',
+ Nigeria = 'ng',
+ Nicaragua = 'ni',
+ Netherlands = 'nl',
+ Norway = 'no',
+ Nepal = 'np',
+ Nauru = 'nr',
+ NewZealand = 'nz',
+ Oman = 'om',
+ Pakistan = 'pk',
+ Panama = 'pa',
+ Peru = 'pe',
+ Philippines = 'ph',
+ Palau = 'pw',
+ PapuaNewGuinea = 'pg',
+ Poland = 'pl',
+ NorthKorea = 'kp',
+ Portugal = 'pt',
+ Paraguay = 'py',
+ Qatar = 'qa',
+ Romania = 'ro',
+ Russia = 'ru',
+ Rwanda = 'rw',
+ SaudiArabia = 'sa',
+ Sudan = 'sd',
+ Senegal = 'sn',
+ Singapore = 'sg',
+ SolomonIslands = 'sb',
+ SierraLeone = 'sl',
+ ElSalvador = 'sv',
+ SanMarino = 'sm',
+ Somalia = 'so',
+ Serbia = 'rs',
+ SouthSudan = 'ss',
+ SaoTomeAndPrincipe = 'st',
+ Suriname = 'sr',
+ Slovakia = 'sk',
+ Slovenia = 'si',
+ Sweden = 'se',
+ Eswatini = 'sz',
+ Seychelles = 'sc',
+ Syria = 'sy',
+ Chad = 'td',
+ Togo = 'tg',
+ Thailand = 'th',
+ Tajikistan = 'tj',
+ Turkmenistan = 'tm',
+ TimorLeste = 'tl',
+ Tonga = 'to',
+ TrinidadAndTobago = 'tt',
+ Tunisia = 'tn',
+ Turkey = 'tr',
+ Tuvalu = 'tv',
+ Tanzania = 'tz',
+ Uganda = 'ug',
+ Ukraine = 'ua',
+ Uruguay = 'uy',
+ UnitedStates = 'us',
+ Uzbekistan = 'uz',
+ VaticanCity = 'va',
+ SaintVincentAndTheGrenadines = 'vc',
+ Venezuela = 've',
+ Vietnam = 'vn',
+ Vanuatu = 'vu',
+ Samoa = 'ws',
+ Yemen = 'ye',
+ SouthAfrica = 'za',
+ Zambia = 'zm',
+ Zimbabwe = 'zw',
+}
\ No newline at end of file
diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts
new file mode 100644
index 0000000..7e96fd8
--- /dev/null
+++ b/src/enums/image-format.ts
@@ -0,0 +1,7 @@
+export enum ImageFormat {
+ Jpg = 'jpg',
+ Jpeg = 'jpeg',
+ Gif = 'gif',
+ Png = 'png',
+ Webp = 'webp',
+}
\ No newline at end of file
diff --git a/src/enums/image-gravity.ts b/src/enums/image-gravity.ts
new file mode 100644
index 0000000..815095d
--- /dev/null
+++ b/src/enums/image-gravity.ts
@@ -0,0 +1,11 @@
+export enum ImageGravity {
+ Center = 'center',
+ Topleft = 'top-left',
+ Top = 'top',
+ Topright = 'top-right',
+ Left = 'left',
+ Right = 'right',
+ Bottomleft = 'bottom-left',
+ Bottom = 'bottom',
+ Bottomright = 'bottom-right',
+}
\ No newline at end of file
diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts
new file mode 100644
index 0000000..b2bf4d1
--- /dev/null
+++ b/src/enums/o-auth-provider.ts
@@ -0,0 +1,41 @@
+export enum OAuthProvider {
+ Amazon = 'amazon',
+ Apple = 'apple',
+ Auth0 = 'auth0',
+ Authentik = 'authentik',
+ Autodesk = 'autodesk',
+ Bitbucket = 'bitbucket',
+ Bitly = 'bitly',
+ Box = 'box',
+ Dailymotion = 'dailymotion',
+ Discord = 'discord',
+ Disqus = 'disqus',
+ Dropbox = 'dropbox',
+ Etsy = 'etsy',
+ Facebook = 'facebook',
+ Github = 'github',
+ Gitlab = 'gitlab',
+ Google = 'google',
+ Linkedin = 'linkedin',
+ Microsoft = 'microsoft',
+ Notion = 'notion',
+ Oidc = 'oidc',
+ Okta = 'okta',
+ Paypal = 'paypal',
+ PaypalSandbox = 'paypalSandbox',
+ Podio = 'podio',
+ Salesforce = 'salesforce',
+ Slack = 'slack',
+ Spotify = 'spotify',
+ Stripe = 'stripe',
+ Tradeshift = 'tradeshift',
+ TradeshiftBox = 'tradeshiftBox',
+ Twitch = 'twitch',
+ Wordpress = 'wordpress',
+ Yahoo = 'yahoo',
+ Yammer = 'yammer',
+ Yandex = 'yandex',
+ Zoho = 'zoho',
+ Zoom = 'zoom',
+ Mock = 'mock',
+}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 2f90e42..72a7cc9 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -5,10 +5,20 @@ export { Databases } from './services/databases';
export { Functions } from './services/functions';
export { Graphql } from './services/graphql';
export { Locale } from './services/locale';
+export { Messaging } from './services/messaging';
export { Storage } from './services/storage';
export { Teams } from './services/teams';
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
+export { ID } from './id';
+export { AuthenticatorType } from './enums/authenticator-type';
+export { AuthenticationFactor } from './enums/authentication-factor';
+export { OAuthProvider } from './enums/o-auth-provider';
+export { Browser } from './enums/browser';
+export { CreditCard } from './enums/credit-card';
+export { Flag } from './enums/flag';
+export { ExecutionMethod } from './enums/execution-method';
+export { ImageGravity } from './enums/image-gravity';
+export { ImageFormat } from './enums/image-format';
diff --git a/src/models.ts b/src/models.ts
index 5c28e4b..0e907cb 100644
--- a/src/models.ts
+++ b/src/models.ts
@@ -364,10 +364,18 @@ export namespace Models {
* Phone verification status.
*/
phoneVerification: boolean;
+ /**
+ * Multi factor authentication status.
+ */
+ mfa: boolean;
/**
* User preferences as a key-value object
*/
prefs: Preferences;
+ /**
+ * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider.
+ */
+ targets: Target[];
/**
* Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.
*/
@@ -586,6 +594,18 @@ export namespace Models {
* Returns true if this the current user session.
*/
current: boolean;
+ /**
+ * Returns a list of active session factors.
+ */
+ factors: string[];
+ /**
+ * Secret used to authenticate the user. Only included if the request was made with an API key
+ */
+ secret: string;
+ /**
+ * Most recent date in ISO 8601 format when the session successfully passed MFA challenge.
+ */
+ mfaUpdatedAt: string;
}
/**
* Identity
@@ -656,6 +676,10 @@ export namespace Models {
* Token expiration date in ISO 8601 format.
*/
expire: string;
+ /**
+ * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email.
+ */
+ phrase: string;
}
/**
* JWT
@@ -838,6 +862,10 @@ export namespace Models {
* User confirmation status, true if the user has joined the team or false otherwise.
*/
confirm: boolean;
+ /**
+ * Multi factor authentication status, true if the user has MFA enabled or false otherwise.
+ */
+ mfa: boolean;
/**
* User list of roles
*/
@@ -1018,4 +1046,142 @@ export namespace Models {
*/
value: string;
}
+ /**
+ * MFA Challenge
+ */
+ export type MfaChallenge = {
+ /**
+ * Token ID.
+ */
+ $id: string;
+ /**
+ * Token creation date in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * Token expiration date in ISO 8601 format.
+ */
+ expire: string;
+ }
+ /**
+ * MFA Recovery Codes
+ */
+ export type MfaRecoveryCodes = {
+ /**
+ * Recovery codes.
+ */
+ recoveryCodes: string[];
+ }
+ /**
+ * MFAType
+ */
+ export type MfaType = {
+ /**
+ * Secret token used for TOTP factor.
+ */
+ secret: string;
+ /**
+ * URI for authenticator apps.
+ */
+ uri: string;
+ }
+ /**
+ * MFAFactors
+ */
+ export type MfaFactors = {
+ /**
+ * TOTP
+ */
+ totp: boolean;
+ /**
+ * Phone
+ */
+ phone: boolean;
+ /**
+ * Email
+ */
+ email: boolean;
+ }
+ /**
+ * Subscriber
+ */
+ export type Subscriber = {
+ /**
+ * Subscriber ID.
+ */
+ $id: string;
+ /**
+ * Subscriber creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Subscriber update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Target ID.
+ */
+ targetId: string;
+ /**
+ * Target.
+ */
+ target: Target;
+ /**
+ * Topic ID.
+ */
+ userId: string;
+ /**
+ * User Name.
+ */
+ userName: string;
+ /**
+ * Topic ID.
+ */
+ topicId: string;
+ /**
+ * The target provider type. Can be one of the following: `email`, `sms` or `push`.
+ */
+ providerType: string;
+ }
+ /**
+ * Target
+ */
+ export type Target = {
+ /**
+ * Target ID.
+ */
+ $id: string;
+ /**
+ * Target creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Target update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Target Name.
+ */
+ name: string;
+ /**
+ * User ID.
+ */
+ userId: string;
+ /**
+ * Provider ID.
+ */
+ providerId?: string;
+ /**
+ * The target provider type. Can be one of the following: `email`, `sms` or `push`.
+ */
+ providerType: string;
+ /**
+ * The target identifier.
+ */
+ identifier: string;
+ }
}
diff --git a/src/query.ts b/src/query.ts
index 1f880cb..229d6c8 100644
--- a/src/query.ts
+++ b/src/query.ts
@@ -1,74 +1,101 @@
type QueryTypesSingle = string | number | boolean;
-export type QueryTypesList = string[] | number[] | boolean[];
+export type QueryTypesList = string[] | number[] | boolean[] | Query[];
export type QueryTypes = QueryTypesSingle | QueryTypesList;
+type AttributesTypes = string | string[];
export class Query {
+ method: string;
+ attribute: AttributesTypes | undefined;
+ values: QueryTypesList | undefined;
+
+ constructor(
+ method: string,
+ attribute?: AttributesTypes,
+ values?: QueryTypes
+ ) {
+ this.method = method;
+ this.attribute = attribute;
+
+ if (values !== undefined) {
+ if (Array.isArray(values)) {
+ this.values = values;
+ } else {
+ this.values = [values] as QueryTypesList;
+ }
+ }
+ }
+
+ toString(): string {
+ return JSON.stringify({
+ method: this.method,
+ attribute: this.attribute,
+ values: this.values,
+ });
+ }
+
static equal = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "equal", value);
+ new Query("equal", attribute, value).toString();
static notEqual = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "notEqual", value);
+ new Query("notEqual", attribute, value).toString();
static lessThan = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "lessThan", value);
+ new Query("lessThan", attribute, value).toString();
static lessThanEqual = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "lessThanEqual", value);
+ new Query("lessThanEqual", attribute, value).toString();
static greaterThan = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "greaterThan", value);
+ new Query("greaterThan", attribute, value).toString();
static greaterThanEqual = (attribute: string, value: QueryTypes): string =>
- Query.addQuery(attribute, "greaterThanEqual", value);
+ new Query("greaterThanEqual", attribute, value).toString();
static isNull = (attribute: string): string =>
- `isNull("${attribute}")`;
+ new Query("isNull", attribute).toString();
static isNotNull = (attribute: string): string =>
- `isNotNull("${attribute}")`;
+ new Query("isNotNull", attribute).toString();
- static between = (attribute: string, start: string|number, end: string|number): string =>
- `between("${attribute}", ${Query.parseValues(start)}, ${Query.parseValues(end)})`;
+ static between = (attribute: string, start: string | number, end: string | number) =>
+ new Query("between", attribute, [start, end] as QueryTypesList).toString();
static startsWith = (attribute: string, value: string): string =>
- Query.addQuery(attribute, "startsWith", value);
+ new Query("startsWith", attribute, value).toString();
static endsWith = (attribute: string, value: string): string =>
- Query.addQuery(attribute, "endsWith", value);
+ new Query("endsWith", attribute, value).toString();
static select = (attributes: string[]): string =>
- `select([${attributes.map((attr: string) => `"${attr}"`).join(",")}])`;
+ new Query("select", undefined, attributes).toString();
static search = (attribute: string, value: string): string =>
- Query.addQuery(attribute, "search", value);
+ new Query("search", attribute, value).toString();
static orderDesc = (attribute: string): string =>
- `orderDesc("${attribute}")`;
+ new Query("orderDesc", attribute).toString();
static orderAsc = (attribute: string): string =>
- `orderAsc("${attribute}")`;
+ new Query("orderAsc", attribute).toString();
static cursorAfter = (documentId: string): string =>
- `cursorAfter("${documentId}")`;
+ new Query("cursorAfter", undefined, documentId).toString();
static cursorBefore = (documentId: string): string =>
- `cursorBefore("${documentId}")`;
+ new Query("cursorBefore", undefined, documentId).toString();
static limit = (limit: number): string =>
- `limit(${limit})`;
+ new Query("limit", undefined, limit).toString();
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
+ new Query("offset", undefined, offset).toString();
+
+ static contains = (attribute: string, value: string | string[]): string =>
+ new Query("contains", attribute, value).toString();
+
+ static or = (queries: string[]) =>
+ new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();
+
+ static and = (queries: string[]) =>
+ new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();
+}
diff --git a/src/service.ts b/src/service.ts
index 0c9662b..fe17699 100644
--- a/src/service.ts
+++ b/src/service.ts
@@ -13,14 +13,11 @@ export class Service {
static flatten(data: Payload, prefix = ''): Payload {
let output: Payload = {};
- for (const key in data) {
- let value = data[key];
- let finalKey = prefix ? `${prefix}[${key}]` : key;
-
+ for (const [key, value] of Object.entries(data)) {
+ let finalKey = prefix ? prefix + '[' + key +']' : key;
if (Array.isArray(value)) {
- output = Object.assign(output, this.flatten(value, finalKey));
- }
- else {
+ output = { ...output, ...Service.flatten(value, finalKey) };
+ } else {
output[finalKey] = value;
}
}
diff --git a/src/services/account.ts b/src/services/account.ts
index 29d4b6a..023d178 100644
--- a/src/services/account.ts
+++ b/src/services/account.ts
@@ -2,6 +2,9 @@ import { Service } from '../service';
import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
+import { AuthenticatorType } from '../enums/authenticator-type';
+import { AuthenticationFactor } from '../enums/authentication-factor';
+import { OAuthProvider } from '../enums/o-auth-provider';
export class Account extends Service {
@@ -132,11 +135,11 @@ export class Account extends Service {
*
* Get the list of identities for the currently logged in user.
*
- * @param {string} queries
+ * @param {string[]} queries
* @throws {AppwriteException}
* @returns {Promise}
*/
- async listIdentities(queries?: string): Promise {
+ async listIdentities(queries?: string[]): Promise {
const apiPath = '/account/identities';
const payload: Payload = {};
@@ -151,7 +154,7 @@ export class Account extends Service {
}
/**
- * Delete Identity
+ * Delete identity
*
* Delete an identity by its unique ID.
*
@@ -219,6 +222,276 @@ export class Account extends Service {
}, payload);
}
+ /**
+ * Update MFA
+ *
+ * Enable or disable MFA on an account.
+ *
+ * @param {boolean} mfa
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMFA(mfa: boolean): Promise> {
+ if (typeof mfa === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "mfa"');
+ }
+
+ const apiPath = '/account/mfa';
+ const payload: Payload = {};
+
+ if (typeof mfa !== 'undefined') {
+ payload['mfa'] = mfa;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Add Authenticator
+ *
+ * Add an authenticator app to be used as an MFA factor. Verify the
+ * authenticator using the [verify
+ * authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator)
+ * method.
+ *
+ * @param {AuthenticatorType} type
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMfaAuthenticator(type: AuthenticatorType): Promise {
+ if (typeof type === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "type"');
+ }
+
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Verify Authenticator
+ *
+ * Verify an authenticator app after adding it using the [add
+ * authenticator](/docs/references/cloud/client-web/account#addAuthenticator)
+ * method.
+ *
+ * @param {AuthenticatorType} type
+ * @param {string} otp
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> {
+ if (typeof type === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "type"');
+ }
+
+ if (typeof otp === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "otp"');
+ }
+
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
+ const payload: Payload = {};
+
+ if (typeof otp !== 'undefined') {
+ payload['otp'] = otp;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete Authenticator
+ *
+ * Delete an authenticator for a user by ID.
+ *
+ * @param {AuthenticatorType} type
+ * @param {string} otp
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> {
+ if (typeof type === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "type"');
+ }
+
+ if (typeof otp === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "otp"');
+ }
+
+ const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type);
+ const payload: Payload = {};
+
+ if (typeof otp !== 'undefined') {
+ payload['otp'] = otp;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create 2FA Challenge
+ *
+ * Begin the process of MFA verification after sign-in. Finish the flow with
+ * [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
+ * method.
+ *
+ * @param {AuthenticationFactor} factor
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMfaChallenge(factor: AuthenticationFactor): Promise {
+ if (typeof factor === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "factor"');
+ }
+
+ const apiPath = '/account/mfa/challenge';
+ const payload: Payload = {};
+
+ if (typeof factor !== 'undefined') {
+ payload['factor'] = factor;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create MFA Challenge (confirmation)
+ *
+ * Complete the MFA challenge by providing the one-time password. Finish the
+ * process of MFA verification by providing the one-time password. To begin
+ * the flow, use
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
+ * method.
+ *
+ * @param {string} challengeId
+ * @param {string} otp
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMfaChallenge(challengeId: string, otp: string): Promise<{}> {
+ if (typeof challengeId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "challengeId"');
+ }
+
+ if (typeof otp === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "otp"');
+ }
+
+ const apiPath = '/account/mfa/challenge';
+ const payload: Payload = {};
+
+ if (typeof challengeId !== 'undefined') {
+ payload['challengeId'] = challengeId;
+ }
+
+ if (typeof otp !== 'undefined') {
+ payload['otp'] = otp;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * List Factors
+ *
+ * List the factors available on the account to be used as a MFA challange.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async listMfaFactors(): Promise {
+ const apiPath = '/account/mfa/factors';
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Get MFA Recovery Codes
+ *
+ * Get recovery codes that can be used as backup for MFA flow. Before getting
+ * codes, they must be generated using
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
+ * method. An OTP challenge is required to read recovery codes.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async getMfaRecoveryCodes(): Promise {
+ const apiPath = '/account/mfa/recovery-codes';
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('get', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create MFA Recovery Codes
+ *
+ * Generate recovery codes as backup for MFA flow. It's recommended to
+ * generate and show then immediately after user successfully adds their
+ * authehticator. Recovery codes can be used as a MFA verification type in
+ * [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge)
+ * method.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMfaRecoveryCodes(): Promise {
+ const apiPath = '/account/mfa/recovery-codes';
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Regenerate MFA Recovery Codes
+ *
+ * Regenerate recovery codes that can be used as backup for MFA flow. Before
+ * regenerating codes, they must be first generated using
+ * [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes)
+ * method. An OTP challenge is required to regenreate recovery codes.
+ *
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updateMfaRecoveryCodes(): Promise {
+ const apiPath = '/account/mfa/recovery-codes';
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('patch', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
/**
* Update name
*
@@ -427,11 +700,10 @@ export class Account extends Service {
* @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 {
+ async updateRecovery(userId: string, secret: string, password: string): Promise {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@@ -444,10 +716,6 @@ export class Account extends Service {
throw new AppwriteException('Missing required parameter: "password"');
}
- if (typeof passwordAgain === 'undefined') {
- throw new AppwriteException('Missing required parameter: "passwordAgain"');
- }
-
const apiPath = '/account/recovery';
const payload: Payload = {};
@@ -463,10 +731,6 @@ export class Account extends Service {
payload['password'] = password;
}
- if (typeof passwordAgain !== 'undefined') {
- payload['passwordAgain'] = passwordAgain;
- }
-
const uri = new URL(this.client.config.endpoint + apiPath);
return await this.client.call('put', uri, {
'content-type': 'application/json',
@@ -536,7 +800,7 @@ export class Account extends Service {
}
/**
- * Create email session
+ * Create email password 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.
@@ -550,7 +814,7 @@ export class Account extends Service {
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createEmailSession(email: string, password: string): Promise {
+ async createEmailPasswordSession(email: string, password: string): Promise {
if (typeof email === 'undefined') {
throw new AppwriteException('Missing required parameter: "email"');
}
@@ -577,75 +841,11 @@ export class Account extends Service {
}
/**
- * Create magic URL session
- *
- * Sends the user an email with a secret key for creating a session. If the
- * provided user ID has not been 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](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession)
- * 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](https://appwrite.io/docs/authentication-security#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"');
- }
-
- const apiPath = '/account/sessions/magic-url';
- const 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 + apiPath);
- return await this.client.call('post', uri, {
- 'content-type': 'application/json',
- }, payload);
- }
-
- /**
- * Create magic URL session (confirmation)
+ * Update magic URL session
*
- * 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](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession)
- * 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.
+ * Use this endpoint to create a session from token. Provide the **userId**
+ * and **secret** parameters from the successful response of authentication
+ * flows initiated by token creation. For example, magic URL and phone login.
*
* @param {string} userId
* @param {string} secret
@@ -698,14 +898,14 @@ export class Account extends Service {
* limits](https://appwrite.io/docs/authentication-security#limits).
*
*
- * @param {string} provider
+ * @param {OAuthProvider} 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 {
+ createOAuth2Session(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | URL {
if (typeof provider === 'undefined') {
throw new AppwriteException('Missing required parameter: "provider"');
}
@@ -740,31 +940,24 @@ export class Account extends Service {
}
/**
- * Create phone session
+ * Update 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession)
- * 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](https://appwrite.io/docs/authentication-security#limits).
+ * Use this endpoint to create a session from token. Provide the **userId**
+ * and **secret** parameters from the successful response of authentication
+ * flows initiated by token creation. For example, magic URL and phone login.
*
* @param {string} userId
- * @param {string} phone
+ * @param {string} secret
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createPhoneSession(userId: string, phone: string): Promise {
+ async updatePhoneSession(userId: string, secret: string): Promise {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
- if (typeof phone === 'undefined') {
- throw new AppwriteException('Missing required parameter: "phone"');
+ if (typeof secret === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "secret"');
}
const apiPath = '/account/sessions/phone';
@@ -774,31 +967,29 @@ export class Account extends Service {
payload['userId'] = userId;
}
- if (typeof phone !== 'undefined') {
- payload['phone'] = phone;
+ if (typeof secret !== 'undefined') {
+ payload['secret'] = secret;
}
const uri = new URL(this.client.config.endpoint + apiPath);
- return await this.client.call('post', uri, {
+ return await this.client.call('put', uri, {
'content-type': 'application/json',
}, payload);
}
/**
- * Create phone session (confirmation)
+ * Create session
*
- * Use this endpoint to complete creating a session with SMS. Use the
- * **userId** from the
- * [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession)
- * endpoint and the **secret** received via SMS to successfully update and
- * confirm the phone session.
+ * Use this endpoint to create a session from token. Provide the **userId**
+ * and **secret** parameters from the successful response of authentication
+ * flows initiated by token creation. For example, magic URL and phone login.
*
* @param {string} userId
* @param {string} secret
* @throws {AppwriteException}
* @returns {Promise}
*/
- async updatePhoneSession(userId: string, secret: string): Promise {
+ async createSession(userId: string, secret: string): Promise {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
@@ -807,7 +998,7 @@ export class Account extends Service {
throw new AppwriteException('Missing required parameter: "secret"');
}
- const apiPath = '/account/sessions/phone';
+ const apiPath = '/account/sessions/token';
const payload: Payload = {};
if (typeof userId !== 'undefined') {
@@ -819,7 +1010,7 @@ export class Account extends Service {
}
const uri = new URL(this.client.config.endpoint + apiPath);
- return await this.client.call('put', uri, {
+ return await this.client.call('post', uri, {
'content-type': 'application/json',
}, payload);
}
@@ -849,11 +1040,11 @@ export class Account extends Service {
}
/**
- * Update OAuth session (refresh tokens)
+ * Update session
*
- * 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.
+ * Use this endpoint to extend a session's length. Extending a session is
+ * useful when session expiry is short. If the session was created using an
+ * OAuth provider, this endpoint refreshes the access token from the provider.
*
* @param {string} sessionId
* @throws {AppwriteException}
@@ -920,6 +1111,314 @@ export class Account extends Service {
}, payload);
}
+ /**
+ * Create push target
+ *
+ *
+ * @param {string} targetId
+ * @param {string} identifier
+ * @param {string} providerId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPushTarget(targetId: string, identifier: string, providerId?: string): Promise {
+ if (typeof targetId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "targetId"');
+ }
+
+ if (typeof identifier === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "identifier"');
+ }
+
+ const apiPath = '/account/targets/push';
+ const payload: Payload = {};
+
+ if (typeof targetId !== 'undefined') {
+ payload['targetId'] = targetId;
+ }
+
+ if (typeof identifier !== 'undefined') {
+ payload['identifier'] = identifier;
+ }
+
+ if (typeof providerId !== 'undefined') {
+ payload['providerId'] = providerId;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Update push target
+ *
+ *
+ * @param {string} targetId
+ * @param {string} identifier
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async updatePushTarget(targetId: string, identifier: string): Promise {
+ if (typeof targetId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "targetId"');
+ }
+
+ if (typeof identifier === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "identifier"');
+ }
+
+ const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
+ const payload: Payload = {};
+
+ if (typeof identifier !== 'undefined') {
+ payload['identifier'] = identifier;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('put', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete push target
+ *
+ *
+ * @param {string} targetId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deletePushTarget(targetId: string): Promise<{}> {
+ if (typeof targetId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "targetId"');
+ }
+
+ const apiPath = '/account/targets/{targetId}/push'.replace('{targetId}', targetId);
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create email token (OTP)
+ *
+ * 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. Use the
+ * returned user ID and secret and submit a request to the [POST
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
+ * endpoint to complete the login process. The secret sent to the user's email
+ * is valid for 15 minutes.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session
+ * limits](https://appwrite.io/docs/authentication-security#limits).
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {boolean} phrase
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createEmailToken(userId: string, email: string, phrase?: boolean): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ const apiPath = '/account/tokens/email';
+ const payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof phrase !== 'undefined') {
+ payload['phrase'] = phrase;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create magic URL token
+ *
+ * Sends the user an email with a secret key for creating a session. If the
+ * provided user ID has not been 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
+ * [POST
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
+ * 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](https://appwrite.io/docs/authentication-security#limits).
+ *
+ *
+ * @param {string} userId
+ * @param {string} email
+ * @param {string} url
+ * @param {boolean} phrase
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise {
+ if (typeof userId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "userId"');
+ }
+
+ if (typeof email === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "email"');
+ }
+
+ const apiPath = '/account/tokens/magic-url';
+ const payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof email !== 'undefined') {
+ payload['email'] = email;
+ }
+
+ if (typeof url !== 'undefined') {
+ payload['url'] = url;
+ }
+
+ if (typeof phrase !== 'undefined') {
+ payload['phrase'] = phrase;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Create OAuth2 token
+ *
+ * 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 authentication succeeds, `userId` and `secret` of a token will be
+ * appended to the success URL as query parameters. These can be used to
+ * create a new session using the [Create
+ * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
+ * endpoint.
+ *
+ * A user is limited to 10 active sessions at a time by default. [Learn more
+ * about session
+ * limits](https://appwrite.io/docs/authentication-security#limits).
+ *
+ * @param {OAuthProvider} provider
+ * @param {string} success
+ * @param {string} failure
+ * @param {string[]} scopes
+ * @throws {AppwriteException}
+ * @returns {void|string}
+ */
+ createOAuth2Token(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | URL {
+ if (typeof provider === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "provider"');
+ }
+
+ const apiPath = '/account/tokens/oauth2/{provider}'.replace('{provider}', provider);
+ const 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 + apiPath);
+ 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 token
+ *
+ * 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 [POST
+ * /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
+ * 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](https://appwrite.io/docs/authentication-security#limits).
+ *
+ * @param {string} userId
+ * @param {string} phone
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createPhoneToken(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"');
+ }
+
+ const apiPath = '/account/tokens/phone';
+ const payload: Payload = {};
+
+ if (typeof userId !== 'undefined') {
+ payload['userId'] = userId;
+ }
+
+ if (typeof phone !== 'undefined') {
+ payload['phone'] = phone;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
/**
* Create email verification
*
diff --git a/src/services/avatars.ts b/src/services/avatars.ts
index 13ed4a5..fae5666 100644
--- a/src/services/avatars.ts
+++ b/src/services/avatars.ts
@@ -2,6 +2,9 @@ import { Service } from '../service';
import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
+import { Browser } from '../enums/browser';
+import { CreditCard } from '../enums/credit-card';
+import { Flag } from '../enums/flag';
export class Avatars extends Service {
@@ -24,14 +27,14 @@ export class Avatars extends Service {
* image at source quality. If dimensions are not specified, the default size
* of image returned is 100x100px.
*
- * @param {string} code
+ * @param {Browser} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {AppwriteException}
* @returns {URL}
*/
- getBrowser(code: string, width?: number, height?: number, quality?: number): URL {
+ getBrowser(code: Browser, width?: number, height?: number, quality?: number): URL {
if (typeof code === 'undefined') {
throw new AppwriteException('Missing required parameter: "code"');
}
@@ -74,14 +77,14 @@ export class Avatars extends Service {
* of image returned is 100x100px.
*
*
- * @param {string} code
+ * @param {CreditCard} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {AppwriteException}
* @returns {URL}
*/
- getCreditCard(code: string, width?: number, height?: number, quality?: number): URL {
+ getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): URL {
if (typeof code === 'undefined') {
throw new AppwriteException('Missing required parameter: "code"');
}
@@ -158,14 +161,14 @@ export class Avatars extends Service {
* of image returned is 100x100px.
*
*
- * @param {string} code
+ * @param {Flag} code
* @param {number} width
* @param {number} height
* @param {number} quality
* @throws {AppwriteException}
* @returns {URL}
*/
- getFlag(code: string, width?: number, height?: number, quality?: number): URL {
+ getFlag(code: Flag, width?: number, height?: number, quality?: number): URL {
if (typeof code === 'undefined') {
throw new AppwriteException('Missing required parameter: "code"');
}
diff --git a/src/services/functions.ts b/src/services/functions.ts
index 83d6484..16d55fe 100644
--- a/src/services/functions.ts
+++ b/src/services/functions.ts
@@ -2,6 +2,7 @@ import { Service } from '../service';
import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
+import { ExecutionMethod } from '../enums/execution-method';
export class Functions extends Service {
@@ -56,12 +57,12 @@ export class Functions extends Service {
* @param {string} body
* @param {boolean} async
* @param {string} xpath
- * @param {string} method
+ * @param {ExecutionMethod} method
* @param {object} headers
* @throws {AppwriteException}
* @returns {Promise}
*/
- async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: string, headers?: object): Promise {
+ async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object): Promise {
if (typeof functionId === 'undefined') {
throw new AppwriteException('Missing required parameter: "functionId"');
}
diff --git a/src/services/messaging.ts b/src/services/messaging.ts
new file mode 100644
index 0000000..16920b2
--- /dev/null
+++ b/src/services/messaging.ts
@@ -0,0 +1,81 @@
+import { Service } from '../service';
+import { AppwriteException, Client } from '../client';
+import type { Models } from '../models';
+import type { UploadProgress, Payload } from '../client';
+
+export class Messaging extends Service {
+
+ constructor(client: Client)
+ {
+ super(client);
+ }
+
+ /**
+ * Create subscriber
+ *
+ * Create a new subscriber.
+ *
+ * @param {string} topicId
+ * @param {string} subscriberId
+ * @param {string} targetId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise {
+ if (typeof topicId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "topicId"');
+ }
+
+ if (typeof subscriberId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "subscriberId"');
+ }
+
+ if (typeof targetId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "targetId"');
+ }
+
+ const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId);
+ const payload: Payload = {};
+
+ if (typeof subscriberId !== 'undefined') {
+ payload['subscriberId'] = subscriberId;
+ }
+
+ if (typeof targetId !== 'undefined') {
+ payload['targetId'] = targetId;
+ }
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('post', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+
+ /**
+ * Delete subscriber
+ *
+ * Delete a subscriber by its unique ID.
+ *
+ * @param {string} topicId
+ * @param {string} subscriberId
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ async deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> {
+ if (typeof topicId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "topicId"');
+ }
+
+ if (typeof subscriberId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "subscriberId"');
+ }
+
+ const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId);
+ const payload: Payload = {};
+
+ const uri = new URL(this.client.config.endpoint + apiPath);
+ return await this.client.call('delete', uri, {
+ 'content-type': 'application/json',
+ }, payload);
+ }
+};
diff --git a/src/services/storage.ts b/src/services/storage.ts
index dd3f499..83a51b1 100644
--- a/src/services/storage.ts
+++ b/src/services/storage.ts
@@ -2,6 +2,8 @@ import { Service } from '../service';
import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
+import { ImageGravity } from '../enums/image-gravity';
+import { ImageFormat } from '../enums/image-format';
export class Storage extends Service {
@@ -299,7 +301,7 @@ export class Storage extends Service {
* @param {string} fileId
* @param {number} width
* @param {number} height
- * @param {string} gravity
+ * @param {ImageGravity} gravity
* @param {number} quality
* @param {number} borderWidth
* @param {string} borderColor
@@ -307,11 +309,11 @@ export class Storage extends Service {
* @param {number} opacity
* @param {number} rotation
* @param {string} background
- * @param {string} output
+ * @param {ImageFormat} 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 {
+ getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: ImageGravity, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: ImageFormat): URL {
if (typeof bucketId === 'undefined') {
throw new AppwriteException('Missing required parameter: "bucketId"');
}