From 78febed05cf1ef96e4575909c76d6d5e03d4afb9 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:47:05 +0100 Subject: [PATCH 01/27] fix: remove content-type from GET requests --- README.md | 2 +- package.json | 2 +- src/client.ts | 13 ++++++++++--- src/enums/o-auth-provider.ts | 1 + src/services/account.ts | 8 -------- src/services/databases.ts | 2 -- src/services/functions.ts | 2 -- src/services/locale.ts | 8 -------- src/services/storage.ts | 2 -- src/services/teams.ts | 5 ----- 10 files changed, 13 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 66d8ec22..3f24ffcd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.2-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) diff --git a/package.json b/package.json index 64c51f84..5ff33cff 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.7.2", + "version": "0.7.3", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 5bfa8299..fb3e96a5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.7.2', + 'x-sdk-version': '0.7.3', 'X-Appwrite-Response-Format': '1.6.0', }; @@ -128,8 +128,12 @@ class Client { * @returns {this} */ setEndpoint(endpoint: string): this { + if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) { + throw new AppwriteException('Invalid endpoint URL: ' + endpoint); + } + this.config.endpoint = endpoint; - this.config.endpointRealtime = this.config.endpointRealtime || this.config.endpoint.replace('https://', 'wss://').replace('http://', 'ws://'); + this.config.endpointRealtime = endpoint.replace('https://', 'wss://').replace('http://', 'ws://'); return this; } @@ -142,8 +146,11 @@ class Client { * @returns {this} */ setEndpointRealtime(endpointRealtime: string): this { - this.config.endpointRealtime = endpointRealtime; + if (!endpointRealtime.startsWith('ws://') && !endpointRealtime.startsWith('wss://')) { + throw new AppwriteException('Invalid realtime endpoint URL: ' + endpointRealtime); + } + this.config.endpointRealtime = endpointRealtime; return this; } diff --git a/src/enums/o-auth-provider.ts b/src/enums/o-auth-provider.ts index b2bf4d16..7a3fcb3f 100644 --- a/src/enums/o-auth-provider.ts +++ b/src/enums/o-auth-provider.ts @@ -13,6 +13,7 @@ export enum OAuthProvider { Dropbox = 'dropbox', Etsy = 'etsy', Facebook = 'facebook', + Figma = 'figma', Github = 'github', Gitlab = 'gitlab', Google = 'google', diff --git a/src/services/account.ts b/src/services/account.ts index 7c4927d5..bcd37339 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -28,7 +28,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -144,7 +143,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -207,7 +205,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -390,7 +387,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -409,7 +405,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -559,7 +554,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -696,7 +690,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -959,7 +952,6 @@ export class Account extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/databases.ts b/src/services/databases.ts index a6367fcb..23b0fad0 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -41,7 +41,6 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -131,7 +130,6 @@ export class Databases extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/functions.ts b/src/services/functions.ts index 89aa791a..d278537a 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -42,7 +42,6 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -122,7 +121,6 @@ export class Functions extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 6a99b833..6498bd98 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -30,7 +30,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -47,7 +46,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -64,7 +62,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -81,7 +78,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -98,7 +94,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -115,7 +110,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -133,7 +127,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -150,7 +143,6 @@ export class Locale extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 5101f7d8..3b1ac8a8 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -43,7 +43,6 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -185,7 +184,6 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } diff --git a/src/services/teams.ts b/src/services/teams.ts index 8eb69e1f..98e459f6 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -36,7 +36,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -98,7 +97,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -183,7 +181,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -286,7 +283,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } @@ -425,7 +421,6 @@ export class Teams extends Service { const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { - 'content-type': 'application/json', }, payload); } From 874739446d83f5796ee7699ddcd5d25284b13de6 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 10 May 2025 14:21:43 +0000 Subject: [PATCH 02/27] fix: bump dependencies to resolve PlatformConstants error with Expo 53 --- CHANGELOG.md | 6 +++++- docs/examples/account/create-anonymous-session.md | 2 +- docs/examples/account/create-email-password-session.md | 2 +- docs/examples/account/create-email-token.md | 2 +- docs/examples/account/create-j-w-t.md | 2 +- docs/examples/account/create-magic-u-r-l-token.md | 2 +- docs/examples/account/create-mfa-authenticator.md | 2 +- docs/examples/account/create-mfa-challenge.md | 2 +- docs/examples/account/create-mfa-recovery-codes.md | 2 +- docs/examples/account/create-o-auth2session.md | 2 +- docs/examples/account/create-o-auth2token.md | 2 +- docs/examples/account/create-phone-token.md | 2 +- docs/examples/account/create-phone-verification.md | 2 +- docs/examples/account/create-push-target.md | 2 +- docs/examples/account/create-recovery.md | 2 +- docs/examples/account/create-session.md | 2 +- docs/examples/account/create-verification.md | 2 +- docs/examples/account/create.md | 2 +- docs/examples/account/delete-identity.md | 2 +- docs/examples/account/delete-mfa-authenticator.md | 2 +- docs/examples/account/delete-push-target.md | 2 +- docs/examples/account/delete-session.md | 2 +- docs/examples/account/delete-sessions.md | 2 +- docs/examples/account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/get-prefs.md | 2 +- docs/examples/account/get-session.md | 2 +- docs/examples/account/get.md | 2 +- docs/examples/account/list-identities.md | 2 +- docs/examples/account/list-logs.md | 2 +- docs/examples/account/list-mfa-factors.md | 2 +- docs/examples/account/list-sessions.md | 2 +- docs/examples/account/update-email.md | 2 +- docs/examples/account/update-m-f-a.md | 2 +- docs/examples/account/update-magic-u-r-l-session.md | 2 +- docs/examples/account/update-mfa-authenticator.md | 2 +- docs/examples/account/update-mfa-challenge.md | 2 +- docs/examples/account/update-mfa-recovery-codes.md | 2 +- docs/examples/account/update-name.md | 2 +- docs/examples/account/update-password.md | 2 +- docs/examples/account/update-phone-session.md | 2 +- docs/examples/account/update-phone-verification.md | 2 +- docs/examples/account/update-phone.md | 2 +- docs/examples/account/update-prefs.md | 2 +- docs/examples/account/update-push-target.md | 2 +- docs/examples/account/update-recovery.md | 2 +- docs/examples/account/update-session.md | 2 +- docs/examples/account/update-status.md | 2 +- docs/examples/account/update-verification.md | 2 +- docs/examples/avatars/get-browser.md | 2 +- docs/examples/avatars/get-credit-card.md | 2 +- docs/examples/avatars/get-favicon.md | 2 +- docs/examples/avatars/get-flag.md | 2 +- docs/examples/avatars/get-image.md | 2 +- docs/examples/avatars/get-initials.md | 2 +- docs/examples/avatars/get-q-r.md | 2 +- docs/examples/databases/create-document.md | 2 +- docs/examples/databases/delete-document.md | 2 +- docs/examples/databases/get-document.md | 2 +- docs/examples/databases/list-documents.md | 2 +- docs/examples/databases/update-document.md | 2 +- docs/examples/functions/create-execution.md | 2 +- docs/examples/functions/get-execution.md | 2 +- docs/examples/functions/list-executions.md | 2 +- docs/examples/graphql/mutation.md | 2 +- docs/examples/graphql/query.md | 2 +- docs/examples/locale/get.md | 2 +- docs/examples/locale/list-codes.md | 2 +- docs/examples/locale/list-continents.md | 2 +- docs/examples/locale/list-countries-e-u.md | 2 +- docs/examples/locale/list-countries-phones.md | 2 +- docs/examples/locale/list-countries.md | 2 +- docs/examples/locale/list-currencies.md | 2 +- docs/examples/locale/list-languages.md | 2 +- docs/examples/messaging/create-subscriber.md | 2 +- docs/examples/messaging/delete-subscriber.md | 2 +- docs/examples/storage/create-file.md | 2 +- docs/examples/storage/delete-file.md | 2 +- docs/examples/storage/get-file-download.md | 2 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/storage/get-file-view.md | 2 +- docs/examples/storage/get-file.md | 2 +- docs/examples/storage/list-files.md | 2 +- docs/examples/storage/update-file.md | 2 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/create.md | 2 +- docs/examples/teams/delete-membership.md | 2 +- docs/examples/teams/delete.md | 2 +- docs/examples/teams/get-membership.md | 2 +- docs/examples/teams/get-prefs.md | 2 +- docs/examples/teams/get.md | 2 +- docs/examples/teams/list-memberships.md | 2 +- docs/examples/teams/list.md | 2 +- docs/examples/teams/update-membership-status.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/teams/update-name.md | 2 +- docs/examples/teams/update-prefs.md | 2 +- package.json | 6 +++--- src/client.ts | 2 +- src/services/databases.ts | 1 - 99 files changed, 104 insertions(+), 101 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21fbe545..82fe1022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,5 @@ -# Change log \ No newline at end of file +# Change log + +## 0.7.4 + +* Upgrade dependencies to resolve PlatformConstants error with Expo 53 diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index 333e1994..4baad33e 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 0718e393..217d7873 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index 13d08f0b..b9bdf3bb 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md index fd060c8c..217dc787 100644 --- a/docs/examples/account/create-j-w-t.md +++ b/docs/examples/account/create-j-w-t.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md index b627ca6c..413e347a 100644 --- a/docs/examples/account/create-magic-u-r-l-token.md +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index d34d9957..ec243490 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -1,7 +1,7 @@ import { Client, Account, AuthenticatorType } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index f5c94903..04de2586 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -1,7 +1,7 @@ import { Client, Account, AuthenticationFactor } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 66ec3680..f256be30 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-o-auth2session.md b/docs/examples/account/create-o-auth2session.md index 7dff5734..84bddb47 100644 --- a/docs/examples/account/create-o-auth2session.md +++ b/docs/examples/account/create-o-auth2session.md @@ -1,7 +1,7 @@ import { Client, Account, OAuthProvider } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md index 85ffb2a2..cd4ee86a 100644 --- a/docs/examples/account/create-o-auth2token.md +++ b/docs/examples/account/create-o-auth2token.md @@ -1,7 +1,7 @@ import { Client, Account, OAuthProvider } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index 33988887..d03e5ea4 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 39a33135..62bcc481 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-push-target.md b/docs/examples/account/create-push-target.md index da020dae..83211ab9 100644 --- a/docs/examples/account/create-push-target.md +++ b/docs/examples/account/create-push-target.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index c46c9079..802af82f 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 3c85dc8a..bb3040ae 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index cce3e1aa..5fdffcba 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index 5db3d7d9..eb3d04ac 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index c25a5a44..df492a52 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 5be2b161..093ba4d5 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -1,7 +1,7 @@ import { Client, Account, AuthenticatorType } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/delete-push-target.md b/docs/examples/account/delete-push-target.md index 34e89ab4..a926ede9 100644 --- a/docs/examples/account/delete-push-target.md +++ b/docs/examples/account/delete-push-target.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 60791284..134a2caa 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 67652f21..830eb273 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 06f09b8d..c660a17a 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index ef4185ca..b26a7b09 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index ca6cfb72..1db05d5c 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index cd5d50fe..21d24016 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 6189f80e..239dbbf2 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 48fe10be..9cf44145 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index ada7d487..51b76c90 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index cc081d5e..68232be2 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 5f879989..4bbe0b03 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md index 30f5f641..ebbfc0c8 100644 --- a/docs/examples/account/update-m-f-a.md +++ b/docs/examples/account/update-m-f-a.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); 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 a5b92765..c5e6b613 100644 --- a/docs/examples/account/update-magic-u-r-l-session.md +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index f3f3276d..07a798e7 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -1,7 +1,7 @@ import { Client, Account, AuthenticatorType } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index b26d387a..b93e0bf5 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 81d27f7c..2ed9bb02 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 47e5db98..adbbcab5 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index a37ee4c3..3bde58e6 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index d7098e51..c9c82696 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 582061fa..0ef7e53e 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index cc39c5ef..bf8aae2a 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 4478e023..01d4fd68 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-push-target.md b/docs/examples/account/update-push-target.md index 6871a101..d88e22e0 100644 --- a/docs/examples/account/update-push-target.md +++ b/docs/examples/account/update-push-target.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 73184b84..9a5ef04f 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 34bc567f..0c8a9e5d 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index 0b6ec6f7..8d3a2b06 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 9d00a482..c956d5fc 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,7 +1,7 @@ import { Client, Account } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const account = new Account(client); diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index bbcb0df8..6bb005e5 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,7 +1,7 @@ import { Client, Avatars, Browser } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index a97cc6c4..bdaaf8bf 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,7 +1,7 @@ import { Client, Avatars, CreditCard } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 067aa740..ff48c76f 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,7 +1,7 @@ import { Client, Avatars } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index f2268fcc..ac7aaf98 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,7 +1,7 @@ import { Client, Avatars, Flag } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 3816e7b4..006155ef 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,7 +1,7 @@ import { Client, Avatars } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index b8545b37..a87a6434 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,7 +1,7 @@ import { Client, Avatars } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 5c80c6ae..177759d9 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -1,7 +1,7 @@ import { Client, Avatars } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const avatars = new Avatars(client); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 58053ca0..1b28231e 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,7 +1,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index beeb7b2a..9136107a 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -1,7 +1,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index df2333b5..9993e2c9 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -1,7 +1,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 88d94a90..b2f377e5 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -1,7 +1,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 5021c0b0..7676ee10 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,7 +1,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 9933beb2..72c71f77 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,7 +1,7 @@ import { Client, Functions, ExecutionMethod } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const functions = new Functions(client); diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 79fffec4..848747ea 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,7 +1,7 @@ import { Client, Functions } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const functions = new Functions(client); diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 0615ecbf..6a1f5821 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,7 +1,7 @@ import { Client, Functions } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const functions = new Functions(client); diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 2fae4783..3292a5da 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -1,7 +1,7 @@ import { Client, Graphql } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const graphql = new Graphql(client); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 39d8cb13..a00c517a 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -1,7 +1,7 @@ import { Client, Graphql } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const graphql = new Graphql(client); diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 0d48cd85..34c1672c 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index f1466bee..29cec5a5 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index a813a69f..c98ba19a 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index 7ba7149e..7fb71a54 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 6d3093dc..612debc5 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 9ffb09b8..8b1f636f 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 06326651..4b96a5fd 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 1ef69e59..54166afb 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -1,7 +1,7 @@ import { Client, Locale } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const locale = new Locale(client); diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index 153cd2e3..c950e90b 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -1,7 +1,7 @@ import { Client, Messaging } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const messaging = new Messaging(client); diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index 6d61172a..5004b59c 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -1,7 +1,7 @@ import { Client, Messaging } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const messaging = new Messaging(client); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index f6e4f472..efbfd607 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 55aed16a..1a436ac8 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index b4b1374c..c8dcea3d 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 10d473ae..b41236f6 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,7 +1,7 @@ import { Client, Storage, ImageGravity, ImageFormat } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 1a544529..06443a89 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index bbbb3fe9..6d358ada 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 731a1d1e..19099b12 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index ba8cc606..d4ed68a3 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,7 +1,7 @@ import { Client, Storage } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const storage = new Storage(client); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c4fc5574..680fdb2a 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index c252f3df..51aaee35 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 683c92d1..37bdc7f8 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index dfd63fc9..fe67eaff 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 4e30d1bd..2b253c8b 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 40cffb12..943ed1a1 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index dc2d6cd4..9267b57e 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 7eabeeee..4444bcd6 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 64b9324d..779538a7 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 0e42de97..c8edbf08 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index e22fc975..347cbdd0 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 27447af3..0ab4aa1c 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index 02be2aca..fda16a05 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -1,7 +1,7 @@ import { Client, Teams } from "react-native-appwrite"; const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID const teams = new Teams(client); diff --git a/package.json b/package.json index 5ff33cff..d720f4a8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.7.3", + "version": "0.7.4", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { @@ -33,8 +33,8 @@ "typescript": "^5.3.3" }, "dependencies": { - "expo-file-system": "~18.0.11", - "react-native": "0.76.7" + "expo-file-system": "18.*.*", + "react-native": ">=0.76.7 <1.0.0" }, "peerDependencies": { "expo": "*", diff --git a/src/client.ts b/src/client.ts index fb3e96a5..13a71a62 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.7.3', + 'x-sdk-version': '0.7.4', 'X-Appwrite-Response-Format': '1.6.0', }; diff --git a/src/services/databases.ts b/src/services/databases.ts index 23b0fad0..1ec4dfe1 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -49,7 +49,6 @@ export class Databases extends Service { * collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) * API or directly from your database console. - * * * @param {string} databaseId * @param {string} collectionId From e9dccb6adeb1f8cafffb6e1251f4fe2b3e924959 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 10 May 2025 14:25:33 +0000 Subject: [PATCH 03/27] chore: update doc examples to use new multi region endpoint --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fe1022..37f0a0af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,3 +3,4 @@ ## 0.7.4 * Upgrade dependencies to resolve PlatformConstants error with Expo 53 +* Update doc examples to use new multi-region endpoint: `https://<REGION>.cloud.appwrite.io/v1` \ No newline at end of file From b3db6fbe0c1c7e81c3e51f2fa32055c00521575f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 10 May 2025 14:26:54 +0000 Subject: [PATCH 04/27] chore: fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f0a0af..0b2e2d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,4 @@ ## 0.7.4 * Upgrade dependencies to resolve PlatformConstants error with Expo 53 -* Update doc examples to use new multi-region endpoint: `https://<REGION>.cloud.appwrite.io/v1` \ No newline at end of file +* Update doc examples to use new multi-region endpoint: 'https://<REGION>.cloud.appwrite.io/v1' \ No newline at end of file From 442ed5e8d7eec4f80967ab43d4e2d2e6c9e1e051 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 10 May 2025 14:27:59 +0000 Subject: [PATCH 05/27] chore: fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b2e2d02..f720e11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,4 @@ ## 0.7.4 * Upgrade dependencies to resolve PlatformConstants error with Expo 53 -* Update doc examples to use new multi-region endpoint: 'https://<REGION>.cloud.appwrite.io/v1' \ No newline at end of file +* Update doc examples to use new multi-region endpoint \ No newline at end of file From 5cc1bf0d84585a3295458e37b295735315f4a2e8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 00:03:07 +1200 Subject: [PATCH 06/27] Add support for 1.7 --- README.md | 4 +-- docs/examples/avatars/get-browser.md | 2 +- docs/examples/avatars/get-credit-card.md | 2 +- docs/examples/avatars/get-flag.md | 2 +- docs/examples/databases/create-document.md | 4 ++- docs/examples/databases/create-documents.md | 15 ++++++++ docs/examples/functions/list-executions.md | 3 +- docs/examples/storage/get-file-download.md | 3 +- docs/examples/storage/get-file-preview.md | 5 +-- docs/examples/storage/get-file-view.md | 3 +- package.json | 2 +- src/client.ts | 4 +-- src/enums/image-format.ts | 1 - src/models.ts | 2 +- src/services/databases.ts | 38 +++++++++++++++++++++ src/services/functions.ts | 7 +--- src/services/storage.ts | 21 ++++++++++-- 17 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 docs/examples/databases/create-documents.md diff --git a/README.md b/README.md index 3f24ffcd..178a7c6e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.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.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/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 React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 6bb005e5..433cbe59 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -10,7 +10,7 @@ const result = avatars.getBrowser( Browser.AvantBrowser, // code 0, // width (optional) 0, // height (optional) - 0 // quality (optional) + -1 // quality (optional) ); console.log(result); diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index bdaaf8bf..bbd0007f 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -10,7 +10,7 @@ const result = avatars.getCreditCard( CreditCard.AmericanExpress, // code 0, // width (optional) 0, // height (optional) - 0 // quality (optional) + -1 // quality (optional) ); console.log(result); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index ac7aaf98..4e6070d1 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -10,7 +10,7 @@ const result = avatars.getFlag( Flag.Afghanistan, // code 0, // width (optional) 0, // height (optional) - 0 // quality (optional) + -1 // quality (optional) ); console.log(result); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 1b28231e..ec768fcf 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,7 +2,9 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID + .setSession('') // The user session to authenticate with + .setKey('') // + .setJWT(''); // Your secret JSON Web Token const databases = new Databases(client); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md new file mode 100644 index 00000000..08663b6d --- /dev/null +++ b/docs/examples/databases/create-documents.md @@ -0,0 +1,15 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setKey(''); // + +const databases = new Databases(client); + +const result = await databases.createDocuments( + '', // databaseId + '', // collectionId + [] // documents +); + +console.log(result); diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 6a1f5821..346f8c7e 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -8,8 +8,7 @@ const functions = new Functions(client); const result = await functions.listExecutions( '', // functionId - [], // queries (optional) - '' // search (optional) + [] // queries (optional) ); console.log(result); diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index c8dcea3d..e21bad67 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -8,7 +8,8 @@ const storage = new Storage(client); const result = storage.getFileDownload( '', // bucketId - '' // fileId + '', // fileId + '' // token (optional) ); console.log(result); diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index b41236f6..6f116c5d 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -12,14 +12,15 @@ const result = storage.getFilePreview( 0, // width (optional) 0, // height (optional) ImageGravity.Center, // gravity (optional) - 0, // quality (optional) + -1, // quality (optional) 0, // borderWidth (optional) '', // borderColor (optional) 0, // borderRadius (optional) 0, // opacity (optional) -360, // rotation (optional) '', // background (optional) - ImageFormat.Jpg // output (optional) + ImageFormat.Jpg, // output (optional) + '' // token (optional) ); console.log(result); diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 06443a89..9b229f6a 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -8,7 +8,8 @@ const storage = new Storage(client); const result = storage.getFileView( '', // bucketId - '' // fileId + '', // fileId + '' // token (optional) ); console.log(result); diff --git a/package.json b/package.json index d720f4a8..13bac548 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.7.4", + "version": "0.8.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 13a71a62..ad2e2527 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,8 +114,8 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.7.4', - 'X-Appwrite-Response-Format': '1.6.0', + 'x-sdk-version': '0.8.0', + 'X-Appwrite-Response-Format': '1.7.0', }; /** diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index bcbe3e93..5aad5f08 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -1,7 +1,6 @@ export enum ImageFormat { Jpg = 'jpg', Jpeg = 'jpeg', - Gif = 'gif', Png = 'png', Webp = 'webp', Heic = 'heic', diff --git a/src/models.ts b/src/models.ts index 02394388..f6db5fab 100644 --- a/src/models.ts +++ b/src/models.ts @@ -940,7 +940,7 @@ export namespace Models { */ errors: string; /** - * Function execution duration in seconds. + * Resource(function/site) execution duration in seconds. */ duration: number; /** diff --git a/src/services/databases.ts b/src/services/databases.ts index 1ec4dfe1..84be0215 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -96,6 +96,44 @@ export class Databases extends Service { }, payload); } + /** + * Create new Documents. Before using this route, you should create a new + * collection resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {object[]} documents + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. diff --git a/src/services/functions.ts b/src/services/functions.ts index d278537a..4f41fe09 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -20,11 +20,10 @@ export class Functions extends Service { * * @param {string} functionId * @param {string[]} queries - * @param {string} search * @throws {AppwriteException} * @returns {Promise} */ - listExecutions(functionId: string, queries?: string[], search?: string): Promise { + listExecutions(functionId: string, queries?: string[]): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } @@ -36,10 +35,6 @@ export class Functions extends Service { payload['queries'] = queries; } - if (typeof search !== 'undefined') { - payload['search'] = search; - } - const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('get', uri, { }, payload); diff --git a/src/services/storage.ts b/src/services/storage.ts index 3b1ac8a8..0df7865e 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -258,10 +258,11 @@ export class Storage extends Service { * * @param {string} bucketId * @param {string} fileId + * @param {string} token * @throws {AppwriteException} * @returns {URL} */ - getFileDownload(bucketId: string, fileId: string): URL { + getFileDownload(bucketId: string, fileId: string, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -273,6 +274,10 @@ export class Storage extends Service { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; + if (typeof token !== 'undefined') { + payload['token'] = token; + } + const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; @@ -303,10 +308,11 @@ export class Storage extends Service { * @param {number} rotation * @param {string} background * @param {ImageFormat} output + * @param {string} token * @throws {AppwriteException} * @returns {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 { + 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, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -362,6 +368,10 @@ export class Storage extends Service { payload['output'] = output; } + if (typeof token !== 'undefined') { + payload['token'] = token; + } + const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; @@ -379,10 +389,11 @@ export class Storage extends Service { * * @param {string} bucketId * @param {string} fileId + * @param {string} token * @throws {AppwriteException} * @returns {URL} */ - getFileView(bucketId: string, fileId: string): URL { + getFileView(bucketId: string, fileId: string, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -394,6 +405,10 @@ export class Storage extends Service { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; + if (typeof token !== 'undefined') { + payload['token'] = token; + } + const uri = new URL(this.client.config.endpoint + apiPath); payload['project'] = this.client.config.project; From 99acc2f6c8b43035305938e65ee36ec0f3545fba Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 02:04:08 +1200 Subject: [PATCH 07/27] Add 1.7 support --- docs/examples/databases/create-documents.md | 15 -------- src/services/databases.ts | 38 --------------------- 2 files changed, 53 deletions(-) delete mode 100644 docs/examples/databases/create-documents.md diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md deleted file mode 100644 index 08663b6d..00000000 --- a/docs/examples/databases/create-documents.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Databases } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setKey(''); // - -const databases = new Databases(client); - -const result = await databases.createDocuments( - '', // databaseId - '', // collectionId - [] // documents -); - -console.log(result); diff --git a/src/services/databases.ts b/src/services/databases.ts index 84be0215..1ec4dfe1 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -96,44 +96,6 @@ export class Databases extends Service { }, payload); } - /** - * Create new Documents. Before using this route, you should create a new - * collection resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {object[]} documents - * @throws {AppwriteException} - * @returns {Promise} - */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); - const payload: Payload = {}; - - if (typeof documents !== 'undefined') { - payload['documents'] = documents; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - /** * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. From ca2b06af713baf38f2b690c98670250abfb1995c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 May 2025 07:48:49 +0000 Subject: [PATCH 08/27] chore: bump to next major versions --- package.json | 2 +- src/client.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 13bac548..55f72634 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.8.0", + "version": "0.9.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index ad2e2527..bc3d647c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.8.0', + 'x-sdk-version': '0.9.0', 'X-Appwrite-Response-Format': '1.7.0', }; From f642ef15f9800fc93d57c54b29c2e211eeacd251 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 May 2025 06:50:33 +0000 Subject: [PATCH 09/27] feat: (breaking) methods to generate file URLs --- CHANGELOG.md | 7 + docs/examples/databases/create-document.md | 4 +- src/client.ts | 4 +- src/services/account.ts | 1 + src/services/avatars.ts | 333 +++++++++++++++++++-- src/services/databases.ts | 1 + src/services/functions.ts | 1 + src/services/graphql.ts | 1 + src/services/locale.ts | 1 + src/services/messaging.ts | 1 + src/services/storage.ts | 157 +++++++++- src/services/teams.ts | 1 + 12 files changed, 478 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f720e11a..1bc7d893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 0.9.0 + +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Update default `quality` for `getFilePreview` from 0 to -1 +* Remove `Gif` from ImageFormat enum +* Remove `search` param from `listExecutions` method + ## 0.7.4 * Upgrade dependencies to resolve PlatformConstants error with Expo 53 diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index ec768fcf..1b28231e 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/src/client.ts b/src/client.ts index bc3d647c..5c0799bd 100644 --- a/src/client.ts +++ b/src/client.ts @@ -416,7 +416,7 @@ class Client { } } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { + async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); @@ -469,6 +469,8 @@ class Client { if (response.headers.get('content-type')?.includes('application/json')) { data = await response.json(); + } else if (responseType === 'arrayBuffer') { + data = await response.arrayBuffer(); } else { data = { message: await response.text() diff --git a/src/services/account.ts b/src/services/account.ts index bcd37339..b48f2549 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1457,4 +1457,5 @@ export class Account extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 1d640843..8e2e20a7 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -33,9 +33,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): URL { + getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -62,7 +62,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -81,9 +82,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): URL { + getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -110,7 +111,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -121,9 +123,9 @@ export class Avatars extends Service { * * @param {string} url * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFavicon(url: string): URL { + getFavicon(url: string): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -142,7 +144,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -162,9 +165,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): URL { + getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -191,7 +194,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -211,9 +215,9 @@ export class Avatars extends Service { * @param {number} width * @param {number} height * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getImage(url: string, width?: number, height?: number): URL { + getImage(url: string, width?: number, height?: number): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -240,7 +244,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -266,9 +271,9 @@ export class Avatars extends Service { * @param {number} height * @param {string} background * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getInitials(name?: string, width?: number, height?: number, background?: string): URL { + getInitials(name?: string, width?: number, height?: number, background?: string): Promise { const apiPath = '/avatars/initials'; const payload: Payload = {}; @@ -295,7 +300,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -308,9 +314,9 @@ export class Avatars extends Service { * @param {number} margin * @param {boolean} download * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getQR(text: string, size?: number, margin?: number, download?: boolean): URL { + getQR(text: string, size?: number, margin?: number, download?: boolean): Promise { if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } @@ -341,6 +347,291 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); + } + + + /** + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user [GET + * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) + * endpoint. Use width, height and quality arguments to change the output + * settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * @param {Browser} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): Promise { + const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * The credit card endpoint will return you the icon of the credit card + * provider you need. Use width, height and quality arguments to change the + * output settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {CreditCard} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): Promise { + const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote + * website URL. + * + * This endpoint does not follow HTTP redirects. + * + * @param {string} url + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getFaviconURL(url: string): Promise { + const apiPath = '/avatars/favicon'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. Country codes + * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {Flag} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getFlagURL(code: Flag, width?: number, height?: number, quality?: number): Promise { + const apiPath = '/avatars/flags/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 400x400px. + * + * This endpoint does not follow HTTP redirects. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getImageURL(url: string, width?: number, height?: number): Promise { + const apiPath = '/avatars/image'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Use this endpoint to show your user initials avatar icon on your website or + * app. By default, this route will try to print your logged-in user name or + * email initials. You can also overwrite the user name if you pass the 'name' + * parameter. If no name is given and no user is logged, an empty avatar will + * be returned. + * + * You can use the color and background params to change the avatar colors. By + * default, a random theme will be selected. The random theme will persist for + * the user's initials when reloading the same theme will always return for + * the same initials. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {string} name + * @param {number} width + * @param {number} height + * @param {string} background + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getInitialsURL(name?: string, width?: number, height?: number, background?: string): Promise { + const apiPath = '/avatars/initials'; + const payload: Payload = {}; + + if (typeof name !== 'undefined') { + payload['name'] = name; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof background !== 'undefined') { + payload['background'] = background; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {boolean} download + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getQRURL(text: string, size?: number, margin?: number, download?: boolean): Promise { + const apiPath = '/avatars/qr'; + const payload: Payload = {}; + + if (typeof text !== 'undefined') { + payload['text'] = text; + } + + if (typeof size !== 'undefined') { + payload['size'] = size; + } + + if (typeof margin !== 'undefined') { + payload['margin'] = margin; + } + + if (typeof download !== 'undefined') { + payload['download'] = download; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); } }; diff --git a/src/services/databases.ts b/src/services/databases.ts index 1ec4dfe1..272d8bba 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -204,4 +204,5 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/functions.ts b/src/services/functions.ts index 4f41fe09..b2668c4d 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -118,4 +118,5 @@ export class Functions extends Service { return this.client.call('get', uri, { }, payload); } + }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index a24adaa4..89820038 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -64,4 +64,5 @@ export class Graphql extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 6498bd98..1937f5f9 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -145,4 +145,5 @@ export class Locale extends Service { return this.client.call('get', uri, { }, payload); } + }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 6e33b9ab..2c021b01 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -77,4 +77,5 @@ export class Messaging extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 0df7865e..fff9ce1d 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -260,9 +260,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFileDownload(bucketId: string, fileId: string, token?: string): URL { + getFileDownload(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -285,7 +285,8 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -310,9 +311,9 @@ export class Storage extends Service { * @param {ImageFormat} output * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - 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, token?: 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, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -379,7 +380,8 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -391,9 +393,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFileView(bucketId: string, fileId: string, token?: string): URL { + getFileView(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -416,6 +418,143 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); + } + + + /** + * Get a file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} bucketId + * @param {string} fileId + * @param {string} token + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getFileDownloadURL(bucketId: string, fileId: string, token?: string): Promise { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. Preview is + * supported only for image files smaller than 10MB. + * + * @param {string} bucketId + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {ImageGravity} gravity + * @param {number} quality + * @param {number} borderWidth + * @param {string} borderColor + * @param {number} borderRadius + * @param {number} opacity + * @param {number} rotation + * @param {string} background + * @param {ImageFormat} output + * @param {string} token + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getFilePreviewURL(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, token?: string): Promise { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof gravity !== 'undefined') { + payload['gravity'] = gravity; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + if (typeof borderWidth !== 'undefined') { + payload['borderWidth'] = borderWidth; + } + + if (typeof borderColor !== 'undefined') { + payload['borderColor'] = borderColor; + } + + if (typeof borderRadius !== 'undefined') { + payload['borderRadius'] = borderRadius; + } + + if (typeof opacity !== 'undefined') { + payload['opacity'] = opacity; + } + + if (typeof rotation !== 'undefined') { + payload['rotation'] = rotation; + } + + if (typeof background !== 'undefined') { + payload['background'] = background; + } + + if (typeof output !== 'undefined') { + payload['output'] = output; + } + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); + } + + /** + * Get a file content by its unique ID. This endpoint is similar to the + * download method but returns with no 'Content-Disposition: attachment' + * header. + * + * @param {string} bucketId + * @param {string} fileId + * @param {string} token + * @throws {AppwriteException} + * @returns ArrayBuffer + + */ + getFileViewURL(bucketId: string, fileId: string, token?: string): Promise { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return this.client.call('get', uri, { + }, payload); } }; diff --git a/src/services/teams.ts b/src/services/teams.ts index 98e459f6..d2a70f98 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -455,4 +455,5 @@ export class Teams extends Service { 'content-type': 'application/json', }, payload); } + }; From 9fa0199a10f2768fa392df94db7031e6275200aa Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 May 2025 11:43:07 +0000 Subject: [PATCH 10/27] fix: return types --- src/services/avatars.ts | 49 ++++++++++++++++++----------------------- src/services/storage.ts | 21 ++++++++---------- 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 8e2e20a7..f0784ed2 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -369,10 +369,10 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): Promise { + getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); const payload: Payload = {}; @@ -390,8 +390,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -410,10 +409,10 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): Promise { + getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); const payload: Payload = {}; @@ -431,8 +430,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -443,10 +441,10 @@ export class Avatars extends Service { * * @param {string} url * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getFaviconURL(url: string): Promise { + getFaviconURL(url: string): URL { const apiPath = '/avatars/favicon'; const payload: Payload = {}; @@ -456,8 +454,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -477,10 +474,10 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getFlagURL(code: Flag, width?: number, height?: number, quality?: number): Promise { + getFlagURL(code: Flag, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/flags/{code}'.replace('{code}', code); const payload: Payload = {}; @@ -498,8 +495,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -519,10 +515,10 @@ export class Avatars extends Service { * @param {number} width * @param {number} height * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getImageURL(url: string, width?: number, height?: number): Promise { + getImageURL(url: string, width?: number, height?: number): URL { const apiPath = '/avatars/image'; const payload: Payload = {}; @@ -540,8 +536,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -567,10 +562,10 @@ export class Avatars extends Service { * @param {number} height * @param {string} background * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getInitialsURL(name?: string, width?: number, height?: number, background?: string): Promise { + getInitialsURL(name?: string, width?: number, height?: number, background?: string): URL { const apiPath = '/avatars/initials'; const payload: Payload = {}; @@ -592,8 +587,7 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -606,10 +600,10 @@ export class Avatars extends Service { * @param {number} margin * @param {boolean} download * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getQRURL(text: string, size?: number, margin?: number, download?: boolean): Promise { + getQRURL(text: string, size?: number, margin?: number, download?: boolean): URL { const apiPath = '/avatars/qr'; const payload: Payload = {}; @@ -631,7 +625,6 @@ export class Avatars extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } }; diff --git a/src/services/storage.ts b/src/services/storage.ts index fff9ce1d..77ae2d8d 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -432,10 +432,10 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getFileDownloadURL(bucketId: string, fileId: string, token?: string): Promise { + getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; @@ -445,8 +445,7 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -471,10 +470,10 @@ export class Storage extends Service { * @param {ImageFormat} output * @param {string} token * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getFilePreviewURL(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, token?: string): Promise { + getFilePreviewURL(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, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; @@ -528,8 +527,7 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } /** @@ -541,10 +539,10 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns ArrayBuffer + * @returns {URL} */ - getFileViewURL(bucketId: string, fileId: string, token?: string): Promise { + getFileViewURL(bucketId: string, fileId: string, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); const payload: Payload = {}; @@ -554,7 +552,6 @@ export class Storage extends Service { const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); + return uri; } }; From 796d4611a370b81a4c2c367ef4e260929c575ef6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 05:14:47 +0000 Subject: [PATCH 11/27] chore: add setDevKey and upsertDocument methods --- docs/examples/databases/create-document.md | 4 +- docs/examples/databases/create-documents.md | 15 + package.json | 2 +- src/client.ts | 6 +- src/services/account.ts | 1 - src/services/avatars.ts | 324 ++------------------ src/services/databases.ts | 39 ++- src/services/functions.ts | 1 - src/services/graphql.ts | 1 - src/services/locale.ts | 1 - src/services/messaging.ts | 1 - src/services/storage.ts | 152 +-------- src/services/teams.ts | 1 - 13 files changed, 87 insertions(+), 461 deletions(-) create mode 100644 docs/examples/databases/create-documents.md diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 1b28231e..ec768fcf 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,7 +2,9 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID + .setSession('') // The user session to authenticate with + .setKey('') // + .setJWT(''); // Your secret JSON Web Token const databases = new Databases(client); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md new file mode 100644 index 00000000..08663b6d --- /dev/null +++ b/docs/examples/databases/create-documents.md @@ -0,0 +1,15 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setKey(''); // + +const databases = new Databases(client); + +const result = await databases.createDocuments( + '', // databaseId + '', // collectionId + [] // documents +); + +console.log(result); diff --git a/package.json b/package.json index 55f72634..690e55c4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.9.0", + "version": "0.9.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 5c0799bd..2d41c2b8 100644 --- a/src/client.ts +++ b/src/client.ts @@ -114,7 +114,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.9.0', + 'x-sdk-version': '0.9.1', 'X-Appwrite-Response-Format': '1.7.0', }; @@ -416,7 +416,7 @@ class Client { } } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { + async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); @@ -469,8 +469,6 @@ class Client { if (response.headers.get('content-type')?.includes('application/json')) { data = await response.json(); - } else if (responseType === 'arrayBuffer') { - data = await response.arrayBuffer(); } else { data = { message: await response.text() diff --git a/src/services/account.ts b/src/services/account.ts index b48f2549..bcd37339 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1457,5 +1457,4 @@ export class Account extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index f0784ed2..1d640843 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -33,9 +33,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise { + getBrowser(code: Browser, width?: number, height?: number, quality?: number): URL { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -62,8 +62,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -82,9 +81,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise { + getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): URL { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -111,8 +110,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -123,9 +121,9 @@ export class Avatars extends Service { * * @param {string} url * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getFavicon(url: string): Promise { + getFavicon(url: string): URL { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -144,8 +142,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -165,9 +162,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise { + getFlag(code: Flag, width?: number, height?: number, quality?: number): URL { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -194,8 +191,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -215,9 +211,9 @@ export class Avatars extends Service { * @param {number} width * @param {number} height * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getImage(url: string, width?: number, height?: number): Promise { + getImage(url: string, width?: number, height?: number): URL { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -244,8 +240,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -271,9 +266,9 @@ export class Avatars extends Service { * @param {number} height * @param {string} background * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getInitials(name?: string, width?: number, height?: number, background?: string): Promise { + getInitials(name?: string, width?: number, height?: number, background?: string): URL { const apiPath = '/avatars/initials'; const payload: Payload = {}; @@ -300,8 +295,7 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -314,9 +308,9 @@ export class Avatars extends Service { * @param {number} margin * @param {boolean} download * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getQR(text: string, size?: number, margin?: number, download?: boolean): Promise { + getQR(text: string, size?: number, margin?: number, download?: boolean): URL { if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } @@ -347,284 +341,6 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); - } - - - /** - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user [GET - * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) - * endpoint. Use width, height and quality arguments to change the output - * settings. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * @param {Browser} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - - */ - getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): URL { - const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); - const payload: Payload = {}; - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - if (typeof quality !== 'undefined') { - payload['quality'] = quality; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * The credit card endpoint will return you the icon of the credit card - * provider you need. Use width, height and quality arguments to change the - * output settings. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {CreditCard} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - - */ - getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): URL { - const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); - const payload: Payload = {}; - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - if (typeof quality !== 'undefined') { - payload['quality'] = quality; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote - * website URL. - * - * This endpoint does not follow HTTP redirects. - * - * @param {string} url - * @throws {AppwriteException} - * @returns {URL} - - */ - getFaviconURL(url: string): URL { - const apiPath = '/avatars/favicon'; - const payload: Payload = {}; - - if (typeof url !== 'undefined') { - payload['url'] = url; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. Country codes - * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {Flag} code - * @param {number} width - * @param {number} height - * @param {number} quality - * @throws {AppwriteException} - * @returns {URL} - - */ - getFlagURL(code: Flag, width?: number, height?: number, quality?: number): URL { - const apiPath = '/avatars/flags/{code}'.replace('{code}', code); - const payload: Payload = {}; - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - if (typeof quality !== 'undefined') { - payload['quality'] = quality; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 400x400px. - * - * This endpoint does not follow HTTP redirects. - * - * @param {string} url - * @param {number} width - * @param {number} height - * @throws {AppwriteException} - * @returns {URL} - - */ - getImageURL(url: string, width?: number, height?: number): URL { - const apiPath = '/avatars/image'; - const payload: Payload = {}; - - if (typeof url !== 'undefined') { - payload['url'] = url; - } - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * - * - * @param {string} name - * @param {number} width - * @param {number} height - * @param {string} background - * @throws {AppwriteException} - * @returns {URL} - - */ - getInitialsURL(name?: string, width?: number, height?: number, background?: string): URL { - const apiPath = '/avatars/initials'; - const payload: Payload = {}; - - if (typeof name !== 'undefined') { - payload['name'] = name; - } - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - if (typeof background !== 'undefined') { - payload['background'] = background; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * - * - * @param {string} text - * @param {number} size - * @param {number} margin - * @param {boolean} download - * @throws {AppwriteException} - * @returns {URL} - - */ - getQRURL(text: string, size?: number, margin?: number, download?: boolean): URL { - const apiPath = '/avatars/qr'; - const payload: Payload = {}; - - if (typeof text !== 'undefined') { - payload['text'] = text; - } - - if (typeof size !== 'undefined') { - payload['size'] = size; - } - - if (typeof margin !== 'undefined') { - payload['margin'] = margin; - } - - if (typeof download !== 'undefined') { - payload['download'] = download; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return uri; } }; diff --git a/src/services/databases.ts b/src/services/databases.ts index 272d8bba..84be0215 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -96,6 +96,44 @@ export class Databases extends Service { }, payload); } + /** + * Create new Documents. Before using this route, you should create a new + * collection resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {object[]} documents + * @throws {AppwriteException} + * @returns {Promise} + */ + createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + /** * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. @@ -204,5 +242,4 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/functions.ts b/src/services/functions.ts index b2668c4d..4f41fe09 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -118,5 +118,4 @@ export class Functions extends Service { return this.client.call('get', uri, { }, payload); } - }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 89820038..a24adaa4 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -64,5 +64,4 @@ export class Graphql extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 1937f5f9..6498bd98 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -145,5 +145,4 @@ export class Locale extends Service { return this.client.call('get', uri, { }, payload); } - }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2c021b01..6e33b9ab 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -77,5 +77,4 @@ export class Messaging extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 77ae2d8d..0df7865e 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -260,9 +260,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getFileDownload(bucketId: string, fileId: string, token?: string): Promise { + getFileDownload(bucketId: string, fileId: string, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -285,8 +285,7 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -311,9 +310,9 @@ export class Storage extends Service { * @param {ImageFormat} output * @param {string} token * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {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, token?: string): Promise { + 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, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -380,8 +379,7 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); + return uri; } /** @@ -393,9 +391,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {ArrayBuffer} + * @returns {URL} */ - getFileView(bucketId: string, fileId: string, token?: string): Promise { + getFileView(bucketId: string, fileId: string, token?: string): URL { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -418,140 +416,6 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return this.client.call('get', uri, { - }, payload, 'arrayBuffer'); - } - - - /** - * Get a file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. - * - * @param {string} bucketId - * @param {string} fileId - * @param {string} token - * @throws {AppwriteException} - * @returns {URL} - - */ - getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL { - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; - - if (typeof token !== 'undefined') { - payload['token'] = token; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. Preview is - * supported only for image files smaller than 10MB. - * - * @param {string} bucketId - * @param {string} fileId - * @param {number} width - * @param {number} height - * @param {ImageGravity} gravity - * @param {number} quality - * @param {number} borderWidth - * @param {string} borderColor - * @param {number} borderRadius - * @param {number} opacity - * @param {number} rotation - * @param {string} background - * @param {ImageFormat} output - * @param {string} token - * @throws {AppwriteException} - * @returns {URL} - - */ - getFilePreviewURL(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, token?: string): URL { - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; - - if (typeof width !== 'undefined') { - payload['width'] = width; - } - - if (typeof height !== 'undefined') { - payload['height'] = height; - } - - if (typeof gravity !== 'undefined') { - payload['gravity'] = gravity; - } - - if (typeof quality !== 'undefined') { - payload['quality'] = quality; - } - - if (typeof borderWidth !== 'undefined') { - payload['borderWidth'] = borderWidth; - } - - if (typeof borderColor !== 'undefined') { - payload['borderColor'] = borderColor; - } - - if (typeof borderRadius !== 'undefined') { - payload['borderRadius'] = borderRadius; - } - - if (typeof opacity !== 'undefined') { - payload['opacity'] = opacity; - } - - if (typeof rotation !== 'undefined') { - payload['rotation'] = rotation; - } - - if (typeof background !== 'undefined') { - payload['background'] = background; - } - - if (typeof output !== 'undefined') { - payload['output'] = output; - } - - if (typeof token !== 'undefined') { - payload['token'] = token; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - - return uri; - } - - /** - * Get a file content by its unique ID. This endpoint is similar to the - * download method but returns with no 'Content-Disposition: attachment' - * header. - * - * @param {string} bucketId - * @param {string} fileId - * @param {string} token - * @throws {AppwriteException} - * @returns {URL} - - */ - getFileViewURL(bucketId: string, fileId: string, token?: string): URL { - const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); - const payload: Payload = {}; - - if (typeof token !== 'undefined') { - payload['token'] = token; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return uri; } }; diff --git a/src/services/teams.ts b/src/services/teams.ts index d2a70f98..98e459f6 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -455,5 +455,4 @@ export class Teams extends Service { 'content-type': 'application/json', }, payload); } - }; From f63e97186204ec54ede757a34644f9117f5c4c7f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 05:16:42 +0000 Subject: [PATCH 12/27] chore: add setDevkey and upsertDocument methods --- ...create-documents.md => upsert-document.md} | 8 +-- src/client.ts | 16 ++++++ src/services/databases.ts | 50 +++++++++++-------- 3 files changed, 51 insertions(+), 23 deletions(-) rename docs/examples/databases/{create-documents.md => upsert-document.md} (60%) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/upsert-document.md similarity index 60% rename from docs/examples/databases/create-documents.md rename to docs/examples/databases/upsert-document.md index 08663b6d..ae423d12 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/upsert-document.md @@ -2,14 +2,16 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setKey(''); // + .setProject(''); // Your project ID const databases = new Databases(client); -const result = await databases.createDocuments( +const result = await databases.upsertDocument( '', // databaseId '', // collectionId - [] // documents + '', // documentId + {}, // data + ["read("any")"] // permissions (optional) ); console.log(result); diff --git a/src/client.ts b/src/client.ts index 2d41c2b8..ccddc76d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -108,6 +108,7 @@ class Client { jwt: '', locale: '', session: '', + devkey: '', platform: '', }; headers: Headers = { @@ -226,6 +227,21 @@ class Client { return this; } + /** + * Set DevKey + * + * Your secret dev API key + * + * @param value string + * + * @return {this} + */ + setDevKey(value: string): this { + this.headers['X-Appwrite-Dev-Key'] = value; + this.config.devkey = value; + return this; + } + private realtime: Realtime = { socket: undefined, diff --git a/src/services/databases.ts b/src/services/databases.ts index 84be0215..e8bb0ab8 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -97,18 +97,17 @@ export class Databases extends Service { } /** - * Create new Documents. Before using this route, you should create a new - * collection resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) - * API or directly from your database console. + * Get a document by its unique ID. This endpoint response returns a JSON + * object with the document data. * * @param {string} databaseId * @param {string} collectionId - * @param {object[]} documents + * @param {string} documentId + * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} */ - createDocuments(databaseId: string, collectionId: string, documents: object[]): Promise> { + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -117,35 +116,37 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "collectionId"'); } - if (typeof documents === 'undefined') { - throw new AppwriteException('Missing required parameter: "documents"'); + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); } - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; - if (typeof documents !== 'undefined') { - payload['documents'] = documents; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; } const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', + return this.client.call('get', uri, { }, payload); } /** - * Get a document by its unique ID. This endpoint response returns a JSON - * object with the document data. + * Create or update a Document. Before using this route, you should create a + * new collection resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + * API or directly from your database console. * * @param {string} databaseId * @param {string} collectionId * @param {string} documentId - * @param {string[]} queries + * @param {object} data + * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { + upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -158,15 +159,24 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "documentId"'); } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; - if (typeof queries !== 'undefined') { - payload['queries'] = queries; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; } const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { + return this.client.call('put', uri, { + 'content-type': 'application/json', }, payload); } From b1a5857cd1bce2e5ebea5331474868dcd16b6618 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 14:36:00 +0000 Subject: [PATCH 13/27] fix: remove credentials when devKeys is set --- package.json | 2 +- src/client.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 690e55c4..cd6bfdae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.9.1", + "version": "0.9.2", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index ccddc76d..49e675b4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.9.1', + 'x-sdk-version': '0.9.2', 'X-Appwrite-Response-Format': '1.7.0', }; @@ -441,9 +441,12 @@ class Client { let options: RequestInit = { method, headers, - credentials: 'include' }; + if (headers['X-Appwrite-Dev-Key'] === undefined) { + options.credentials = 'include'; + } + if (method === 'GET') { for (const [key, value] of Object.entries(Service.flatten(params))) { url.searchParams.append(key, value); From 686550b47d5c774ae674c2d39f475c7830c5d4b4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Jun 2025 07:59:26 +0000 Subject: [PATCH 14/27] chore: regenerate sdk --- README.md | 2 +- package.json | 2 +- src/client.ts | 6 +- src/services/account.ts | 1 + src/services/avatars.ts | 324 +++++++++++++++++++++++++++++++++++--- src/services/databases.ts | 1 + src/services/functions.ts | 1 + src/services/graphql.ts | 1 + src/services/locale.ts | 1 + src/services/messaging.ts | 1 + src/services/storage.ts | 152 +++++++++++++++++- src/services/teams.ts | 1 + 12 files changed, 461 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 178a7c6e..542c5c3e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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) diff --git a/package.json b/package.json index cd6bfdae..690e55c4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.9.2", + "version": "0.9.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 49e675b4..d3908252 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.9.2', + 'x-sdk-version': '0.9.1', 'X-Appwrite-Response-Format': '1.7.0', }; @@ -432,7 +432,7 @@ class Client { } } - async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise { + async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise { method = method.toUpperCase(); headers = Object.assign({}, this.headers, headers); @@ -488,6 +488,8 @@ class Client { if (response.headers.get('content-type')?.includes('application/json')) { data = await response.json(); + } else if (responseType === 'arrayBuffer') { + data = await response.arrayBuffer(); } else { data = { message: await response.text() diff --git a/src/services/account.ts b/src/services/account.ts index bcd37339..b48f2549 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1457,4 +1457,5 @@ export class Account extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 1d640843..f0784ed2 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -33,9 +33,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getBrowser(code: Browser, width?: number, height?: number, quality?: number): URL { + getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -62,7 +62,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -81,9 +82,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): URL { + getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -110,7 +111,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -121,9 +123,9 @@ export class Avatars extends Service { * * @param {string} url * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFavicon(url: string): URL { + getFavicon(url: string): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -142,7 +144,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -162,9 +165,9 @@ export class Avatars extends Service { * @param {number} height * @param {number} quality * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFlag(code: Flag, width?: number, height?: number, quality?: number): URL { + getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); } @@ -191,7 +194,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -211,9 +215,9 @@ export class Avatars extends Service { * @param {number} width * @param {number} height * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getImage(url: string, width?: number, height?: number): URL { + getImage(url: string, width?: number, height?: number): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); } @@ -240,7 +244,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -266,9 +271,9 @@ export class Avatars extends Service { * @param {number} height * @param {string} background * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getInitials(name?: string, width?: number, height?: number, background?: string): URL { + getInitials(name?: string, width?: number, height?: number, background?: string): Promise { const apiPath = '/avatars/initials'; const payload: Payload = {}; @@ -295,7 +300,8 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -308,9 +314,9 @@ export class Avatars extends Service { * @param {number} margin * @param {boolean} download * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getQR(text: string, size?: number, margin?: number, download?: boolean): URL { + getQR(text: string, size?: number, margin?: number, download?: boolean): Promise { if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); } @@ -341,6 +347,284 @@ export class Avatars extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); + } + + + /** + * You can use this endpoint to show different browser icons to your users. + * The code argument receives the browser code as it appears in your user [GET + * /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) + * endpoint. Use width, height and quality arguments to change the output + * settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * @param {Browser} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + + */ + getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): URL { + const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * The credit card endpoint will return you the icon of the credit card + * provider you need. Use width, height and quality arguments to change the + * output settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {CreditCard} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + + */ + getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): URL { + const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote + * website URL. + * + * This endpoint does not follow HTTP redirects. + * + * @param {string} url + * @throws {AppwriteException} + * @returns {URL} + + */ + getFaviconURL(url: string): URL { + const apiPath = '/avatars/favicon'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * You can use this endpoint to show different country flags icons to your + * users. The code argument receives the 2 letter country code. Use width, + * height and quality arguments to change the output settings. Country codes + * follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {Flag} code + * @param {number} width + * @param {number} height + * @param {number} quality + * @throws {AppwriteException} + * @returns {URL} + + */ + getFlagURL(code: Flag, width?: number, height?: number, quality?: number): URL { + const apiPath = '/avatars/flags/{code}'.replace('{code}', code); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Use this endpoint to fetch a remote image URL and crop it to any image size + * you want. This endpoint is very useful if you need to crop and display + * remote images in your app or in case you want to make sure a 3rd party + * image is properly served using a TLS protocol. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 400x400px. + * + * This endpoint does not follow HTTP redirects. + * + * @param {string} url + * @param {number} width + * @param {number} height + * @throws {AppwriteException} + * @returns {URL} + + */ + getImageURL(url: string, width?: number, height?: number): URL { + const apiPath = '/avatars/image'; + const payload: Payload = {}; + + if (typeof url !== 'undefined') { + payload['url'] = url; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Use this endpoint to show your user initials avatar icon on your website or + * app. By default, this route will try to print your logged-in user name or + * email initials. You can also overwrite the user name if you pass the 'name' + * parameter. If no name is given and no user is logged, an empty avatar will + * be returned. + * + * You can use the color and background params to change the avatar colors. By + * default, a random theme will be selected. The random theme will persist for + * the user's initials when reloading the same theme will always return for + * the same initials. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * + * + * @param {string} name + * @param {number} width + * @param {number} height + * @param {string} background + * @throws {AppwriteException} + * @returns {URL} + + */ + getInitialsURL(name?: string, width?: number, height?: number, background?: string): URL { + const apiPath = '/avatars/initials'; + const payload: Payload = {}; + + if (typeof name !== 'undefined') { + payload['name'] = name; + } + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof background !== 'undefined') { + payload['background'] = background; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Converts a given plain text to a QR code image. You can use the query + * parameters to change the size and style of the resulting image. + * + * + * @param {string} text + * @param {number} size + * @param {number} margin + * @param {boolean} download + * @throws {AppwriteException} + * @returns {URL} + + */ + getQRURL(text: string, size?: number, margin?: number, download?: boolean): URL { + const apiPath = '/avatars/qr'; + const payload: Payload = {}; + + if (typeof text !== 'undefined') { + payload['text'] = text; + } + + if (typeof size !== 'undefined') { + payload['size'] = size; + } + + if (typeof margin !== 'undefined') { + payload['margin'] = margin; + } + + if (typeof download !== 'undefined') { + payload['download'] = download; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return uri; } }; diff --git a/src/services/databases.ts b/src/services/databases.ts index e8bb0ab8..ac0ce85c 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -252,4 +252,5 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/functions.ts b/src/services/functions.ts index 4f41fe09..b2668c4d 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -118,4 +118,5 @@ export class Functions extends Service { return this.client.call('get', uri, { }, payload); } + }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index a24adaa4..89820038 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -64,4 +64,5 @@ export class Graphql extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 6498bd98..1937f5f9 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -145,4 +145,5 @@ export class Locale extends Service { return this.client.call('get', uri, { }, payload); } + }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 6e33b9ab..2c021b01 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -77,4 +77,5 @@ export class Messaging extends Service { 'content-type': 'application/json', }, payload); } + }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 0df7865e..77ae2d8d 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -260,9 +260,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFileDownload(bucketId: string, fileId: string, token?: string): URL { + getFileDownload(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -285,7 +285,8 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -310,9 +311,9 @@ export class Storage extends Service { * @param {ImageFormat} output * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - 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, token?: 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, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -379,7 +380,8 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } - return uri; + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); } /** @@ -391,9 +393,9 @@ export class Storage extends Service { * @param {string} fileId * @param {string} token * @throws {AppwriteException} - * @returns {URL} + * @returns {ArrayBuffer} */ - getFileView(bucketId: string, fileId: string, token?: string): URL { + getFileView(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); } @@ -416,6 +418,140 @@ export class Storage extends Service { for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); } + return this.client.call('get', uri, { + }, payload, 'arrayBuffer'); + } + + + /** + * Get a file content by its unique ID. The endpoint response return with a + * 'Content-Disposition: attachment' header that tells the browser to start + * downloading the file to user downloads directory. + * + * @param {string} bucketId + * @param {string} fileId + * @param {string} token + * @throws {AppwriteException} + * @returns {URL} + + */ + getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Get a file preview image. Currently, this method supports preview for image + * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, + * and spreadsheets, will return the file icon image. You can also pass query + * string arguments for cutting and resizing your preview image. Preview is + * supported only for image files smaller than 10MB. + * + * @param {string} bucketId + * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {ImageGravity} gravity + * @param {number} quality + * @param {number} borderWidth + * @param {string} borderColor + * @param {number} borderRadius + * @param {number} opacity + * @param {number} rotation + * @param {string} background + * @param {ImageFormat} output + * @param {string} token + * @throws {AppwriteException} + * @returns {URL} + + */ + getFilePreviewURL(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, token?: string): URL { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof width !== 'undefined') { + payload['width'] = width; + } + + if (typeof height !== 'undefined') { + payload['height'] = height; + } + + if (typeof gravity !== 'undefined') { + payload['gravity'] = gravity; + } + + if (typeof quality !== 'undefined') { + payload['quality'] = quality; + } + + if (typeof borderWidth !== 'undefined') { + payload['borderWidth'] = borderWidth; + } + + if (typeof borderColor !== 'undefined') { + payload['borderColor'] = borderColor; + } + + if (typeof borderRadius !== 'undefined') { + payload['borderRadius'] = borderRadius; + } + + if (typeof opacity !== 'undefined') { + payload['opacity'] = opacity; + } + + if (typeof rotation !== 'undefined') { + payload['rotation'] = rotation; + } + + if (typeof background !== 'undefined') { + payload['background'] = background; + } + + if (typeof output !== 'undefined') { + payload['output'] = output; + } + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + + return uri; + } + + /** + * Get a file content by its unique ID. This endpoint is similar to the + * download method but returns with no 'Content-Disposition: attachment' + * header. + * + * @param {string} bucketId + * @param {string} fileId + * @param {string} token + * @throws {AppwriteException} + * @returns {URL} + + */ + getFileViewURL(bucketId: string, fileId: string, token?: string): URL { + const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + + if (typeof token !== 'undefined') { + payload['token'] = token; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return uri; } }; diff --git a/src/services/teams.ts b/src/services/teams.ts index 98e459f6..d2a70f98 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -455,4 +455,5 @@ export class Teams extends Service { 'content-type': 'application/json', }, payload); } + }; From 5a6a99840e77c75545fa43fc13999dcd651afbf7 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Jun 2025 08:07:57 +0000 Subject: [PATCH 15/27] chore: fix formatting --- package.json | 2 +- src/client.ts | 2 +- src/services/account.ts | 1 - src/services/avatars.ts | 8 -------- src/services/databases.ts | 1 - src/services/functions.ts | 1 - src/services/graphql.ts | 1 - src/services/locale.ts | 1 - src/services/messaging.ts | 1 - src/services/storage.ts | 4 ---- src/services/teams.ts | 1 - 11 files changed, 2 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 690e55c4..ebce0e85 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.9.1", + "version": "0.10.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index d3908252..481c7a0f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.9.1', + 'x-sdk-version': '0.10.0', 'X-Appwrite-Response-Format': '1.7.0', }; diff --git a/src/services/account.ts b/src/services/account.ts index b48f2549..bcd37339 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1457,5 +1457,4 @@ export class Account extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index f0784ed2..5795bfce 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -351,7 +351,6 @@ export class Avatars extends Service { }, payload, 'arrayBuffer'); } - /** * You can use this endpoint to show different browser icons to your users. * The code argument receives the browser code as it appears in your user [GET @@ -370,7 +369,6 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {URL} - */ getBrowserURL(code: Browser, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/browsers/{code}'.replace('{code}', code); @@ -410,7 +408,6 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {URL} - */ getCreditCardURL(code: CreditCard, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code); @@ -442,7 +439,6 @@ export class Avatars extends Service { * @param {string} url * @throws {AppwriteException} * @returns {URL} - */ getFaviconURL(url: string): URL { const apiPath = '/avatars/favicon'; @@ -475,7 +471,6 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {URL} - */ getFlagURL(code: Flag, width?: number, height?: number, quality?: number): URL { const apiPath = '/avatars/flags/{code}'.replace('{code}', code); @@ -516,7 +511,6 @@ export class Avatars extends Service { * @param {number} height * @throws {AppwriteException} * @returns {URL} - */ getImageURL(url: string, width?: number, height?: number): URL { const apiPath = '/avatars/image'; @@ -563,7 +557,6 @@ export class Avatars extends Service { * @param {string} background * @throws {AppwriteException} * @returns {URL} - */ getInitialsURL(name?: string, width?: number, height?: number, background?: string): URL { const apiPath = '/avatars/initials'; @@ -601,7 +594,6 @@ export class Avatars extends Service { * @param {boolean} download * @throws {AppwriteException} * @returns {URL} - */ getQRURL(text: string, size?: number, margin?: number, download?: boolean): URL { const apiPath = '/avatars/qr'; diff --git a/src/services/databases.ts b/src/services/databases.ts index ac0ce85c..e8bb0ab8 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -252,5 +252,4 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/functions.ts b/src/services/functions.ts index b2668c4d..4f41fe09 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -118,5 +118,4 @@ export class Functions extends Service { return this.client.call('get', uri, { }, payload); } - }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index 89820038..a24adaa4 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -64,5 +64,4 @@ export class Graphql extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/locale.ts b/src/services/locale.ts index 1937f5f9..6498bd98 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -145,5 +145,4 @@ export class Locale extends Service { return this.client.call('get', uri, { }, payload); } - }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 2c021b01..6e33b9ab 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -77,5 +77,4 @@ export class Messaging extends Service { 'content-type': 'application/json', }, payload); } - }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 77ae2d8d..e574d6bc 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -422,7 +422,6 @@ export class Storage extends Service { }, payload, 'arrayBuffer'); } - /** * Get a file content by its unique ID. The endpoint response return with a * 'Content-Disposition: attachment' header that tells the browser to start @@ -433,7 +432,6 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {URL} - */ getFileDownloadURL(bucketId: string, fileId: string, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); @@ -471,7 +469,6 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {URL} - */ getFilePreviewURL(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, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); @@ -540,7 +537,6 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {URL} - */ getFileViewURL(bucketId: string, fileId: string, token?: string): URL { const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); diff --git a/src/services/teams.ts b/src/services/teams.ts index d2a70f98..98e459f6 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -455,5 +455,4 @@ export class Teams extends Service { 'content-type': 'application/json', }, payload); } - }; From 1068161afeda3ca950765ac45f161e6a7b825bac Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Jun 2025 08:14:10 +0000 Subject: [PATCH 16/27] chore: add changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bc7d893..56e176f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Change log +## 0.10.0 + +* Add generate file URL methods like`getFilePreviewURL`, `getFileViewURL` etc. +* Update (breaking) existing methods like `getFilePreview` to download the image instead of returning URLs + +## 0.9.2 + +* Fix `devKeys` by removing credentials from requests when the key is set + +## 0.9.1 + +* Add `setDevkey` and `upsertDocument` methods + ## 0.9.0 * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage From 12e5af7e8ac3ab49d4b67c9ee156bd37c44918de Mon Sep 17 00:00:00 2001 From: root Date: Sat, 12 Jul 2025 06:30:50 +0000 Subject: [PATCH 17/27] fix: add uri searchParams to URL based methods --- package.json | 2 +- src/client.ts | 2 +- src/enums/image-format.ts | 1 + src/services/avatars.ts | 35 +++++++++++++++++++++++++++++++++++ src/services/databases.ts | 4 ++++ src/services/storage.ts | 15 +++++++++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ebce0e85..c4717855 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.10.0", + "version": "0.10.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 481c7a0f..b404254b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.10.0', + 'x-sdk-version': '0.10.1', 'X-Appwrite-Response-Format': '1.7.0', }; diff --git a/src/enums/image-format.ts b/src/enums/image-format.ts index 5aad5f08..758fad74 100644 --- a/src/enums/image-format.ts +++ b/src/enums/image-format.ts @@ -5,4 +5,5 @@ export enum ImageFormat { Webp = 'webp', Heic = 'heic', Avif = 'avif', + Gif = 'gif', } \ No newline at end of file diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 5795bfce..85952b13 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -387,6 +387,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -426,6 +431,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -449,6 +459,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -489,6 +504,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -529,6 +549,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -579,6 +604,11 @@ export class Avatars extends Service { } 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); + } return uri; } @@ -616,6 +646,11 @@ export class Avatars extends Service { } 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); + } return uri; } diff --git a/src/services/databases.ts b/src/services/databases.ts index e8bb0ab8..09186833 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -133,6 +133,10 @@ export class Databases extends Service { } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Create or update a Document. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) diff --git a/src/services/storage.ts b/src/services/storage.ts index e574d6bc..e40614aa 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -442,6 +442,11 @@ export class Storage extends Service { } 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); + } return uri; } @@ -523,6 +528,11 @@ export class Storage extends Service { } 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); + } return uri; } @@ -547,6 +557,11 @@ export class Storage extends Service { } 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); + } return uri; } From 1883cbeefe53c47e3df3bad86495e17c55d15b3a Mon Sep 17 00:00:00 2001 From: root Date: Sat, 12 Jul 2025 06:33:40 +0000 Subject: [PATCH 18/27] chore: add changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e176f0..6ab2975b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log +## 0.10.1 + +* Fix URL based methods like `getFileViewURL`, `getFilePreviewURL` etc. by adding the missing `projectId` to searchParams +* Add `gif` to ImageFormat enum + ## 0.10.0 * Add generate file URL methods like`getFilePreviewURL`, `getFileViewURL` etc. From bed892b5674b975a8e0a3773c6f32d15c0239d94 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 14 Jul 2025 18:01:24 +0200 Subject: [PATCH 19/27] ci: fix npm token --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7817726..9e8e7165 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,4 +39,4 @@ jobs: - name: Publish run: npm publish --tag ${{ steps.release_tag.outputs.tag }} env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }} From b38c15af084ba80e7e8ba435e117d4e341c8916c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:48:37 +1200 Subject: [PATCH 20/27] Add inc/dec --- .github/workflows/publish.yml | 2 +- docs/examples/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 18 ++++ .../databases/increment-document-attribute.md | 18 ++++ package.json | 2 +- src/client.ts | 2 +- src/models.ts | 4 + src/services/databases.ts | 92 +++++++++++++++++++ 8 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7817726..9e8e7165 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,4 +39,4 @@ jobs: - name: Publish run: npm publish --tag ${{ steps.release_tag.outputs.tag }} env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NO_ORG }} diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index ec768fcf..c627ab32 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,6 +2,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // .setSession('') // The user session to authenticate with .setKey('') // .setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 00000000..4c9c2d99 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.decrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // min (optional) +); + +console.log(result); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 00000000..3a9d9490 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.incrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // max (optional) +); + +console.log(result); diff --git a/package.json b/package.json index c4717855..92479c87 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.10.1", + "version": "0.11.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index b404254b..22628773 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.10.1', + 'x-sdk-version': '0.11.0', 'X-Appwrite-Response-Format': '1.7.0', }; diff --git a/src/models.ts b/src/models.ts index f6db5fab..5fafb2ab 100644 --- a/src/models.ts +++ b/src/models.ts @@ -189,6 +189,10 @@ export namespace Models { * Document ID. */ $id: string; + /** + * Document automatically incrementing ID. + */ + $sequence: number; /** * Collection ID. */ diff --git a/src/services/databases.ts b/src/services/databases.ts index 09186833..783d9327 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -256,4 +256,96 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} min + * @throws {AppwriteException} + * @returns {Promise} + */ + decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + + if (typeof min !== 'undefined') { + payload['min'] = min; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} max + * @throws {AppwriteException} + * @returns {Promise} + */ + incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + + if (typeof max !== 'undefined') { + payload['max'] = max; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } }; From feff5c80b1b3ad88733c75563ad70760eea86c86 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:15:08 +0000 Subject: [PATCH 21/27] chore: regenerate --- README.md | 4 +- docs/examples/databases/create-document.md | 1 - .../databases/decrement-document-attribute.md | 18 -- .../databases/increment-document-attribute.md | 18 -- docs/examples/databases/upsert-document.md | 8 +- docs/examples/tables/create-row.md | 19 ++ docs/examples/tables/create-rows.md | 16 + docs/examples/tables/delete-row.md | 15 + docs/examples/tables/get-row.md | 16 + docs/examples/tables/list-rows.md | 15 + docs/examples/tables/update-row.md | 17 ++ docs/examples/tables/upsert-row.md | 17 ++ src/client.ts | 2 +- src/index.ts | 1 + src/models.ts | 83 ++++-- src/services/account.ts | 118 ++++---- src/services/avatars.ts | 14 +- src/services/databases.ts | 134 ++------- src/services/functions.ts | 6 +- src/services/graphql.ts | 4 +- src/services/locale.ts | 16 +- src/services/messaging.ts | 4 +- src/services/storage.ts | 16 +- src/services/tables.ts | 279 ++++++++++++++++++ src/services/teams.ts | 38 +-- 25 files changed, 593 insertions(+), 286 deletions(-) delete mode 100644 docs/examples/databases/decrement-document-attribute.md delete mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/tables/create-row.md create mode 100644 docs/examples/tables/create-rows.md create mode 100644 docs/examples/tables/delete-row.md create mode 100644 docs/examples/tables/get-row.md create mode 100644 docs/examples/tables/list-rows.md create mode 100644 docs/examples/tables/update-row.md create mode 100644 docs/examples/tables/upsert-row.md create mode 100644 src/services/tables.ts diff --git a/README.md b/README.md index 542c5c3e..40867bae 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/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 React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index c627ab32..ec768fcf 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,7 +2,6 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // .setSession('') // The user session to authenticate with .setKey('') // .setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md deleted file mode 100644 index 4c9c2d99..00000000 --- a/docs/examples/databases/decrement-document-attribute.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Databases } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const databases = new Databases(client); - -const result = await databases.decrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // min (optional) -); - -console.log(result); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md deleted file mode 100644 index 3a9d9490..00000000 --- a/docs/examples/databases/increment-document-attribute.md +++ /dev/null @@ -1,18 +0,0 @@ -import { Client, Databases } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const databases = new Databases(client); - -const result = await databases.incrementDocumentAttribute( - '', // databaseId - '', // collectionId - '', // documentId - '', // attribute - null, // value (optional) - null // max (optional) -); - -console.log(result); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index ae423d12..56d3af23 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,16 +2,16 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID + .setSession('') // The user session to authenticate with + .setKey('') // + .setJWT(''); // Your secret JSON Web Token const databases = new Databases(client); const result = await databases.upsertDocument( '', // databaseId '', // collectionId - '', // documentId - {}, // data - ["read("any")"] // permissions (optional) + '' // documentId ); console.log(result); diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md new file mode 100644 index 00000000..75de1c2a --- /dev/null +++ b/docs/examples/tables/create-row.md @@ -0,0 +1,19 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setKey('') // + .setJWT(''); // Your secret JSON Web Token + +const tables = new Tables(client); + +const result = await tables.createRow( + '', // databaseId + '', // tableId + '', // rowId + {}, // data + ["read("any")"] // permissions (optional) +); + +console.log(result); diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md new file mode 100644 index 00000000..165aa4cb --- /dev/null +++ b/docs/examples/tables/create-rows.md @@ -0,0 +1,16 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setAdmin('') // + .setKey(''); // + +const tables = new Tables(client); + +const result = await tables.createRows( + '', // databaseId + '', // tableId + [] // rows +); + +console.log(result); diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md new file mode 100644 index 00000000..9746f85e --- /dev/null +++ b/docs/examples/tables/delete-row.md @@ -0,0 +1,15 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const tables = new Tables(client); + +const result = await tables.deleteRow( + '', // databaseId + '', // tableId + '' // rowId +); + +console.log(result); diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md new file mode 100644 index 00000000..b9434e39 --- /dev/null +++ b/docs/examples/tables/get-row.md @@ -0,0 +1,16 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const tables = new Tables(client); + +const result = await tables.getRow( + '', // databaseId + '', // tableId + '', // rowId + [] // queries (optional) +); + +console.log(result); diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md new file mode 100644 index 00000000..75f81a14 --- /dev/null +++ b/docs/examples/tables/list-rows.md @@ -0,0 +1,15 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const tables = new Tables(client); + +const result = await tables.listRows( + '', // databaseId + '', // tableId + [] // queries (optional) +); + +console.log(result); diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md new file mode 100644 index 00000000..7bb36dd2 --- /dev/null +++ b/docs/examples/tables/update-row.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const tables = new Tables(client); + +const result = await tables.updateRow( + '', // databaseId + '', // tableId + '', // rowId + {}, // data (optional) + ["read("any")"] // permissions (optional) +); + +console.log(result); diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md new file mode 100644 index 00000000..f176425a --- /dev/null +++ b/docs/examples/tables/upsert-row.md @@ -0,0 +1,17 @@ +import { Client, Tables } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setSession('') // The user session to authenticate with + .setKey('') // + .setJWT(''); // Your secret JSON Web Token + +const tables = new Tables(client); + +const result = await tables.upsertRow( + '', // databaseId + '', // tableId + '' // rowId +); + +console.log(result); diff --git a/src/client.ts b/src/client.ts index 22628773..a0b2f34c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -116,7 +116,7 @@ class Client { 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', 'x-sdk-version': '0.11.0', - 'X-Appwrite-Response-Format': '1.7.0', + 'X-Appwrite-Response-Format': '1.8.0', }; /** diff --git a/src/index.ts b/src/index.ts index bbc74cce..35d654c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ export { Client, AppwriteException } from './client'; export { Account } from './services/account'; export { Avatars } from './services/avatars'; export { Databases } from './services/databases'; +export { Tables } from './services/tables'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; diff --git a/src/models.ts b/src/models.ts index 5fafb2ab..1acb8a42 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,10 +1,23 @@ export namespace Models { + /** + * Rows List + */ + export type RowList = { + /** + * Total number of rows rows that matched your query. + */ + total: number; + /** + * List of rows. + */ + rows: Row[]; + } /** * Documents List */ - export type DocumentList = { + export type DocumentList = { /** - * Total number of documents documents that matched your query. + * Total number of documents rows that matched your query. */ total: number; /** @@ -17,7 +30,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions documents that matched your query. + * Total number of sessions rows that matched your query. */ total: number; /** @@ -30,7 +43,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities documents that matched your query. + * Total number of identities rows that matched your query. */ total: number; /** @@ -43,7 +56,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs documents that matched your query. + * Total number of logs rows that matched your query. */ total: number; /** @@ -56,7 +69,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files documents that matched your query. + * Total number of files rows that matched your query. */ total: number; /** @@ -67,9 +80,9 @@ export namespace Models { /** * Teams List */ - export type TeamList = { + export type TeamList = { /** - * Total number of teams documents that matched your query. + * Total number of teams rows that matched your query. */ total: number; /** @@ -82,7 +95,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships documents that matched your query. + * Total number of memberships rows that matched your query. */ total: number; /** @@ -95,7 +108,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions documents that matched your query. + * Total number of executions rows that matched your query. */ total: number; /** @@ -108,7 +121,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries documents that matched your query. + * Total number of countries rows that matched your query. */ total: number; /** @@ -121,7 +134,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents documents that matched your query. + * Total number of continents rows that matched your query. */ total: number; /** @@ -134,7 +147,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages documents that matched your query. + * Total number of languages rows that matched your query. */ total: number; /** @@ -147,7 +160,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies documents that matched your query. + * Total number of currencies rows that matched your query. */ total: number; /** @@ -160,7 +173,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones documents that matched your query. + * Total number of phones rows that matched your query. */ total: number; /** @@ -173,7 +186,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes rows that matched your query. */ total: number; /** @@ -181,6 +194,40 @@ export namespace Models { */ localeCodes: LocaleCode[]; } + /** + * Row + */ + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row automatically incrementing ID. + */ + $sequence: number; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Row creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Row update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + [key: string]: any; + } /** * Document */ @@ -307,7 +354,7 @@ export namespace Models { /** * User */ - export type User = { + export type User = { /** * User ID. */ @@ -796,7 +843,7 @@ export namespace Models { /** * Team */ - export type Team = { + export type Team = { /** * Team ID. */ diff --git a/src/services/account.ts b/src/services/account.ts index bcd37339..cca5bae1 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -21,8 +21,8 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ - get(): Promise> { + */ + get(): Promise> { const apiPath = '/account'; const payload: Payload = {}; @@ -46,8 +46,8 @@ export class Account extends Service { * @param {string} name * @throws {AppwriteException} * @returns {Promise} - */ - create(userId: string, email: string, password: string, name?: string): Promise> { + */ + create(userId: string, email: string, password: string, name?: string): Promise> { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); } @@ -99,8 +99,8 @@ export class Account extends Service { * @param {string} password * @throws {AppwriteException} * @returns {Promise} - */ - updateEmail(email: string, password: string): Promise> { + */ + updateEmail(email: string, password: string): Promise> { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); } @@ -132,7 +132,7 @@ export class Account extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - */ + */ listIdentities(queries?: string[]): Promise { const apiPath = '/account/identities'; const payload: Payload = {}; @@ -152,7 +152,7 @@ export class Account extends Service { * @param {string} identityId * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteIdentity(identityId: string): Promise<{}> { if (typeof identityId === 'undefined') { throw new AppwriteException('Missing required parameter: "identityId"'); @@ -176,7 +176,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ createJWT(): Promise { const apiPath = '/account/jwts'; const payload: Payload = {}; @@ -194,7 +194,7 @@ export class Account extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - */ + */ listLogs(queries?: string[]): Promise { const apiPath = '/account/logs'; const payload: Payload = {}; @@ -214,8 +214,8 @@ export class Account extends Service { * @param {boolean} mfa * @throws {AppwriteException} * @returns {Promise} - */ - updateMFA(mfa: boolean): Promise> { + */ + updateMFA(mfa: boolean): Promise> { if (typeof mfa === 'undefined') { throw new AppwriteException('Missing required parameter: "mfa"'); } @@ -242,7 +242,7 @@ export class Account extends Service { * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} - */ + */ createMfaAuthenticator(type: AuthenticatorType): Promise { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); @@ -266,8 +266,8 @@ export class Account extends Service { * @param {string} otp * @throws {AppwriteException} * @returns {Promise} - */ - updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { + */ + updateMfaAuthenticator(type: AuthenticatorType, otp: string): Promise> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); } @@ -295,7 +295,7 @@ export class Account extends Service { * @param {AuthenticatorType} type * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteMfaAuthenticator(type: AuthenticatorType): Promise<{}> { if (typeof type === 'undefined') { throw new AppwriteException('Missing required parameter: "type"'); @@ -318,7 +318,7 @@ export class Account extends Service { * @param {AuthenticationFactor} factor * @throws {AppwriteException} * @returns {Promise} - */ + */ createMfaChallenge(factor: AuthenticationFactor): Promise { if (typeof factor === 'undefined') { throw new AppwriteException('Missing required parameter: "factor"'); @@ -348,7 +348,7 @@ export class Account extends Service { * @param {string} otp * @throws {AppwriteException} * @returns {Promise} - */ + */ updateMfaChallenge(challengeId: string, otp: string): Promise { if (typeof challengeId === 'undefined') { throw new AppwriteException('Missing required parameter: "challengeId"'); @@ -380,7 +380,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listMfaFactors(): Promise { const apiPath = '/account/mfa/factors'; const payload: Payload = {}; @@ -398,7 +398,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ getMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; @@ -417,7 +417,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ createMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; @@ -436,7 +436,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ updateMfaRecoveryCodes(): Promise { const apiPath = '/account/mfa/recovery-codes'; const payload: Payload = {}; @@ -453,8 +453,8 @@ export class Account extends Service { * @param {string} name * @throws {AppwriteException} * @returns {Promise} - */ - updateName(name: string): Promise> { + */ + updateName(name: string): Promise> { if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } @@ -481,8 +481,8 @@ export class Account extends Service { * @param {string} oldPassword * @throws {AppwriteException} * @returns {Promise} - */ - updatePassword(password: string, oldPassword?: string): Promise> { + */ + updatePassword(password: string, oldPassword?: string): Promise> { if (typeof password === 'undefined') { throw new AppwriteException('Missing required parameter: "password"'); } @@ -515,8 +515,8 @@ export class Account extends Service { * @param {string} password * @throws {AppwriteException} * @returns {Promise} - */ - updatePhone(phone: string, password: string): Promise> { + */ + updatePhone(phone: string, password: string): Promise> { if (typeof phone === 'undefined') { throw new AppwriteException('Missing required parameter: "phone"'); } @@ -547,8 +547,8 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ - getPrefs(): Promise { + */ + getPrefs(): Promise { const apiPath = '/account/prefs'; const payload: Payload = {}; @@ -565,8 +565,8 @@ export class Account extends Service { * @param {object} prefs * @throws {AppwriteException} * @returns {Promise} - */ - updatePrefs(prefs: object): Promise> { + */ + updatePrefs(prefs: object): Promise> { if (typeof prefs === 'undefined') { throw new AppwriteException('Missing required parameter: "prefs"'); } @@ -598,7 +598,7 @@ export class Account extends Service { * @param {string} url * @throws {AppwriteException} * @returns {Promise} - */ + */ createRecovery(email: string, url: string): Promise { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); @@ -642,7 +642,7 @@ export class Account extends Service { * @param {string} password * @throws {AppwriteException} * @returns {Promise} - */ + */ updateRecovery(userId: string, secret: string, password: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -683,7 +683,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listSessions(): Promise { const apiPath = '/account/sessions'; const payload: Payload = {}; @@ -699,7 +699,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteSessions(): Promise<{}> { const apiPath = '/account/sessions'; const payload: Payload = {}; @@ -721,7 +721,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ createAnonymousSession(): Promise { const apiPath = '/account/sessions/anonymous'; const payload: Payload = {}; @@ -744,7 +744,7 @@ export class Account extends Service { * @param {string} password * @throws {AppwriteException} * @returns {Promise} - */ + */ createEmailPasswordSession(email: string, password: string): Promise { if (typeof email === 'undefined') { throw new AppwriteException('Missing required parameter: "email"'); @@ -780,7 +780,8 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + * @deprecated This API has been deprecated. + */ updateMagicURLSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -831,7 +832,7 @@ export class Account extends Service { * @param {string[]} scopes * @throws {AppwriteException} * @returns {void|string} - */ + */ createOAuth2Session(provider: OAuthProvider, success?: string, failure?: string, scopes?: string[]): void | URL { if (typeof provider === 'undefined') { throw new AppwriteException('Missing required parameter: "provider"'); @@ -871,7 +872,8 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + * @deprecated This API has been deprecated. + */ updatePhoneSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -907,7 +909,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + */ createSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -941,7 +943,7 @@ export class Account extends Service { * @param {string} sessionId * @throws {AppwriteException} * @returns {Promise} - */ + */ getSession(sessionId: string): Promise { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); @@ -963,7 +965,7 @@ export class Account extends Service { * @param {string} sessionId * @throws {AppwriteException} * @returns {Promise} - */ + */ updateSession(sessionId: string): Promise { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); @@ -988,7 +990,7 @@ export class Account extends Service { * @param {string} sessionId * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteSession(sessionId: string): Promise<{}> { if (typeof sessionId === 'undefined') { throw new AppwriteException('Missing required parameter: "sessionId"'); @@ -1010,8 +1012,8 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ - updateStatus(): Promise> { + */ + updateStatus(): Promise> { const apiPath = '/account/status'; const payload: Payload = {}; @@ -1033,7 +1035,7 @@ export class Account extends Service { * @param {string} providerId * @throws {AppwriteException} * @returns {Promise} - */ + */ createPushTarget(targetId: string, identifier: string, providerId?: string): Promise { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); @@ -1075,7 +1077,7 @@ export class Account extends Service { * @param {string} identifier * @throws {AppwriteException} * @returns {Promise} - */ + */ updatePushTarget(targetId: string, identifier: string): Promise { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); @@ -1106,7 +1108,7 @@ export class Account extends Service { * @param {string} targetId * @throws {AppwriteException} * @returns {Promise} - */ + */ deletePushTarget(targetId: string): Promise<{}> { if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); @@ -1138,7 +1140,7 @@ export class Account extends Service { * @param {boolean} phrase * @throws {AppwriteException} * @returns {Promise} - */ + */ createEmailToken(userId: string, email: string, phrase?: boolean): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1191,7 +1193,7 @@ export class Account extends Service { * @param {boolean} phrase * @throws {AppwriteException} * @returns {Promise} - */ + */ createMagicURLToken(userId: string, email: string, url?: string, phrase?: boolean): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1248,7 +1250,7 @@ export class Account extends Service { * @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"'); @@ -1295,7 +1297,7 @@ export class Account extends Service { * @param {string} phone * @throws {AppwriteException} * @returns {Promise} - */ + */ createPhoneToken(userId: string, phone: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1342,7 +1344,7 @@ export class Account extends Service { * @param {string} url * @throws {AppwriteException} * @returns {Promise} - */ + */ createVerification(url: string): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); @@ -1371,7 +1373,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + */ updateVerification(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); @@ -1410,7 +1412,7 @@ export class Account extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ createPhoneVerification(): Promise { const apiPath = '/account/verification/phone'; const payload: Payload = {}; @@ -1431,7 +1433,7 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + */ updatePhoneVerification(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { throw new AppwriteException('Missing required parameter: "userId"'); diff --git a/src/services/avatars.ts b/src/services/avatars.ts index 85952b13..5a66f64f 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -34,7 +34,7 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getBrowser(code: Browser, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); @@ -83,7 +83,7 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getCreditCard(code: CreditCard, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); @@ -124,7 +124,7 @@ export class Avatars extends Service { * @param {string} url * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getFavicon(url: string): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); @@ -166,7 +166,7 @@ export class Avatars extends Service { * @param {number} quality * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getFlag(code: Flag, width?: number, height?: number, quality?: number): Promise { if (typeof code === 'undefined') { throw new AppwriteException('Missing required parameter: "code"'); @@ -216,7 +216,7 @@ export class Avatars extends Service { * @param {number} height * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getImage(url: string, width?: number, height?: number): Promise { if (typeof url === 'undefined') { throw new AppwriteException('Missing required parameter: "url"'); @@ -272,7 +272,7 @@ export class Avatars extends Service { * @param {string} background * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getInitials(name?: string, width?: number, height?: number, background?: string): Promise { const apiPath = '/avatars/initials'; const payload: Payload = {}; @@ -315,7 +315,7 @@ export class Avatars extends Service { * @param {boolean} download * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getQR(text: string, size?: number, margin?: number, download?: boolean): Promise { if (typeof text === 'undefined') { throw new AppwriteException('Missing required parameter: "text"'); diff --git a/src/services/databases.ts b/src/services/databases.ts index 783d9327..c0031fae 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -22,8 +22,9 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - */ - listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. + */ + listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -57,8 +58,9 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - */ - createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. + */ + createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -106,8 +108,9 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - */ - getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. + */ + getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -145,12 +148,11 @@ export class Databases extends Service { * @param {string} databaseId * @param {string} collectionId * @param {string} documentId - * @param {object} data - * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - */ - upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. + */ + upsertDocument(databaseId: string, collectionId: string, documentId: string): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -163,21 +165,9 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "documentId"'); } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; - if (typeof data !== 'undefined') { - payload['data'] = data; - } - - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { 'content-type': 'application/json', @@ -195,8 +185,9 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - */ - updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. + */ + updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -234,7 +225,8 @@ export class Databases extends Service { * @param {string} documentId * @throws {AppwriteException} * @returns {Promise} - */ + * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. + */ deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); @@ -256,96 +248,4 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } - - /** - * Decrement a specific attribute of a document by a given value. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {string} attribute - * @param {number} value - * @param {number} min - * @throws {AppwriteException} - * @returns {Promise} - */ - decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); - const payload: Payload = {}; - - if (typeof value !== 'undefined') { - payload['value'] = value; - } - - if (typeof min !== 'undefined') { - payload['min'] = min; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Increment a specific attribute of a document by a given value. - * - * @param {string} databaseId - * @param {string} collectionId - * @param {string} documentId - * @param {string} attribute - * @param {number} value - * @param {number} max - * @throws {AppwriteException} - * @returns {Promise} - */ - incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - - if (typeof attribute === 'undefined') { - throw new AppwriteException('Missing required parameter: "attribute"'); - } - - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); - const payload: Payload = {}; - - if (typeof value !== 'undefined') { - payload['value'] = value; - } - - if (typeof max !== 'undefined') { - payload['max'] = max; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } }; diff --git a/src/services/functions.ts b/src/services/functions.ts index 4f41fe09..6b0134c7 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -22,7 +22,7 @@ export class Functions extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - */ + */ listExecutions(functionId: string, queries?: string[]): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -55,7 +55,7 @@ export class Functions extends Service { * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise} - */ + */ createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); @@ -101,7 +101,7 @@ export class Functions extends Service { * @param {string} executionId * @throws {AppwriteException} * @returns {Promise} - */ + */ getExecution(functionId: string, executionId: string): Promise { if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); diff --git a/src/services/graphql.ts b/src/services/graphql.ts index a24adaa4..8655f00c 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -19,7 +19,7 @@ export class Graphql extends Service { * @param {object} query * @throws {AppwriteException} * @returns {Promise} - */ + */ query(query: object): Promise<{}> { if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); @@ -45,7 +45,7 @@ export class Graphql extends Service { * @param {object} query * @throws {AppwriteException} * @returns {Promise} - */ + */ mutation(query: object): Promise<{}> { if (typeof query === 'undefined') { throw new AppwriteException('Missing required parameter: "query"'); diff --git a/src/services/locale.ts b/src/services/locale.ts index 6498bd98..7a29f954 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -23,7 +23,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ get(): Promise { const apiPath = '/locale'; const payload: Payload = {}; @@ -39,7 +39,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listCodes(): Promise { const apiPath = '/locale/codes'; const payload: Payload = {}; @@ -55,7 +55,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listContinents(): Promise { const apiPath = '/locale/continents'; const payload: Payload = {}; @@ -71,7 +71,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listCountries(): Promise { const apiPath = '/locale/countries'; const payload: Payload = {}; @@ -87,7 +87,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listCountriesEU(): Promise { const apiPath = '/locale/countries/eu'; const payload: Payload = {}; @@ -103,7 +103,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listCountriesPhones(): Promise { const apiPath = '/locale/countries/phones'; const payload: Payload = {}; @@ -120,7 +120,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listCurrencies(): Promise { const apiPath = '/locale/currencies'; const payload: Payload = {}; @@ -136,7 +136,7 @@ export class Locale extends Service { * * @throws {AppwriteException} * @returns {Promise} - */ + */ listLanguages(): Promise { const apiPath = '/locale/languages'; const payload: Payload = {}; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 6e33b9ab..e6edd34d 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -21,7 +21,7 @@ export class Messaging extends Service { * @param {string} targetId * @throws {AppwriteException} * @returns {Promise} - */ + */ createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); @@ -59,7 +59,7 @@ export class Messaging extends Service { * @param {string} subscriberId * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); diff --git a/src/services/storage.ts b/src/services/storage.ts index e40614aa..e062b2fb 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -24,7 +24,7 @@ export class Storage extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} - */ + */ listFiles(bucketId: string, queries?: string[], search?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -72,7 +72,7 @@ export class Storage extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - */ + */ async createFile(bucketId: string, fileId: string, file: {name: string, type: string, size: number, uri: string}, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -169,7 +169,7 @@ export class Storage extends Service { * @param {string} fileId * @throws {AppwriteException} * @returns {Promise} - */ + */ getFile(bucketId: string, fileId: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -197,7 +197,7 @@ export class Storage extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - */ + */ updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -232,7 +232,7 @@ export class Storage extends Service { * @param {string} fileId * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteFile(bucketId: string, fileId: string): Promise<{}> { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -261,7 +261,7 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getFileDownload(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -312,7 +312,7 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ 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, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); @@ -394,7 +394,7 @@ export class Storage extends Service { * @param {string} token * @throws {AppwriteException} * @returns {ArrayBuffer} - */ + */ getFileView(bucketId: string, fileId: string, token?: string): Promise { if (typeof bucketId === 'undefined') { throw new AppwriteException('Missing required parameter: "bucketId"'); diff --git a/src/services/tables.ts b/src/services/tables.ts new file mode 100644 index 00000000..9e86fbee --- /dev/null +++ b/src/services/tables.ts @@ -0,0 +1,279 @@ +import { Service } from '../service'; +import { AppwriteException, Client } from '../client'; +import type { Models } from '../models'; +import type { UploadProgress, Payload } from '../client'; +import * as FileSystem from 'expo-file-system'; +import { Platform } from 'react-native'; + + +export class Tables extends Service { + + constructor(client: Client) + { + super(client); + } + + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + listRows(databaseId: string, tableId: string, queries?: string[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + createRow(databaseId: string, tableId: string, rowId: string, data: object, permissions?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof rowId !== 'undefined') { + payload['rowId'] = rowId; + } + + if (typeof data !== 'undefined') { + payload['data'] = data; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {object[]} rows + * @throws {AppwriteException} + * @returns {Promise} + */ + createRows(databaseId: string, tableId: string, rows: object[]): Promise> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('post', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {string[]} queries + * @throws {AppwriteException} + * @returns {Promise} + */ + getRow(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('get', uri, { + }, payload); + } + + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @throws {AppwriteException} + * @returns {Promise} + */ + upsertRow(databaseId: string, tableId: string, rowId: string): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('put', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @param {object} data + * @param {string[]} permissions + * @throws {AppwriteException} + * @returns {Promise} + */ + updateRow(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + if (typeof data !== 'undefined') { + payload['data'] = data; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Delete a row by its unique ID. + * + * @param {string} databaseId + * @param {string} tableId + * @param {string} rowId + * @throws {AppwriteException} + * @returns {Promise} + */ + deleteRow(databaseId: string, tableId: string, rowId: string): Promise<{}> { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); + const payload: Payload = {}; + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('delete', uri, { + 'content-type': 'application/json', + }, payload); + } +}; diff --git a/src/services/teams.ts b/src/services/teams.ts index 98e459f6..d45f7e93 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -21,8 +21,8 @@ export class Teams extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} - */ - list(queries?: string[], search?: string): Promise> { + */ + list(queries?: string[], search?: string): Promise> { const apiPath = '/teams'; const payload: Payload = {}; @@ -49,8 +49,8 @@ export class Teams extends Service { * @param {string[]} roles * @throws {AppwriteException} * @returns {Promise} - */ - create(teamId: string, name: string, roles?: string[]): Promise> { + */ + create(teamId: string, name: string, roles?: string[]): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -86,8 +86,8 @@ export class Teams extends Service { * @param {string} teamId * @throws {AppwriteException} * @returns {Promise} - */ - get(teamId: string): Promise> { + */ + get(teamId: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -107,8 +107,8 @@ export class Teams extends Service { * @param {string} name * @throws {AppwriteException} * @returns {Promise} - */ - updateName(teamId: string, name: string): Promise> { + */ + updateName(teamId: string, name: string): Promise> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -137,7 +137,7 @@ export class Teams extends Service { * @param {string} teamId * @throws {AppwriteException} * @returns {Promise} - */ + */ delete(teamId: string): Promise<{}> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -162,7 +162,7 @@ export class Teams extends Service { * @param {string} search * @throws {AppwriteException} * @returns {Promise} - */ + */ listMemberships(teamId: string, queries?: string[], search?: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -216,7 +216,7 @@ export class Teams extends Service { * @param {string} name * @throws {AppwriteException} * @returns {Promise} - */ + */ createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -268,7 +268,7 @@ export class Teams extends Service { * @param {string} membershipId * @throws {AppwriteException} * @returns {Promise} - */ + */ getMembership(teamId: string, membershipId: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -297,7 +297,7 @@ export class Teams extends Service { * @param {string[]} roles * @throws {AppwriteException} * @returns {Promise} - */ + */ updateMembership(teamId: string, membershipId: string, roles: string[]): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -333,7 +333,7 @@ export class Teams extends Service { * @param {string} membershipId * @throws {AppwriteException} * @returns {Promise} - */ + */ deleteMembership(teamId: string, membershipId: string): Promise<{}> { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -367,7 +367,7 @@ export class Teams extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - */ + */ updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); @@ -410,8 +410,8 @@ export class Teams extends Service { * @param {string} teamId * @throws {AppwriteException} * @returns {Promise} - */ - getPrefs(teamId: string): Promise { + */ + getPrefs(teamId: string): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } @@ -433,8 +433,8 @@ export class Teams extends Service { * @param {object} prefs * @throws {AppwriteException} * @returns {Promise} - */ - updatePrefs(teamId: string, prefs: object): Promise { + */ + updatePrefs(teamId: string, prefs: object): Promise { if (typeof teamId === 'undefined') { throw new AppwriteException('Missing required parameter: "teamId"'); } From c74ae03431542d0941c790785c2a060ba8d5a607 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:23:00 +0000 Subject: [PATCH 22/27] chore: regen --- README.md | 4 +- docs/examples/databases/create-document.md | 4 +- .../databases/decrement-document-attribute.md | 18 ++ .../databases/increment-document-attribute.md | 18 ++ docs/examples/databases/upsert-document.md | 8 +- docs/examples/tables/create-row.md | 19 -- docs/examples/tables/create-rows.md | 16 - docs/examples/tables/delete-row.md | 15 - docs/examples/tables/get-row.md | 16 - docs/examples/tables/list-rows.md | 15 - docs/examples/tables/update-row.md | 17 -- docs/examples/tables/upsert-row.md | 17 -- package.json | 2 +- src/client.ts | 4 +- src/index.ts | 1 - src/models.ts | 75 +---- src/services/account.ts | 2 - src/services/databases.ts | 114 ++++++- src/services/tables.ts | 279 ------------------ 19 files changed, 167 insertions(+), 477 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 src/services/tables.ts diff --git a/README.md b/README.md index 40867bae..542c5c3e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite React Native SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/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 React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index ec768fcf..1b28231e 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,9 +2,7 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID const databases = new Databases(client); diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 00000000..4c9c2d99 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.decrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // min (optional) +); + +console.log(result); diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 00000000..3a9d9490 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import { Client, Databases } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.incrementDocumentAttribute( + '', // databaseId + '', // collectionId + '', // documentId + '', // attribute + null, // value (optional) + null // max (optional) +); + +console.log(result); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 56d3af23..ae423d12 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -2,16 +2,16 @@ import { Client, Databases } from "react-native-appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token + .setProject(''); // Your project ID const databases = new Databases(client); const result = await databases.upsertDocument( '', // databaseId '', // collectionId - '' // documentId + '', // documentId + {}, // data + ["read("any")"] // permissions (optional) ); console.log(result); diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index 75de1c2a..00000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,19 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token - -const tables = new Tables(client); - -const result = await tables.createRow( - '', // databaseId - '', // tableId - '', // rowId - {}, // data - ["read("any")"] // permissions (optional) -); - -console.log(result); diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index 165aa4cb..00000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,16 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setAdmin('') // - .setKey(''); // - -const tables = new Tables(client); - -const result = await tables.createRows( - '', // databaseId - '', // tableId - [] // rows -); - -console.log(result); diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 9746f85e..00000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const tables = new Tables(client); - -const result = await tables.deleteRow( - '', // databaseId - '', // tableId - '' // rowId -); - -console.log(result); diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index b9434e39..00000000 --- a/docs/examples/tables/get-row.md +++ /dev/null @@ -1,16 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const tables = new Tables(client); - -const result = await tables.getRow( - '', // databaseId - '', // tableId - '', // rowId - [] // queries (optional) -); - -console.log(result); diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index 75f81a14..00000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,15 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const tables = new Tables(client); - -const result = await tables.listRows( - '', // databaseId - '', // tableId - [] // queries (optional) -); - -console.log(result); diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index 7bb36dd2..00000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -const tables = new Tables(client); - -const result = await tables.updateRow( - '', // databaseId - '', // tableId - '', // rowId - {}, // data (optional) - ["read("any")"] // permissions (optional) -); - -console.log(result); diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index f176425a..00000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import { Client, Tables } from "react-native-appwrite"; - -const client = new Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setSession('') // The user session to authenticate with - .setKey('') // - .setJWT(''); // Your secret JSON Web Token - -const tables = new Tables(client); - -const result = await tables.upsertRow( - '', // databaseId - '', // tableId - '' // rowId -); - -console.log(result); diff --git a/package.json b/package.json index 92479c87..c4717855 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.11.0", + "version": "0.10.1", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index a0b2f34c..b404254b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,8 +115,8 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.11.0', - 'X-Appwrite-Response-Format': '1.8.0', + 'x-sdk-version': '0.10.1', + 'X-Appwrite-Response-Format': '1.7.0', }; /** diff --git a/src/index.ts b/src/index.ts index 35d654c8..bbc74cce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,6 @@ export { Client, AppwriteException } from './client'; export { Account } from './services/account'; export { Avatars } from './services/avatars'; export { Databases } from './services/databases'; -export { Tables } from './services/tables'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; export { Locale } from './services/locale'; diff --git a/src/models.ts b/src/models.ts index 1acb8a42..13efc688 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,23 +1,10 @@ export namespace Models { - /** - * Rows List - */ - export type RowList = { - /** - * Total number of rows rows that matched your query. - */ - total: number; - /** - * List of rows. - */ - rows: Row[]; - } /** * Documents List */ export type DocumentList = { /** - * Total number of documents rows that matched your query. + * Total number of documents documents that matched your query. */ total: number; /** @@ -30,7 +17,7 @@ export namespace Models { */ export type SessionList = { /** - * Total number of sessions rows that matched your query. + * Total number of sessions documents that matched your query. */ total: number; /** @@ -43,7 +30,7 @@ export namespace Models { */ export type IdentityList = { /** - * Total number of identities rows that matched your query. + * Total number of identities documents that matched your query. */ total: number; /** @@ -56,7 +43,7 @@ export namespace Models { */ export type LogList = { /** - * Total number of logs rows that matched your query. + * Total number of logs documents that matched your query. */ total: number; /** @@ -69,7 +56,7 @@ export namespace Models { */ export type FileList = { /** - * Total number of files rows that matched your query. + * Total number of files documents that matched your query. */ total: number; /** @@ -82,7 +69,7 @@ export namespace Models { */ export type TeamList = { /** - * Total number of teams rows that matched your query. + * Total number of teams documents that matched your query. */ total: number; /** @@ -95,7 +82,7 @@ export namespace Models { */ export type MembershipList = { /** - * Total number of memberships rows that matched your query. + * Total number of memberships documents that matched your query. */ total: number; /** @@ -108,7 +95,7 @@ export namespace Models { */ export type ExecutionList = { /** - * Total number of executions rows that matched your query. + * Total number of executions documents that matched your query. */ total: number; /** @@ -121,7 +108,7 @@ export namespace Models { */ export type CountryList = { /** - * Total number of countries rows that matched your query. + * Total number of countries documents that matched your query. */ total: number; /** @@ -134,7 +121,7 @@ export namespace Models { */ export type ContinentList = { /** - * Total number of continents rows that matched your query. + * Total number of continents documents that matched your query. */ total: number; /** @@ -147,7 +134,7 @@ export namespace Models { */ export type LanguageList = { /** - * Total number of languages rows that matched your query. + * Total number of languages documents that matched your query. */ total: number; /** @@ -160,7 +147,7 @@ export namespace Models { */ export type CurrencyList = { /** - * Total number of currencies rows that matched your query. + * Total number of currencies documents that matched your query. */ total: number; /** @@ -173,7 +160,7 @@ export namespace Models { */ export type PhoneList = { /** - * Total number of phones rows that matched your query. + * Total number of phones documents that matched your query. */ total: number; /** @@ -186,7 +173,7 @@ export namespace Models { */ export type LocaleCodeList = { /** - * Total number of localeCodes rows that matched your query. + * Total number of localeCodes documents that matched your query. */ total: number; /** @@ -194,40 +181,6 @@ export namespace Models { */ localeCodes: LocaleCode[]; } - /** - * Row - */ - export type Row = { - /** - * Row ID. - */ - $id: string; - /** - * Row automatically incrementing ID. - */ - $sequence: number; - /** - * Table ID. - */ - $tableId: string; - /** - * Database ID. - */ - $databaseId: string; - /** - * Row creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * Row update date in ISO 8601 format. - */ - $updatedAt: string; - /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - $permissions: string[]; - [key: string]: any; - } /** * Document */ diff --git a/src/services/account.ts b/src/services/account.ts index cca5bae1..713f7369 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -780,7 +780,6 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated. */ updateMagicURLSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { @@ -872,7 +871,6 @@ export class Account extends Service { * @param {string} secret * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated. */ updatePhoneSession(userId: string, secret: string): Promise { if (typeof userId === 'undefined') { diff --git a/src/services/databases.ts b/src/services/databases.ts index c0031fae..ca803325 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -22,7 +22,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. */ listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise> { if (typeof databaseId === 'undefined') { @@ -58,7 +57,6 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. */ createDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -108,7 +106,6 @@ export class Databases extends Service { * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. */ getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -148,11 +145,12 @@ export class Databases extends Service { * @param {string} databaseId * @param {string} collectionId * @param {string} documentId + * @param {object} data + * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. */ - upsertDocument(databaseId: string, collectionId: string, documentId: string): Promise { + upsertDocument(databaseId: string, collectionId: string, documentId: string, data: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } @@ -165,9 +163,21 @@ export class Databases extends Service { throw new AppwriteException('Missing required parameter: "documentId"'); } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + const uri = new URL(this.client.config.endpoint + apiPath); return this.client.call('put', uri, { 'content-type': 'application/json', @@ -185,7 +195,6 @@ export class Databases extends Service { * @param {string[]} permissions * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. */ updateDocument(databaseId: string, collectionId: string, documentId: string, data?: object, permissions?: string[]): Promise { if (typeof databaseId === 'undefined') { @@ -225,7 +234,6 @@ export class Databases extends Service { * @param {string} documentId * @throws {AppwriteException} * @returns {Promise} - * @deprecated This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. */ deleteDocument(databaseId: string, collectionId: string, documentId: string): Promise<{}> { if (typeof databaseId === 'undefined') { @@ -248,4 +256,96 @@ export class Databases extends Service { 'content-type': 'application/json', }, payload); } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} min + * @throws {AppwriteException} + * @returns {Promise} + */ + decrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, min?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + + if (typeof min !== 'undefined') { + payload['min'] = min; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param {string} databaseId + * @param {string} collectionId + * @param {string} documentId + * @param {string} attribute + * @param {number} value + * @param {number} max + * @throws {AppwriteException} + * @returns {Promise} + */ + incrementDocumentAttribute(databaseId: string, collectionId: string, documentId: string, attribute: string, value?: number, max?: number): Promise { + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if (typeof attribute === 'undefined') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId).replace('{attribute}', attribute); + const payload: Payload = {}; + + if (typeof value !== 'undefined') { + payload['value'] = value; + } + + if (typeof max !== 'undefined') { + payload['max'] = max; + } + + const uri = new URL(this.client.config.endpoint + apiPath); + return this.client.call('patch', uri, { + 'content-type': 'application/json', + }, payload); + } }; diff --git a/src/services/tables.ts b/src/services/tables.ts deleted file mode 100644 index 9e86fbee..00000000 --- a/src/services/tables.ts +++ /dev/null @@ -1,279 +0,0 @@ -import { Service } from '../service'; -import { AppwriteException, Client } from '../client'; -import type { Models } from '../models'; -import type { UploadProgress, Payload } from '../client'; -import * as FileSystem from 'expo-file-system'; -import { Platform } from 'react-native'; - - -export class Tables extends Service { - - constructor(client: Client) - { - super(client); - } - - /** - * Get a list of all the user's rows in a given table. You can use the query - * params to filter your results. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - listRows(databaseId: string, tableId: string, queries?: string[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Create a new Row. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {object} data - * @param {string[]} permissions - * @throws {AppwriteException} - * @returns {Promise} - */ - createRow(databaseId: string, tableId: string, rowId: string, data: object, permissions?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof rowId !== 'undefined') { - payload['rowId'] = rowId; - } - - if (typeof data !== 'undefined') { - payload['data'] = data; - } - - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Create new Rows. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {object[]} rows - * @throws {AppwriteException} - * @returns {Promise} - */ - createRows(databaseId: string, tableId: string, rows: object[]): Promise> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rows === 'undefined') { - throw new AppwriteException('Missing required parameter: "rows"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); - const payload: Payload = {}; - - if (typeof rows !== 'undefined') { - payload['rows'] = rows; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('post', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object - * with the row data. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {string[]} queries - * @throws {AppwriteException} - * @returns {Promise} - */ - getRow(databaseId: string, tableId: string, rowId: string, queries?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - if (typeof queries !== 'undefined') { - payload['queries'] = queries; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('get', uri, { - }, payload); - } - - /** - * Create or update a Row. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @throws {AppwriteException} - * @returns {Promise} - */ - upsertRow(databaseId: string, tableId: string, rowId: string): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('put', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Update a row by its unique ID. Using the patch method you can pass only - * specific fields that will get updated. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @param {object} data - * @param {string[]} permissions - * @throws {AppwriteException} - * @returns {Promise} - */ - updateRow(databaseId: string, tableId: string, rowId: string, data?: object, permissions?: string[]): Promise { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - if (typeof data !== 'undefined') { - payload['data'] = data; - } - - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; - } - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('patch', uri, { - 'content-type': 'application/json', - }, payload); - } - - /** - * Delete a row by its unique ID. - * - * @param {string} databaseId - * @param {string} tableId - * @param {string} rowId - * @throws {AppwriteException} - * @returns {Promise} - */ - deleteRow(databaseId: string, tableId: string, rowId: string): Promise<{}> { - if (typeof databaseId === 'undefined') { - throw new AppwriteException('Missing required parameter: "databaseId"'); - } - - if (typeof tableId === 'undefined') { - throw new AppwriteException('Missing required parameter: "tableId"'); - } - - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - - const apiPath = '/databases/{databaseId}/tables/{tableId}/rows/{rowId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{rowId}', rowId); - const payload: Payload = {}; - - const uri = new URL(this.client.config.endpoint + apiPath); - return this.client.call('delete', uri, { - 'content-type': 'application/json', - }, payload); - } -}; From 13e14ec1854044e36582bb939c47a0db3b497904 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:25:52 +0000 Subject: [PATCH 23/27] chore: add changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ab2975b..ad6d00f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log +## 0.10.2 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `sequence` support to `Document` model +* Fix autocompletion not working for `Document` model even when generic is passed + ## 0.10.1 * Fix URL based methods like `getFileViewURL`, `getFilePreviewURL` etc. by adding the missing `projectId` to searchParams From 29430cb5eea6ca1f72120af5048749719da50194 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:41:38 +0000 Subject: [PATCH 24/27] chore: regen to 1.7.x --- CHANGELOG.md | 2 +- package.json | 2 +- src/client.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad6d00f7..a15eb1b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,4 +34,4 @@ ## 0.7.4 * Upgrade dependencies to resolve PlatformConstants error with Expo 53 -* Update doc examples to use new multi-region endpoint \ No newline at end of file +* Update doc examples to use new multi-region endpoint diff --git a/package.json b/package.json index c4717855..92479c87 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.10.1", + "version": "0.11.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index b404254b..22628773 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.10.1', + 'x-sdk-version': '0.11.0', 'X-Appwrite-Response-Format': '1.7.0', }; From 1bd2fdfb4ba716577914dd487211813a84373f6a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 07:32:14 +0000 Subject: [PATCH 25/27] chore: hotfix --- src/models.ts | 73 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/models.ts b/src/models.ts index 13efc688..4887e222 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,4 +1,7 @@ export namespace Models { + + declare const __default: unique symbol; + /** * Documents List */ @@ -12,6 +15,7 @@ export namespace Models { */ documents: Document[]; } + /** * Sessions List */ @@ -25,6 +29,7 @@ export namespace Models { */ sessions: Session[]; } + /** * Identities List */ @@ -38,6 +43,7 @@ export namespace Models { */ identities: Identity[]; } + /** * Logs List */ @@ -51,6 +57,7 @@ export namespace Models { */ logs: Log[]; } + /** * Files List */ @@ -64,6 +71,7 @@ export namespace Models { */ files: File[]; } + /** * Teams List */ @@ -77,6 +85,7 @@ export namespace Models { */ teams: Team[]; } + /** * Memberships List */ @@ -90,6 +99,7 @@ export namespace Models { */ memberships: Membership[]; } + /** * Executions List */ @@ -103,6 +113,7 @@ export namespace Models { */ executions: Execution[]; } + /** * Countries List */ @@ -116,6 +127,7 @@ export namespace Models { */ countries: Country[]; } + /** * Continents List */ @@ -129,6 +141,7 @@ export namespace Models { */ continents: Continent[]; } + /** * Languages List */ @@ -142,6 +155,7 @@ export namespace Models { */ languages: Language[]; } + /** * Currencies List */ @@ -155,6 +169,7 @@ export namespace Models { */ currencies: Currency[]; } + /** * Phones List */ @@ -168,6 +183,7 @@ export namespace Models { */ phones: Phone[]; } + /** * Locale codes list */ @@ -181,6 +197,7 @@ export namespace Models { */ localeCodes: LocaleCode[]; } + /** * Document */ @@ -213,8 +230,19 @@ export namespace Models { * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ $permissions: string[]; - [key: string]: any; } + + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + + export type DataWithoutDocumentKeys = { + [K in string]: any; + } & { + [K in keyof Document]?: never; + }; + /** * Log */ @@ -304,6 +332,7 @@ export namespace Models { */ countryName: string; } + /** * User */ @@ -385,6 +414,7 @@ export namespace Models { */ accessedAt: string; } + /** * AlgoMD5 */ @@ -394,6 +424,7 @@ export namespace Models { */ type: string; } + /** * AlgoSHA */ @@ -403,6 +434,7 @@ export namespace Models { */ type: string; } + /** * AlgoPHPass */ @@ -412,6 +444,7 @@ export namespace Models { */ type: string; } + /** * AlgoBcrypt */ @@ -421,6 +454,7 @@ export namespace Models { */ type: string; } + /** * AlgoScrypt */ @@ -446,6 +480,7 @@ export namespace Models { */ length: number; } + /** * AlgoScryptModified */ @@ -467,6 +502,7 @@ export namespace Models { */ signerKey: string; } + /** * AlgoArgon2 */ @@ -488,12 +524,24 @@ export namespace Models { */ threads: number; } + /** * Preferences */ export type Preferences = { - [key: string]: any; } + + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + + export type DataWithoutPreferencesKeys = { + [K in string]: any; + } & { + [K in keyof Preferences]?: never; + }; + /** * Session */ @@ -615,6 +663,7 @@ export namespace Models { */ mfaUpdatedAt: string; } + /** * Identity */ @@ -660,6 +709,7 @@ export namespace Models { */ providerRefreshToken: string; } + /** * Token */ @@ -689,6 +739,7 @@ export namespace Models { */ phrase: string; } + /** * JWT */ @@ -698,6 +749,7 @@ export namespace Models { */ jwt: string; } + /** * Locale */ @@ -731,6 +783,7 @@ export namespace Models { */ currency: string; } + /** * LocaleCode */ @@ -744,6 +797,7 @@ export namespace Models { */ name: string; } + /** * File */ @@ -793,6 +847,7 @@ export namespace Models { */ chunksUploaded: number; } + /** * Team */ @@ -822,6 +877,7 @@ export namespace Models { */ prefs: Preferences; } + /** * Membership */ @@ -879,6 +935,7 @@ export namespace Models { */ roles: string[]; } + /** * Execution */ @@ -952,6 +1009,7 @@ export namespace Models { */ scheduledAt?: string; } + /** * Country */ @@ -965,6 +1023,7 @@ export namespace Models { */ code: string; } + /** * Continent */ @@ -978,6 +1037,7 @@ export namespace Models { */ code: string; } + /** * Language */ @@ -995,6 +1055,7 @@ export namespace Models { */ nativeName: string; } + /** * Currency */ @@ -1028,6 +1089,7 @@ export namespace Models { */ namePlural: string; } + /** * Phone */ @@ -1045,6 +1107,7 @@ export namespace Models { */ countryName: string; } + /** * Headers */ @@ -1058,6 +1121,7 @@ export namespace Models { */ value: string; } + /** * MFA Challenge */ @@ -1079,6 +1143,7 @@ export namespace Models { */ expire: string; } + /** * MFA Recovery Codes */ @@ -1088,6 +1153,7 @@ export namespace Models { */ recoveryCodes: string[]; } + /** * MFAType */ @@ -1101,6 +1167,7 @@ export namespace Models { */ uri: string; } + /** * MFAFactors */ @@ -1122,6 +1189,7 @@ export namespace Models { */ recoveryCode: boolean; } + /** * Subscriber */ @@ -1163,6 +1231,7 @@ export namespace Models { */ providerType: string; } + /** * Target */ From 4010533a72e4dc78ac3b62894864967c18c86e3e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 07:47:10 +0000 Subject: [PATCH 26/27] fix: version to 0.10.2 --- package.json | 2 +- src/client.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 92479c87..9c716a2a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.11.0", + "version": "0.10.2", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 22628773..8c0125bb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.11.0', + 'x-sdk-version': '0.10.2', 'X-Appwrite-Response-Format': '1.7.0', }; From ed9ff97e62431a5975c5ba4e64bb6c9927643498 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Jul 2025 09:37:24 +0000 Subject: [PATCH 27/27] fix: version in changelog --- CHANGELOG.md | 2 +- package.json | 2 +- src/client.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a15eb1b0..eda0bca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log -## 0.10.2 +## 0.11.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service * Add `sequence` support to `Document` model diff --git a/package.json b/package.json index 9c716a2a..92479c87 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "0.10.2", + "version": "0.11.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 8c0125bb..22628773 100644 --- a/src/client.ts +++ b/src/client.ts @@ -115,7 +115,7 @@ class Client { 'x-sdk-name': 'React Native', 'x-sdk-platform': 'client', 'x-sdk-language': 'reactnative', - 'x-sdk-version': '0.10.2', + 'x-sdk-version': '0.11.0', 'X-Appwrite-Response-Format': '1.7.0', };