From 3fd85fa2ef61cef4641e6e9a78d6424db84f79e2 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Tue, 2 Apr 2024 14:06:11 -0400 Subject: [PATCH 1/3] Make it obvious when we talk about the Client SDKs --- .../+page.markdoc | 2 +- .../+page.markdoc | 2 +- .../post/enhancing-type-safety/+page.markdoc | 2 +- .../blog/post/enums-api-design/+page.markdoc | 2 +- .../+page.markdoc | 6 +- .../+page.markdoc | 2 +- .../blog/post/oauth-openid/+page.markdoc | 2 +- .../password-hashing-algorithms/+page.markdoc | 2 +- .../+page.markdoc | 2 +- .../simplify-messaging-twilio/+page.markdoc | 2 +- .../understand-data-queries/+page.markdoc | 2 +- .../+page.markdoc | 2 +- .../platform/message-templates/+page.markdoc | 8 +- .../platform/permissions/+page.markdoc | 4 +- src/routes/docs/apis/graphql/+page.markdoc | 82 +++++------ src/routes/docs/apis/realtime/+page.markdoc | 40 +++--- .../docs/products/auth/2fa/+page.markdoc | 8 +- .../docs/products/auth/accounts/+page.markdoc | 46 +++---- .../products/auth/anonymous/+page.markdoc | 26 ++-- .../products/auth/custom-token/+page.markdoc | 37 +++-- .../products/auth/email-otp/+page.markdoc | 76 +++++----- .../auth/email-password/+page.markdoc | 12 +- .../docs/products/auth/jwt/+page.markdoc | 26 ++-- .../docs/products/auth/labels/+page.markdoc | 2 +- .../products/auth/magic-url/+page.markdoc | 5 +- .../docs/products/auth/oauth2/+page.markdoc | 68 +++++---- .../products/auth/phone-sms/+page.markdoc | 73 +++++----- .../products/auth/quick-start/+page.markdoc | 70 +++++----- .../auth/server-side-rendering/+page.markdoc | 17 ++- .../docs/products/auth/teams/+page.markdoc | 12 +- .../databases/collections/+page.markdoc | 2 +- .../databases/databases/+page.markdoc | 2 +- .../databases/documents/+page.markdoc | 106 +++++++------- .../products/databases/order/+page.markdoc | 55 ++++---- .../databases/pagination/+page.markdoc | 130 +++++++++--------- .../products/databases/queries/+page.markdoc | 56 ++++---- .../databases/quick-start/+page.markdoc | 120 ++++++++-------- .../functions/development/+page.markdoc | 6 +- .../products/functions/examples/+page.markdoc | 6 +- .../functions/execution/+page.markdoc | 60 ++++---- .../products/messaging/apns/+page.markdoc | 2 +- .../docs/products/messaging/fcm/+page.markdoc | 2 +- .../products/messaging/mailgun/+page.markdoc | 4 +- .../products/messaging/messages/+page.markdoc | 10 +- .../products/messaging/msg91/+page.markdoc | 4 +- .../send-email-messages/+page.markdoc | 8 +- .../send-push-notifications/+page.markdoc | 2 +- .../messaging/send-sms-messages/+page.markdoc | 8 +- .../products/messaging/sendgrid/+page.markdoc | 4 +- .../products/messaging/smtp/+page.markdoc | 4 +- .../products/messaging/telesign/+page.markdoc | 4 +- .../messaging/textmagic/+page.markdoc | 4 +- .../products/messaging/topics/+page.markdoc | 4 +- .../products/messaging/twilio/+page.markdoc | 4 +- .../products/messaging/vonage/+page.markdoc | 4 +- .../products/storage/buckets/+page.markdoc | 2 +- .../products/storage/images/+page.markdoc | 8 +- .../storage/quick-start/+page.markdoc | 54 ++++---- .../storage/upload-download/+page.markdoc | 42 +++--- .../docs/quick-starts/angular/+page.markdoc | 2 +- .../docs/quick-starts/nextjs/+page.markdoc | 2 +- .../docs/quick-starts/nuxt/+page.markdoc | 2 +- .../docs/quick-starts/react/+page.markdoc | 2 +- .../docs/quick-starts/refine/+page.markdoc | 2 +- .../docs/quick-starts/sveltekit/+page.markdoc | 2 +- .../docs/quick-starts/vue/+page.markdoc | 2 +- .../docs/quick-starts/web/+page.markdoc | 2 +- .../docs/references/quick-start/+page.markdoc | 26 ++-- src/routes/docs/sdks/+page.markdoc | 10 +- .../docs/tutorials/react/step-3/+page.markdoc | 2 +- .../docs/tutorials/react/step-4/+page.markdoc | 8 +- .../docs/tutorials/react/step-5/+page.markdoc | 2 +- .../docs/tutorials/react/step-6/+page.markdoc | 2 +- .../docs/tutorials/react/step-7/+page.markdoc | 2 +- .../tutorials/sveltekit/step-3/+page.markdoc | 2 +- .../tutorials/sveltekit/step-4/+page.markdoc | 2 +- .../tutorials/sveltekit/step-6/+page.markdoc | 2 +- .../tutorials/sveltekit/step-7/+page.markdoc | 2 +- .../docs/tutorials/vue/step-3/+page.markdoc | 2 +- .../docs/tutorials/vue/step-4/+page.markdoc | 2 +- .../docs/tutorials/vue/step-6/+page.markdoc | 2 +- 81 files changed, 709 insertions(+), 730 deletions(-) diff --git a/src/routes/blog/post/accessibility-in-pink-design/+page.markdoc b/src/routes/blog/post/accessibility-in-pink-design/+page.markdoc index ab3af2eef4..320b55be57 100644 --- a/src/routes/blog/post/accessibility-in-pink-design/+page.markdoc +++ b/src/routes/blog/post/accessibility-in-pink-design/+page.markdoc @@ -47,7 +47,7 @@ It is possible to enhance accessibility through development as well. In collabor Browsers have a default font size that users can change via the browser setting. A pixel is an absolute unit for fixed sizes and spaces that ignores browser settings. This means that if we are using pixels and a user (with or without vision impairment) changes the font size in their browser settings, their setting won't affect our product. That being said, pixels should not cause any problems if the user zooms in, but we make no assumptions about users' preferences. This is why we decided to define the font size in REM, which is a relative unit. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/announcing-two-factor-authentication/+page.markdoc b/src/routes/blog/post/announcing-two-factor-authentication/+page.markdoc index 68b511dce5..656a9e5471 100644 --- a/src/routes/blog/post/announcing-two-factor-authentication/+page.markdoc +++ b/src/routes/blog/post/announcing-two-factor-authentication/+page.markdoc @@ -39,7 +39,7 @@ One great aspect of Appwrite 2FA is that it can be used in conjunction with any To use 2FA, it needs to be enabled on a user’s account. This can be achieved by calling `account.updateMFA()`. -```js +```client-web import { Client, Account } from "appwrite"; // Init SDK diff --git a/src/routes/blog/post/enhancing-type-safety/+page.markdoc b/src/routes/blog/post/enhancing-type-safety/+page.markdoc index 43163fd454..158cd0acf6 100644 --- a/src/routes/blog/post/enhancing-type-safety/+page.markdoc +++ b/src/routes/blog/post/enhancing-type-safety/+page.markdoc @@ -65,7 +65,7 @@ Code maintainability is extremely important for any piece of software, which is With the latest release of Appwrite, we have taken steps to improve type safety within our SDKs by leveraging enums. We have replaced all magic literals, such as constants needed for OAuth adapters, with enums to simplify the developer experience for all those who are building with Appwrite. -```js +```client-web import { Client, Account, OAuthProvider } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/enums-api-design/+page.markdoc b/src/routes/blog/post/enums-api-design/+page.markdoc index 1831dc5264..99413b1180 100644 --- a/src/routes/blog/post/enums-api-design/+page.markdoc +++ b/src/routes/blog/post/enums-api-design/+page.markdoc @@ -74,7 +74,7 @@ By being aware of these pitfalls and employing strategies to avoid them, you can With the latest release of Appwrite, we have taken steps to improve type safety within our SDKs by leveraging enums. We have replaced all magic literals, such as constants needed for OAuth adapters, with enums to simplify the developer experience and make it less error-prone for all those who are building with Appwrite. This change exemplifies our commitment to robust and user-friendly API design. -```js +```client-web import { Client, Account, OAuthProvider } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/improve-ux-passwordless-auth/+page.markdoc b/src/routes/blog/post/improve-ux-passwordless-auth/+page.markdoc index bb0cfc1838..4d00f5643b 100644 --- a/src/routes/blog/post/improve-ux-passwordless-auth/+page.markdoc +++ b/src/routes/blog/post/improve-ux-passwordless-auth/+page.markdoc @@ -69,7 +69,7 @@ Magic URL authentication is a two-step process in Appwrite. First, we initialize the login process by sending an email with the magic URL. If the email has never been used, a new account is also generated. -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -99,7 +99,7 @@ Email OTP authentication is a two-step process in Appwrite. First, we initialize the login process by sending an email. If the email has never been used, a new account is also generated. -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -134,7 +134,7 @@ Phone authentication is a two-step process in Appwrite. First, we initialize the login process by sending an SMS. If the phone number has never been used, a new account is also generated. -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() diff --git a/src/routes/blog/post/introducing-enum-sdk-support/+page.markdoc b/src/routes/blog/post/introducing-enum-sdk-support/+page.markdoc index b561fe873c..b6d3978e7f 100644 --- a/src/routes/blog/post/introducing-enum-sdk-support/+page.markdoc +++ b/src/routes/blog/post/introducing-enum-sdk-support/+page.markdoc @@ -25,7 +25,7 @@ This new feature, however, ensures you can use more readable and self-documentin Bringing along benefits such as massively reducing friction when using routes that have predefined parameters. One of the most common examples of SDK Enums is OAuth providers. To log in with Apple, you must pass the `apple` string as the provider. With enums, you'll be able to pass `OAuthProvider.Apple` instead. -```js +```client-web import { Client, Account, OAuthProvider } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/oauth-openid/+page.markdoc b/src/routes/blog/post/oauth-openid/+page.markdoc index 0b401fd318..c58238685d 100644 --- a/src/routes/blog/post/oauth-openid/+page.markdoc +++ b/src/routes/blog/post/oauth-openid/+page.markdoc @@ -90,7 +90,7 @@ Appwrite provides the necessary redirect URL to add to your OIDC app configurati Once that is done, you can use any of the Appwrite client SDKs to implement OAuth 2.0 or OIDC authentication in just a few lines of code. -```js +```client-web import { Client, Account, OAuthProvider } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/password-hashing-algorithms/+page.markdoc b/src/routes/blog/post/password-hashing-algorithms/+page.markdoc index bc5a473e50..0806b54cc5 100644 --- a/src/routes/blog/post/password-hashing-algorithms/+page.markdoc +++ b/src/routes/blog/post/password-hashing-algorithms/+page.markdoc @@ -74,7 +74,7 @@ PBKDF2 is a widely-used password hashing algorithm that iteratively applies a ps Appwrite Authentication also leverages password hashing algorithms to allow developers to secure their users’ passwords via password hashing algorithms. Appwrite uses the `Argon2id` algorithm to hash the password when a user creates an account from a client-side application. Appwrite’s SDKs offer a simple abstraction for the Appwrite Accounts API to let developers implement this, like the following example: -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/push-notifications-best-practices/+page.markdoc b/src/routes/blog/post/push-notifications-best-practices/+page.markdoc index 812f5eefcb..3b05b72011 100644 --- a/src/routes/blog/post/push-notifications-best-practices/+page.markdoc +++ b/src/routes/blog/post/push-notifications-best-practices/+page.markdoc @@ -53,7 +53,7 @@ The content of the messages plays a crucial role. Here are some best practices t The newly released Appwrite Messaging substantially simplifies your process of sending out push notifications to your application’s users. We have added simple-to-use adapters for Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNS) to let you send push notifications to let you send push notifications to both Android and iOS users. -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/blog/post/simplify-messaging-twilio/+page.markdoc b/src/routes/blog/post/simplify-messaging-twilio/+page.markdoc index 4cdb74aeae..261fdc4c36 100644 --- a/src/routes/blog/post/simplify-messaging-twilio/+page.markdoc +++ b/src/routes/blog/post/simplify-messaging-twilio/+page.markdoc @@ -70,7 +70,7 @@ Here's an overview of the Twilio Programmable Messaging: As a part of our latest release, Appwrite 1.5, we have launched a new product, Messaging, that helps developers implement communication services within their applications. As a part of the SMS offering within Messaging, we have added an adapter to integrate Twilio Programmable Messaging with Appwrite. Once you have access to your account SID, auth token, and phone number from Twilio, you will be able to send messages to your users with just a few lines of code. -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/blog/post/understand-data-queries/+page.markdoc b/src/routes/blog/post/understand-data-queries/+page.markdoc index 312fa3adf3..cedb149531 100644 --- a/src/routes/blog/post/understand-data-queries/+page.markdoc +++ b/src/routes/blog/post/understand-data-queries/+page.markdoc @@ -73,7 +73,7 @@ One of the data retrieval APIs the Appwrite Database offers is a list documents - `OR` operation: This operator allows nesting queries in an OR condition. - `CONTAINS` operation: The contains operator allows filtering by values that are contained in an array. -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() diff --git a/src/routes/blog/post/valentines-day-sonnet-generator/+page.markdoc b/src/routes/blog/post/valentines-day-sonnet-generator/+page.markdoc index 6d91047bb5..2f4d0e2e52 100644 --- a/src/routes/blog/post/valentines-day-sonnet-generator/+page.markdoc +++ b/src/routes/blog/post/valentines-day-sonnet-generator/+page.markdoc @@ -160,7 +160,7 @@ The original function provided through this template used OpenAI’s GPT-3.5-Tur After that is done, we need to visit the `src/main.js` file and replace the existing code with the following: -```js +```client-web import { OpenAI } from 'openai'; import { getStaticFile, throwIfMissing } from './utils.js'; diff --git a/src/routes/docs/advanced/platform/message-templates/+page.markdoc b/src/routes/docs/advanced/platform/message-templates/+page.markdoc index dbafc3fbf5..f53c7ecf2f 100644 --- a/src/routes/docs/advanced/platform/message-templates/+page.markdoc +++ b/src/routes/docs/advanced/platform/message-templates/+page.markdoc @@ -122,7 +122,7 @@ You can send messages in different languages by setting the locale with `client. For example, you can send an email verification in French. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client(); @@ -144,7 +144,7 @@ promise.then(function (response) { }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -167,7 +167,7 @@ void main() { // Init SDK } ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account @@ -181,7 +181,7 @@ val account = Account(client) val response = account.createVerification('https://example.com') ``` -```swift +```client-apple import Appwrite let client = Client() diff --git a/src/routes/docs/advanced/platform/permissions/+page.markdoc b/src/routes/docs/advanced/platform/permissions/+page.markdoc index 554d6005f8..13f99a2686 100644 --- a/src/routes/docs/advanced/platform/permissions/+page.markdoc +++ b/src/routes/docs/advanced/platform/permissions/+page.markdoc @@ -67,7 +67,7 @@ The following examples are using the [Appwrite Web SDK](https://github.com/appwr In the following example, we are creating a document that can be read by anyone, edited by writers or admins, and deleted by administrators or a user with the user ID `user:5c1f88b42259e`. -```js +```client-web import { Client, Databases, Permission, Role } from "appwrite"; const client = new Client() @@ -100,7 +100,7 @@ promise.then(function (response) { In the following example, we are creating a document that can be read by members of the team with ID `5c1f88b87435e` and can only be edited or deleted by members of the same team that possess the team role `owner`. -```js +```client-web import { Client, Databases, Permission, Role } from "appwrite"; const client = new Client() diff --git a/src/routes/docs/apis/graphql/+page.markdoc b/src/routes/docs/apis/graphql/+page.markdoc index 19ecee0558..444c4679bf 100644 --- a/src/routes/docs/apis/graphql/+page.markdoc +++ b/src/routes/docs/apis/graphql/+page.markdoc @@ -229,7 +229,7 @@ This allows you to execute complex actions in a single network request. Appwrite SDKs also support GraphQL in addition to the REST services. {% multicode %} -```js +```client-web import { Client, Graphql } from "appwrite"; const client = new Client() @@ -266,7 +266,7 @@ mutation.then(response => { console.log(error); }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -303,45 +303,7 @@ mutation.then((response) { print(error.message); }); ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Graphql - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val graphql = Graphql(client) - -try { - val response = graphql.mutation(mapOf( - "query" to """mutation CreateAccount( - ${'$'}email: String!, - ${'$'}password: String!, - ${'$'}name: String - ) { - accountCreate( - email: ${'$'}email, - password: ${'$'}password, - name: ${'$'}name, - userId: "unique()" - ) { - _id - } - }""", - "variables" to mapOf( - "email" to "...", - "password" to "...", - "name" to "..." - ) - )) - - Log.d(javaClass.name, response) -} catch (ex: AppwriteException) { - ex.printStackTrace() -} -``` -```swift +```client-apple import Appwrite let client = Client() @@ -381,4 +343,42 @@ do { print(error.localizedDescription) } ``` +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Graphql + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val graphql = Graphql(client) + +try { + val response = graphql.mutation(mapOf( + "query" to """mutation CreateAccount( + ${'$'}email: String!, + ${'$'}password: String!, + ${'$'}name: String + ) { + accountCreate( + email: ${'$'}email, + password: ${'$'}password, + name: ${'$'}name, + userId: "unique()" + ) { + _id + } + }""", + "variables" to mapOf( + "email" to "...", + "password" to "...", + "name" to "..." + ) + )) + + Log.d(javaClass.name, response) +} catch (ex: AppwriteException) { + ex.printStackTrace() +} +``` {% /multicode %} diff --git a/src/routes/docs/apis/realtime/+page.markdoc b/src/routes/docs/apis/realtime/+page.markdoc index 0a5bfbb369..db5252f7c2 100644 --- a/src/routes/docs/apis/realtime/+page.markdoc +++ b/src/routes/docs/apis/realtime/+page.markdoc @@ -11,7 +11,7 @@ Instead of requesting new data via HTTP, the subscription will receive new data This lets you build an interactive and responsive user experience by providing information from all of Appwrite's services in realtime. The example below shows subscribing to realtime events for file uploads. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client() @@ -27,7 +27,7 @@ client.subscribe('files', response => { }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -47,7 +47,7 @@ subscription.stream.listen((response) { }); ``` -```swift +```client-apple import Appwrite import AppwriteModels @@ -66,7 +66,7 @@ let subscription = realtime.subscribe(channels: ["files"]) { response in } ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Realtime @@ -113,7 +113,7 @@ The examples below will show you how you can use Realtime in various ways. In this example we are subscribing to all updates related to our account by using the `account` channel. This will be triggered by any update related to the authenticated user, like updating the user's name or e-mail address. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client() @@ -126,7 +126,7 @@ client.subscribe('account', response => { }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -143,7 +143,7 @@ subscription.stream.listen((response) { }) ``` -```swift +```client-apple import Appwrite import AppwriteModels @@ -159,7 +159,7 @@ let subscription = realtime.subscribe(channel: "account", callback: { response i }) ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Realtime @@ -184,7 +184,7 @@ You can also listen to multiple channels at once by passing an array of channels In this example we are listening to the document A and all files by subscribing to the `databases.A.collections.A.documents.A` and `files` channels. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client() @@ -197,7 +197,7 @@ client.subscribe(['collections.A.documents.A', 'files'], response => { }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -214,7 +214,7 @@ subscription.stream.listen((response) { }) ``` -```swift +```client-apple import Appwrite import AppwriteModels @@ -230,7 +230,7 @@ realtime.subscribe(channels: ["databases.A.collections.A.documents.A", "files"]) } ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Realtime @@ -252,7 +252,7 @@ realtime.subscribe("databases.A.collections.A.documents.A", "files") { If you no longer want to receive updates from a subscription, you can unsubscribe so that your callbacks are no longer called. Leaving old subscriptions alive and resubscribing can result in duplicate subscriptions and cause race conditions. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client() @@ -268,7 +268,7 @@ const unsubscribe = client.subscribe('files', response => { unsubscribe(); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -288,7 +288,7 @@ subscription.stream.listen((response) { subscription.close(); ``` -```swift +```client-apple import Appwrite let client = Client() @@ -303,7 +303,7 @@ let subscription = realtime.subscribe(channel: "files") { response in subscription.close() ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Realtime @@ -469,28 +469,28 @@ The SDK will guess the endpoint of the Realtime API when setting the endpoint of By default the endpoint is `wss://cloud.appwrite.io/v1/realtime`. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client(); client.setEndpointRealtime('wss://cloud.appwrite.io/v1/realtime'); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client(); client.setEndpointRealtime('wss://cloud.appwrite.io/v1/realtime'); ``` -```swift +```client-apple import Appwrite let client = Client() client.setEndpointRealtime("wss://cloud.appwrite.io/v1/realtime") ``` -```kotlin +```client-android-kotlin import io.appwrite.Client val client = Client(context) diff --git a/src/routes/docs/products/auth/2fa/+page.markdoc b/src/routes/docs/products/auth/2fa/+page.markdoc index 47f49bc019..843a4079a4 100644 --- a/src/routes/docs/products/auth/2fa/+page.markdoc +++ b/src/routes/docs/products/auth/2fa/+page.markdoc @@ -27,7 +27,7 @@ the 2FA is enforced. Initialize your Appwrite SDK's `Client` and `Account`. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client(); @@ -39,7 +39,7 @@ client .setProject('') // Your project ID ; ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -53,7 +53,7 @@ void main() { // Init SDK } ``` -```swift +```client-apple import Appwrite let client = Client() @@ -63,7 +63,7 @@ let client = Client() let account = Account(client) ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account diff --git a/src/routes/docs/products/auth/accounts/+page.markdoc b/src/routes/docs/products/auth/accounts/+page.markdoc index 8ffa48d58c..8515ea8c2d 100644 --- a/src/routes/docs/products/auth/accounts/+page.markdoc +++ b/src/routes/docs/products/auth/accounts/+page.markdoc @@ -27,7 +27,7 @@ You can store user preferences on a user's account using Appwrite's [Update Pref Preferences are stored as a key-value JSON object. The maximum allowed size for preferences is 64kB, and an error will be thrown if this limit is exceeded. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -44,7 +44,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -60,7 +60,23 @@ final user = await account.updatePrefs( } ); ``` -```kotlin +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let user = try await account.updatePrefs( + prefs: [ + "darkTheme": true, + "language": "en" + ] +) +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account @@ -77,22 +93,6 @@ val user = account.updatePrefs( ) ) ``` -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let user = try await account.updatePrefs( - prefs: [ - "darkTheme": true, - "language": "en" - ] -) -``` ```graphql mutation { accountUpdatePrefs( @@ -111,7 +111,7 @@ mutation { After a user's preferences are updated, they can be retrieved using the [get account preferences](/docs/references/cloud/client-web/account#getPrefs) endpoint. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -128,7 +128,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -139,7 +139,7 @@ final account = Account(client); final prefs = await account.getPrefs(); ``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account @@ -151,7 +151,7 @@ val account = Account(client) val prefs = account.getPrefs() ``` -```swift +```client-apple import Appwrite let client = Client() diff --git a/src/routes/docs/products/auth/anonymous/+page.markdoc b/src/routes/docs/products/auth/anonymous/+page.markdoc index 10d866b149..4caa0ba1b4 100644 --- a/src/routes/docs/products/auth/anonymous/+page.markdoc +++ b/src/routes/docs/products/auth/anonymous/+page.markdoc @@ -13,7 +13,7 @@ Anonymous sessions allow you to implement **guest** users. Guest users let you s Create an anonymous session with [Create Anonymous Session](/docs/references/cloud/client-web/account#createAnonymousSession) method. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -30,7 +30,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -41,28 +41,28 @@ final account = Account(client); final user = await account.createAnonymousSession(); ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Account +```client-apple +import Appwrite -val client = Client() +let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val account = Account(client) +let account = Account(client) -val user = account.createAnonymousSession() +let user = try await account.createAnonymousSession() ``` -```swift -import Appwrite +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Account -let client = Client() +val client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let account = Account(client) +val account = Account(client) -let user = try await account.createAnonymousSession() +val user = account.createAnonymousSession() ``` ```graphql mutation { diff --git a/src/routes/docs/products/auth/custom-token/+page.markdoc b/src/routes/docs/products/auth/custom-token/+page.markdoc index f9f093a1c5..d8590b8311 100644 --- a/src/routes/docs/products/auth/custom-token/+page.markdoc +++ b/src/routes/docs/products/auth/custom-token/+page.markdoc @@ -16,7 +16,7 @@ Custom token allows you to use [Server SDK](/docs/sdks#server) to generate token Once you have your server endpoint prepared either in an Appwrite Function or a server integration, you can use the [Create token](/docs/references/cloud/server-nodejs/users#createToken) endpoint of the [Users API](/docs/products/auth/users) to generate a token. {% multicode %} -```js +```server-nodejs import { Client, Users } from "node-appwrite"; const client = new Client() @@ -165,7 +165,7 @@ Once the client receives a token secret, we can use it to authenticate the user {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -180,7 +180,7 @@ const session = await account.createSession( ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -194,35 +194,34 @@ final session = await account.createSession( secret: '[SECRET]' ); ``` +```client-apple +import Appwrite -```kotlin -import io.appwrite.Client -import io.appwrite.services.Account - -val client = Client() +let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") .setProject(""); -val account = Account(client); +let account = Account(client); -val session = account.createSession( - userId = "[USER_ID]", - secret = "[SECRET]" +let session = try await account.createSession( + userId: "[USER_ID]", + secret: "[SECRET]" ); ``` -```swift -import Appwrite +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Account -let client = Client() +val client = Client() .setEndpoint("https://cloud.appwrite.io/v1") .setProject(""); -let account = Account(client); +val account = Account(client); -let session = try await account.createSession( - userId: "[USER_ID]", - secret: "[SECRET]" +val session = account.createSession( + userId = "[USER_ID]", + secret = "[SECRET]" ); ``` diff --git a/src/routes/docs/products/auth/email-otp/+page.markdoc b/src/routes/docs/products/auth/email-otp/+page.markdoc index fc05071b4f..635d13e6bf 100644 --- a/src/routes/docs/products/auth/email-otp/+page.markdoc +++ b/src/routes/docs/products/auth/email-otp/+page.markdoc @@ -30,7 +30,7 @@ Send an an email to initiate the authentication process. A **new account** will {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -47,7 +47,7 @@ const sessionToken = await account.createEmailToken( const userId = sessionToken.userId; ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -63,8 +63,24 @@ final sessionToken = await account.createEmailToken( final userId = sessionToken.userId; ``` +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject(""); + +let account = Account(client); + +let sessionToken = try await account.createEmailToken( + userId: ID.unique(), + email: "email@example.com" +); + +let userId = sessionToken.userId; +``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account import io.appwrite.ID @@ -82,24 +98,6 @@ val sessionToken = account.createEmailToken( val userId = sessionToken.userId; ``` - -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject(""); - -let account = Account(client); - -let sessionToken = try await account.createEmailToken( - userId: ID.unique(), - email: "email@example.com" -); - -let userId = sessionToken.userId; -``` - ```graphql mutation { accountCreateEmailToken(userId: "unique()", email: "email@example.com") { @@ -119,7 +117,7 @@ After initiating the email OTP authentication process, the returned user ID and {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -134,7 +132,7 @@ const session = await account.createSession( ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -148,8 +146,21 @@ final session = await account.createSession( secret: '[SECRET]' ); ``` +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject(""); -```kotlin +let account = Account(client); + +let session = try await account.createSession( + userId: userId, + secret: "[SECRET]" +); +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account import io.appwrite.ID @@ -166,21 +177,6 @@ val session = account.createSession( ); ``` -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject(""); - -let account = Account(client); - -let session = try await account.createSession( - userId: userId, - secret: "[SECRET]" -); -``` - ```graphql mutation { accountcreateSession(userId: "", secret: "[SECRET]") { @@ -203,7 +199,7 @@ A security phrase is a randomly generated phrase provided on the login page, as By default, security phrases are disabled. To enable a security phrase in Email OTP, enable it in first step of the authentication flow. {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() diff --git a/src/routes/docs/products/auth/email-password/+page.markdoc b/src/routes/docs/products/auth/email-password/+page.markdoc index 2ae01695ff..8bcffbda94 100644 --- a/src/routes/docs/products/auth/email-password/+page.markdoc +++ b/src/routes/docs/products/auth/email-password/+page.markdoc @@ -10,7 +10,7 @@ Email and password login is the most commonly used authentication method. Appwri You can use the Appwrite Client SDKs to create an account using email and password. -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -36,7 +36,7 @@ After an account is created, it can be verified through the account create verif First, send a verification email. Specify a redirect URL which users will be redirected to. The verification secrets will be appended as query parameters to the redirect URL. In this example, the redirect URL is `https://example.com/verify`. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -58,7 +58,7 @@ Next, implement the verification page in your app. This page will parse the secr Since the secrets are passed in through url params, it will be easiest to perform this step in the browser. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -84,7 +84,7 @@ promise.then(function (response) { After you've created your account, users can be logged in using the Create Email Session route. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -108,7 +108,7 @@ If a user forgets their password, they can initiate a password recovery flow to Only redirect URLs to domains added as a platform on your Appwrite Console will be accepted. URLs not added as a platform are rejected to protect against redirect attacks. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -126,7 +126,7 @@ promise.then(function (response) { After receiving an email with the secret attached to the redirect link, submit a request to the Create Password Recovery (confirmation) endpoint to complete the recovery flow. The verification link sent to the user's email address is valid for 1 hour. -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() diff --git a/src/routes/docs/products/auth/jwt/+page.markdoc b/src/routes/docs/products/auth/jwt/+page.markdoc index 24f1a181b1..57a9a79042 100644 --- a/src/routes/docs/products/auth/jwt/+page.markdoc +++ b/src/routes/docs/products/auth/jwt/+page.markdoc @@ -23,7 +23,7 @@ You need to create a session using the Client SDKs **before** generating a JWT. You can generate a JWT like this on a [Client SDK](/docs/sdks#client). {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -34,7 +34,7 @@ const account = new Account(client); const user = await account.createJWT(); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -45,28 +45,28 @@ final account = Account(client); final jwt = await account.createJWT(); ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Account +```client-apple +import Appwrite -val client = Client(context) +let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val account = Account(client) +let account = Account(client) -val jwt = account.createJWT() +let jwt = try await account.createJWT() ``` -```swift -import Appwrite +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Account -let client = Client() +val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let account = Account(client) +val account = Account(client) -let jwt = try await account.createJWT() +val jwt = account.createJWT() ``` ```graphql mutation { diff --git a/src/routes/docs/products/auth/labels/+page.markdoc b/src/routes/docs/products/auth/labels/+page.markdoc index 4e59914c91..07fd955a12 100644 --- a/src/routes/docs/products/auth/labels/+page.markdoc +++ b/src/routes/docs/products/auth/labels/+page.markdoc @@ -7,7 +7,7 @@ description: Organize your users and grant custom permissions for subscriptions Labels are a good way to categorize a user to grant them access to resources. For example, a `subscriber` label can be added to a user once they've purchased a subscription. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); const client = new sdk.Client() diff --git a/src/routes/docs/products/auth/magic-url/+page.markdoc b/src/routes/docs/products/auth/magic-url/+page.markdoc index f371157c7a..0d7d9ef4cd 100644 --- a/src/routes/docs/products/auth/magic-url/+page.markdoc +++ b/src/routes/docs/products/auth/magic-url/+page.markdoc @@ -11,7 +11,7 @@ Magic URL is a password-less way to authenticate users. When a user logs in by p Initialize the log in process with the [Create Magic URL Session](/docs/references/cloud/client-web/account#createMagicURLSession) route. If the email has never been used, a **new account is generated**, then the user will receive an email. If the email is already attached to an account, the **user ID is ignored** and the user will receive a link in their email. {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -52,7 +52,7 @@ After receiving your secret from an email, you can create a session. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -67,7 +67,6 @@ const userId = urlParams.get('userId'); const user = await account.updateMagicURLSession(userId, secret); ``` - ```graphql mutation { accountUpdateMagicURLSession( diff --git a/src/routes/docs/products/auth/oauth2/+page.markdoc b/src/routes/docs/products/auth/oauth2/+page.markdoc index 28fdb6f4a0..4303f634d7 100644 --- a/src/routes/docs/products/auth/oauth2/+page.markdoc +++ b/src/routes/docs/products/auth/oauth2/+page.markdoc @@ -142,7 +142,7 @@ After authenticating a user through their OAuth 2 provider, you can fetch their After creating an OAuth 2 session, you can fetch the session to get information about the provider. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client(); @@ -157,7 +157,7 @@ console.log(session.providerUid); console.log(session.providerAccessToken); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -175,19 +175,17 @@ print(session.provider); print(session.providerUid); print(session.providerAccessToken); ``` +```client-apple +import Appwrite -```kotlin -import io.appwrite.Client -import io.appwrite.services.Account - -val client = Client(context) +let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID -val account = Account(client) +let account = Account(client) -val response = account.getSession( - sessionId = "[SESSION_ID]" +let session = try await account.getSession( + sessionId: "[SESSION_ID]" ) // Provider information @@ -195,18 +193,18 @@ print(session.provider); print(session.providerUid); print(session.providerAccessToken); ``` +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Account -```swift -import Appwrite - -let client = Client() +val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID -let account = Account(client) +val account = Account(client) -let session = try await account.getSession( - sessionId: "[SESSION_ID]" +val response = account.getSession( + sessionId = "[SESSION_ID]" ) // Provider information @@ -233,8 +231,7 @@ You can use the `providerAccessToken` to make requests to your OAuth 2 provider. OAuth 2 sessions expire to protect from security risks. OAuth 2 sessions should be refreshed periodically, so access tokens don't expire. Check value of `providerAccessTokenExpiry` to know if the token is expired or is about to expire. Refreshing before every request might cause rate limit problems. You can do this by calling the [Update OAuth Session](/docs/references/cloud/client-web/account#updateSession) endpoint when ever your user visits your app. {% multicode %} -```js -// Web +```client-web const promise = account.updateSession('[SESSION_ID]'); promise.then(function (response) { @@ -243,8 +240,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart -// Flutter +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -257,8 +253,20 @@ final result = await account.updateSession( sessionId: '[SESSION_ID]' ); ``` -```kotlin -// Android +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +let account = Account(client) + +let session = try await account.updateSession( + sessionId: "[SESSION_ID]" +); +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account @@ -272,20 +280,6 @@ val response = account.updateSession( sessionId = "[SESSION_ID]" ); ``` -```swift -// Apple -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -let account = Account(client) - -let session = try await account.updateSession( - sessionId: "[SESSION_ID]" -); -``` {% /multicode %} diff --git a/src/routes/docs/products/auth/phone-sms/+page.markdoc b/src/routes/docs/products/auth/phone-sms/+page.markdoc index b3f840a37f..085a782a68 100644 --- a/src/routes/docs/products/auth/phone-sms/+page.markdoc +++ b/src/routes/docs/products/auth/phone-sms/+page.markdoc @@ -14,7 +14,7 @@ Send an SMS message to initiate the authentication process. A **new account** wi {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -31,7 +31,7 @@ const sessionToken = await account.createPhoneSession( const userId = sessionToken.userId; ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -47,8 +47,24 @@ final sessionToken = await account.createPhoneSession( final userId = sessionToken.userId; ``` +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject(""); + +let account = Account(client); + +let sessionToken = try await account.createPhoneSession( + userId: ID.unique(), + phone: "+14255550123" +); + +let userId = sessionToken.userId; +``` -```kotlin +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account import io.appwrite.ID @@ -67,23 +83,6 @@ val sessionToken = account.createPhoneSession( val userId = sessionToken.userId; ``` -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject(""); - -let account = Account(client); - -let sessionToken = try await account.createPhoneSession( - userId: ID.unique(), - phone: "+14255550123" -); - -let userId = sessionToken.userId; -``` - ```graphql mutation { accountCreatePhoneSession(userId: "unique()", phone: "+14255550123") { @@ -103,7 +102,7 @@ After initiating the phone authentication process, the returned user ID and secr {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -118,7 +117,7 @@ const session = await account.updatePhoneSession( ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -132,8 +131,21 @@ final session = await account.updatePhoneSession( secret: '[SECRET]' ); ``` +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject(""); -```kotlin +let account = Account(client); + +let session = try await account.updatePhoneSession( + userId: userId, + secret: "[SECRET]" +); +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account import io.appwrite.ID @@ -150,21 +162,6 @@ val session = account.updatePhoneSession( ); ``` -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject(""); - -let account = Account(client); - -let session = try await account.updatePhoneSession( - userId: userId, - secret: "[SECRET]" -); -``` - ```graphql mutation { accountUpdatePhoneSession(userId: "[USER_ID]", secret: "[SECRET]") { diff --git a/src/routes/docs/products/auth/quick-start/+page.markdoc b/src/routes/docs/products/auth/quick-start/+page.markdoc index 10e8bdddaf..203c72ee68 100644 --- a/src/routes/docs/products/auth/quick-start/+page.markdoc +++ b/src/routes/docs/products/auth/quick-start/+page.markdoc @@ -11,7 +11,7 @@ Adding signup and login is as simple as this. You can use the Appwrite [Client SDKs](/docs/sdks#client) to create an account using email and password. {% multicode %} -```js +```client-web import { Client, Account, ID } from "appwrite"; const client = new Client() @@ -28,7 +28,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -43,7 +43,22 @@ final user = await account.create( password: 'password', ); ``` -```kotlin +```client-apple +import Appwrite + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +let account = Account(client) + +let user = try await account.create( + userId: ID.unique(), + email: "email@example.com", + password: "password" +) +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Account import io.appwrite.ID @@ -60,21 +75,6 @@ val user = account.create( password = "password" ) ``` -```swift -import Appwrite - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -let account = Account(client) - -let user = try await account.create( - userId: ID.unique(), - email: "email@example.com", - password: "password" -) -``` ```graphql mutation { @@ -92,7 +92,7 @@ mutation { After you've created your account, users can be logged in using the [Create Email Session](/docs/references/cloud/client-web/account#createEmailSession) method. {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; const client = new Client() @@ -110,7 +110,7 @@ promise.then(function (response) { }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; final client = Client() @@ -125,34 +125,34 @@ final session = await account.createEmailSession( ); ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Account +```client-apple +import Appwrite -val client = Client() +let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val account = Account(client) +let account = Account(client) -val session = account.createEmailSession( - email = "email@example.com", - password = "password" +let session = try await account.createEmailSession( + email: "email@example.com", + password: "password" ) ``` -```swift -import Appwrite +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Account -let client = Client() +val client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -let account = Account(client) +val account = Account(client) -let session = try await account.createEmailSession( - email: "email@example.com", - password: "password" +val session = account.createEmailSession( + email = "email@example.com", + password = "password" ) ``` diff --git a/src/routes/docs/products/auth/server-side-rendering/+page.markdoc b/src/routes/docs/products/auth/server-side-rendering/+page.markdoc index 657d9f5ee4..e12445d2f7 100644 --- a/src/routes/docs/products/auth/server-side-rendering/+page.markdoc +++ b/src/routes/docs/products/auth/server-side-rendering/+page.markdoc @@ -59,7 +59,7 @@ The API key should have the following scope in order to perform authentication: | Sessions | `sessions.write` | Allows API key to create, update, and delete sessions. | {% multicode %} -```js +```server-nodejs import { Client } from "node-appwrite"; // Using the server SDK const adminClient = new Client() @@ -90,7 +90,7 @@ It will be initialized with the session, usually stored within a cookie. You should create a new client for each request and **never** share the client between requests. {% multicode %} -```js +```server-nodejs const sessionClient = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID @@ -122,7 +122,7 @@ Once you have a session object, you can store it in a cookie. This will allow yo Use the `secret` property of the session object as the cookie value. The `expire` property of the session object should be used as the cookie's max age. Here's an example with Express and PHP, but the same concepts apply to all most frameworks. {% multicode %} -```js +```server-nodejs import express from 'express'; // Initialize admin client here @@ -197,7 +197,7 @@ When the browser makes a request to your domain's endpoints, it will automatical {% multicode %} -```js +```server-nodejs // Initialize the session client here app.get('/user', async (req, res) => { @@ -286,7 +286,7 @@ You can create a guest session using the `createAnonymousSession` method. This will create a session for unauthenticated users, and each user will have their own rate limit. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -331,7 +331,7 @@ $result = $account->createAnonymousSession(); Appwrite sessions record some information about the client. To set this information in a server-side context use the `setForwardedUserAgent` to set the end-user's user agent. While optional, these can be useful for debugging and security purposes. {% multicode %} -```js +```server-nodejs client.setForwardedUserAgent(req.headers['user-agent']); ``` ```php @@ -347,7 +347,7 @@ Server-side OAuth2 authentication requires two server endpoints: Create an initial endpoint that redirects the user to the OAuth2 provider's authentication page using Appwrite's `createOAuth2Token` method. After authenticating with the provider, the user will be redirected to the `success` URL with `userId` and `secret` URL parameters. {% multicode %} -```js +```server-nodejs import { Client, Account, OAuthProvider } from "node-appwrite"; // Using the server SDK const adminClient = new Client() @@ -393,8 +393,7 @@ header('Location' . $redirectUrl); Next, create a success callback endpoint that receives the `userId` and `secret` URL parameters, and then calls `createSession` on the server side. This endpoint returns a session object, which you can store in a cookie. {% multicode %} -```js - +```server-nodejs app.get('/oauth/success', async (req, res) => { const account = new Account(adminClient); diff --git a/src/routes/docs/products/auth/teams/+page.markdoc b/src/routes/docs/products/auth/teams/+page.markdoc index d29ba80c19..004ab97a03 100644 --- a/src/routes/docs/products/auth/teams/+page.markdoc +++ b/src/routes/docs/products/auth/teams/+page.markdoc @@ -16,7 +16,7 @@ For example, we can create a team called `teachers` with roles `maths`, `science The creator of the team is also granted the `owner` role. **Only those with the `owner` role can invite and remove members**. {% multicode %} -```js +```client-web import { Client, Teams } from "appwrite"; const client = new Client(); @@ -40,7 +40,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -65,7 +65,7 @@ void main() { // Init SDK }); } ``` -```swift +```client-apple import Appwrite let client = Client() @@ -104,7 +104,7 @@ val response = teams.create( You can invite members to a team by creating team memberships. For example, inviting "David" a math teacher, to the teachers team. {% multicode %} -```js +```client-web import { Client, Teams } from "appwrite"; const client = new Client(); @@ -128,7 +128,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -153,7 +153,7 @@ void main() { // Init SDK }); } ``` -```swift +```client-apple import Appwrite let client = Client() diff --git a/src/routes/docs/products/databases/collections/+page.markdoc b/src/routes/docs/products/databases/collections/+page.markdoc index 1a4038a073..8188af32d7 100644 --- a/src/routes/docs/products/databases/collections/+page.markdoc +++ b/src/routes/docs/products/databases/collections/+page.markdoc @@ -21,7 +21,7 @@ You can also create collections programmatically using a [Server SDK](/docs/sdks {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/databases/databases/+page.markdoc b/src/routes/docs/products/databases/databases/+page.markdoc index 5402fad39c..ea8fbe0913 100644 --- a/src/routes/docs/products/databases/databases/+page.markdoc +++ b/src/routes/docs/products/databases/databases/+page.markdoc @@ -17,7 +17,7 @@ You can create a database by navigating to the **Databases** page and clicking * You can programmatically create databases using a [Server SDK](/docs/sdks#server). Appwrite [Server SDKs](/docs/sdks#server) require an [API key](/docs/advanced/platform/api-keys). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/databases/documents/+page.markdoc b/src/routes/docs/products/databases/documents/+page.markdoc index c0096debd5..c53f58224a 100644 --- a/src/routes/docs/products/databases/documents/+page.markdoc +++ b/src/routes/docs/products/databases/documents/+page.markdoc @@ -15,7 +15,7 @@ You must grant **create** permissions to users at the **collection level** befor In most use cases, you will create documents programmatically. {% multicode %} -```js +```client-web import { Client, Databases, ID } from "appwrite"; const client = new Client() @@ -37,7 +37,7 @@ promise.then(function (response) { console.log(error); }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -59,30 +59,7 @@ void main() async { } } ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Databases - -suspend fun main() { - val client = Client(applicationContext) - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - val databases = Databases(client) - - try { - val document = databases.createDocument( - databaseId = "", - collectionId = "", - documentId = ID.unique(), - data = mapOf("a" to "b"), - ) - } catch (e: Exception) { - Log.e("Appwrite", "Error: " + e.message) - } -} -``` -```swift +```client-apple import Appwrite import AppwriteModels @@ -105,6 +82,29 @@ func main() async throws { } } ``` +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Databases + +suspend fun main() { + val client = Client(applicationContext) + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + val databases = Databases(client) + + try { + val document = databases.createDocument( + databaseId = "", + collectionId = "", + documentId = ID.unique(), + data = mapOf("a" to "b"), + ) + } catch (e: Exception) { + Log.e("Appwrite", "Error: " + e.message) + } +} +``` ```graphql mutation { databasesCreateDocument( @@ -144,7 +144,7 @@ By default, results are limited to the **first 25 items**. You can change this through [pagination](/docs/products/databases/pagination). {% multicode %} -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() @@ -167,7 +167,7 @@ promise.then(function (response) { console.log(error); }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -190,7 +190,31 @@ void main() async { } } ``` -```kotlin +```client-apple +import Appwrite +import AppwriteModels + +func main() async throws { + let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + let databases = Databases(client) + + do { + let documents = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.equal("title", "Avatar") + ] + ) + } catch { + print(error.localizedDescription) + } +} +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.Query import io.appwrite.services.Databases @@ -215,30 +239,6 @@ suspend fun main() { } } ``` -```swift -import Appwrite -import AppwriteModels - -func main() async throws { - let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - let databases = Databases(client) - - do { - let documents = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.equal("title", "Avatar") - ] - ) - } catch { - print(error.localizedDescription) - } -} -``` ```graphql query { databasesListDocuments( diff --git a/src/routes/docs/products/databases/order/+page.markdoc b/src/routes/docs/products/databases/order/+page.markdoc index c14ec6c095..0304faa926 100644 --- a/src/routes/docs/products/databases/order/+page.markdoc +++ b/src/routes/docs/products/databases/order/+page.markdoc @@ -13,7 +13,7 @@ When querying using the [listDocuments](/docs/references/cloud/client-web/databa you can specify the order of the documents returned using the `Query.orderAsc()` and `Query.orderDesc()` query methods. {% multicode %} -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() @@ -31,7 +31,7 @@ databases.listDocuments( ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -55,7 +55,31 @@ void main() async { } ``` -```kotlin +```client-apple +import Appwrite +import AppwriteModels + +func main() async throws { + let client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') + .setProject(''); + + let databases = Databases(client) + + do { + let documents = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.orderAsc("title") + ] + ) + } catch { + print(error.localizedDescription) + } +} +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.Query import io.appwrite.services.Databases @@ -81,31 +105,6 @@ suspend fun main() { } ``` -```swift -import Appwrite -import AppwriteModels - -func main() async throws { - let client = Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject(''); - - let databases = Databases(client) - - do { - let documents = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.orderAsc("title") - ] - ) - } catch { - print(error.localizedDescription) - } -} -``` - ```graphql query { databasesListDocuments( diff --git a/src/routes/docs/products/databases/pagination/+page.markdoc b/src/routes/docs/products/databases/pagination/+page.markdoc index 53cd6398be..93ec2322f6 100644 --- a/src/routes/docs/products/databases/pagination/+page.markdoc +++ b/src/routes/docs/products/databases/pagination/+page.markdoc @@ -20,7 +20,7 @@ With `Query.limit()` you can define how many documents can be returned from one The `Query.offset()` is number of records you wish to skip before selecting records. {% multicode %} -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() @@ -49,7 +49,7 @@ const page2 = await databases.listDocuments( ] ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -78,61 +78,61 @@ void main() async { ); } ``` -```kotlin -import io.appwrite.Client -import io.appwrite.Query -import io.appwrite.services.Databases +```client-apple +import Appwrite +import AppwriteModels -suspend fun main() { - val client = Client(applicationContext) +func main() async throws { + let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") .setProject("") - val databases = Databases(client) + let databases = Databases(client) - val page1 = databases.listDocuments( - databaseId = "", - collectionId = "", - queries = [ + let page1 = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ Query.limit(25), Query.offset(0) ] ) - val page2 = databases.listDocuments( - databaseId = "", - collectionId = "", - queries = [ + let page2 = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ Query.limit(25), Query.offset(25) ] ) } ``` -```swift -import Appwrite -import AppwriteModels +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.Query +import io.appwrite.services.Databases -func main() async throws { - let client = Client() +suspend fun main() { + val client = Client(applicationContext) .setEndpoint("https://cloud.appwrite.io/v1") .setProject("") - let databases = Databases(client) + val databases = Databases(client) - let page1 = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ + val page1 = databases.listDocuments( + databaseId = "", + collectionId = "", + queries = [ Query.limit(25), Query.offset(0) ] ) - let page2 = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ + val page2 = databases.listDocuments( + databaseId = "", + collectionId = "", + queries = [ Query.limit(25), Query.offset(25) ] @@ -156,7 +156,7 @@ Pass the first document's ID into the `Query.cursorBefore(firstId)` query method {% multicode %} -```js +```client-web import { Databases, Query } from "appwrite"; const client = new Client() @@ -187,7 +187,7 @@ const page2 = await databases.listDocuments( ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -218,7 +218,38 @@ void main() async { } ``` -```kotlin +```client-apple +import Appwrite +import AppwriteModels + +func main() async throws { + let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + let databases = Databases(client) + + let page1 = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.limit(25) + ] + ) + + let lastId = page1.documents[page1.documents.count - 1].$id + + let page2 = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.limit(25), + Query.cursorAfter(lastId) + ] + ) +} +``` +```client-android-kotlin import android.util.Log import io.appwrite.AppwriteException import io.appwrite.Client @@ -252,37 +283,6 @@ suspend fun main() { ) } ``` -```swift -import Appwrite -import AppwriteModels - -func main() async throws { - let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - let databases = Databases(client) - - let page1 = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.limit(25) - ] - ) - - let lastId = page1.documents[page1.documents.count - 1].$id - - let page2 = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.limit(25), - Query.cursorAfter(lastId) - ] - ) -} -``` {% /multicode %} diff --git a/src/routes/docs/products/databases/queries/+page.markdoc b/src/routes/docs/products/databases/queries/+page.markdoc index 8e52504097..d202906d78 100644 --- a/src/routes/docs/products/databases/queries/+page.markdoc +++ b/src/routes/docs/products/databases/queries/+page.markdoc @@ -297,7 +297,7 @@ You can change this through [pagination](/docs/products/databases/pagination). {% multicode %} -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() @@ -315,7 +315,7 @@ databases.listDocuments( ] ); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -339,7 +339,32 @@ void main() async { } } ``` -```kotlin +```client-apple +import Appwrite +import AppwriteModels + +func main() async throws { + let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + let databases = Databases(client) + + do { + let documents = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.equal("title", ["Avatar", "Lord of the Rings"]), + Query.greaterThan("year", 1999) + ] + ) + } catch { + print(error.localizedDescription) + } +} +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.Query import io.appwrite.services.Databases @@ -365,31 +390,6 @@ suspend fun main() { } } ``` -```swift -import Appwrite -import AppwriteModels - -func main() async throws { - let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - let databases = Databases(client) - - do { - let documents = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.equal("title", ["Avatar", "Lord of the Rings"]), - Query.greaterThan("year", 1999) - ] - ) - } catch { - print(error.localizedDescription) - } -} -``` ```graphql query { databasesListDocuments( diff --git a/src/routes/docs/products/databases/quick-start/+page.markdoc b/src/routes/docs/products/databases/quick-start/+page.markdoc index 53718abba8..33a67ebc37 100644 --- a/src/routes/docs/products/databases/quick-start/+page.markdoc +++ b/src/routes/docs/products/databases/quick-start/+page.markdoc @@ -29,7 +29,7 @@ Navigate to the `Oscar` database, copy the database ID, and replace ``. {% multicode %} -```js +```client-web import { Client, Databases, ID } from "appwrite"; const client = new Client() @@ -51,7 +51,7 @@ promise.then(function (response) { console.log(error); }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -73,30 +73,7 @@ void main() async { } } ``` -```kotlin -import io.appwrite.Client -import io.appwrite.services.Databases - -suspend fun main() { - val client = Client(applicationContext) - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - val databases = Databases(client) - - try { - val document = databases.createDocument( - databaseId = "", - collectionId = "", - documentId = ID.unique(), - data = mapOf("title" to "hamlet"), - ) - } catch (e: Exception) { - Log.e("Appwrite", "Error: " + e.message) - } -} -``` -```swift +```client-apple import Appwrite import AppwriteModels @@ -119,19 +96,42 @@ func main() async throws { } } ``` +```client-android-kotlin +import io.appwrite.Client +import io.appwrite.services.Databases + +suspend fun main() { + val client = Client(applicationContext) + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + val databases = Databases(client) + + try { + val document = databases.createDocument( + databaseId = "", + collectionId = "", + documentId = ID.unique(), + data = mapOf("title" to "hamlet"), + ) + } catch (e: Exception) { + Log.e("Appwrite", "Error: " + e.message) + } +} +``` {% /multicode %} The response should look similar to this. ```json { - title: 'Hamlet', - '$id': '65013138dcd8618e80c4', - '$permissions': [], - '$createdAt': '2023-09-13T03:49:12.905+00:00', - '$updatedAt': '2023-09-13T03:49:12.905+00:00', - '$databaseId': '650125c64b3c25ce4bc4', - '$collectionId': '650125cff227cf9f95ad' + "title": "Hamlet", + "$id": "65013138dcd8618e80c4", + "$permissions": [], + "$createdAt": "2023-09-13T03:49:12.905+00:00", + "$updatedAt": "2023-09-13T03:49:12.905+00:00", + "$databaseId": "650125c64b3c25ce4bc4", + "$collectionId": "650125cff227cf9f95ad" } ``` @@ -142,7 +142,7 @@ To read and query data from your collection, use the `listDocuments` endpoint. Like the previous step, replace ``, ``, and`` with their respective IDs. {% multicode %} -```js +```client-web import { Client, Databases, Query } from "appwrite"; const client = new Client() @@ -165,7 +165,7 @@ promise.then(function (response) { console.log(error); }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() async { @@ -188,7 +188,31 @@ void main() async { } } ``` -```kotlin +```client-apple +import Appwrite +import AppwriteModels + +func main() async throws{ + let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + + let databases = Databases(client) + + do { + let documents = try await databases.listDocuments( + databaseId: "", + collectionId: "", + queries: [ + Query.equal("title", "Hamlet") + ] + ) + } catch { + print(error.localizedDescription) + } +} +``` +```client-android-kotlin import io.appwrite.Client import io.appwrite.Query import io.appwrite.services.Databases @@ -213,29 +237,5 @@ suspend fun main() { } } ``` -```swift -import Appwrite -import AppwriteModels - -func main() async throws{ - let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - - let databases = Databases(client) - - do { - let documents = try await databases.listDocuments( - databaseId: "", - collectionId: "", - queries: [ - Query.equal("title", "Hamlet") - ] - ) - } catch { - print(error.localizedDescription) - } -} -``` {% /multicode %} {% /section %} diff --git a/src/routes/docs/products/functions/development/+page.markdoc b/src/routes/docs/products/functions/development/+page.markdoc index c9e3c4df15..39cdefbbbf 100644 --- a/src/routes/docs/products/functions/development/+page.markdoc +++ b/src/routes/docs/products/functions/development/+page.markdoc @@ -19,7 +19,7 @@ Here's everything that happens during a function execution. You'll find all of these steps in a simple function like this. {% multicode %} -```js +```server-nodejs import { Client } from 'node-appwrite'; // This is your Appwrite function @@ -1316,7 +1316,7 @@ Pass in your API key as an environment variable. Never share API keys with users. {% multicode %} -```js +```server-nodejs import { Client, Databases, ID } from 'node-appwrite'; export default async ({ req, res, log, error }) => { @@ -1629,7 +1629,7 @@ If the Appwrite Function is invoked by an authenticated user, `the x-appwrite-us {% multicode %} -```js +```server-nodejs import { Client, Databases, ID } from 'node-appwrite'; export default async ({ req, res, log }) => { diff --git a/src/routes/docs/products/functions/examples/+page.markdoc b/src/routes/docs/products/functions/examples/+page.markdoc index 9a6937c23f..ac82f32ea5 100644 --- a/src/routes/docs/products/functions/examples/+page.markdoc +++ b/src/routes/docs/products/functions/examples/+page.markdoc @@ -106,7 +106,7 @@ Finally, add `bundle install` to your function's build commands in the Appwrite ## Code {% multicode %} -```js +```server-nodejs import { fetch } from 'undici'; export default async function ({ req, res }) { @@ -257,7 +257,7 @@ Create a Votes collection with the following attributes: ## Code {% multicode %} -```js +```server-nodejs import { Client, Databases, Query } from 'node-appwrite'; export default async function ({ req, res }) { @@ -513,7 +513,7 @@ Create a Messages collection with the following attributes: {% multicode %} -```js +```server-nodejs import { Client, Databases, Query, ID } from 'node-appwrite'; import querystring from 'node:querystring'; diff --git a/src/routes/docs/products/functions/execution/+page.markdoc b/src/routes/docs/products/functions/execution/+page.markdoc index 991c9fd4bc..624e67b194 100644 --- a/src/routes/docs/products/functions/execution/+page.markdoc +++ b/src/routes/docs/products/functions/execution/+page.markdoc @@ -45,7 +45,7 @@ You can invoke your Appwrite Functions directly from the Appwrite SDKs. {% tabsitem #client title="Client SDKs" %} {% multicode %} -```js +```client-web import { Client, Functions } from 'appwrite'; const client = new Client() @@ -69,7 +69,7 @@ try { } ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; import 'dart:convert'; @@ -96,7 +96,33 @@ try { } ``` -```kotlin +```client-apple +import Appwrite +import Foundation + +let client = Client() + .setEndpoint("https://cloud.appwrite.io/v1") + .setProject("") + +let functions = Functions(client) + +do { + let execution = try await functions.createExecution( + functionId: "[FUNCTION_ID]", + data: JSONSerialization.jsonObject(with: ["foo": "bar"], options: [])!, + path: "/", + method: "GET", + headers: [ + "X-Custom-Header": "123" + ] + ) + print(execution.toMap()) +} catch { + print(error.localizedDescription) +} +``` + +```client-android-kotlin import io.appwrite.Client; import io.appwrite.services.Functions; import com.google.gson.Gson; @@ -123,38 +149,12 @@ try { e.printStackTrace() } ``` - -```swift -import Appwrite -import Foundation - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - -let functions = Functions(client) - -do { - let execution = try await functions.createExecution( - functionId: "[FUNCTION_ID]", - data: JSONSerialization.jsonObject(with: ["foo": "bar"], options: [])!, - path: "/", - method: "GET", - headers: [ - "X-Custom-Header": "123" - ] - ) - print(execution.toMap()) -} catch { - print(error.localizedDescription) -} -``` {% /multicode %} {% /tabsitem %} {% tabsitem #server title="Server SDKs" %} {% multicode %} -```js +```server-nodejs import { Client, Functions } from 'node-appwrite'; const client = new Client() diff --git a/src/routes/docs/products/messaging/apns/+page.markdoc b/src/routes/docs/products/messaging/apns/+page.markdoc index b7d6ae28b6..a12b371ea8 100644 --- a/src/routes/docs/products/messaging/apns/+page.markdoc +++ b/src/routes/docs/products/messaging/apns/+page.markdoc @@ -106,7 +106,7 @@ To update or delete providers programmatically, use an [Appwrite Server SDK](/do {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/fcm/+page.markdoc b/src/routes/docs/products/messaging/fcm/+page.markdoc index 249110fed2..94f448e99b 100644 --- a/src/routes/docs/products/messaging/fcm/+page.markdoc +++ b/src/routes/docs/products/messaging/fcm/+page.markdoc @@ -103,7 +103,7 @@ To update or delete providers programmatically, use an [Appwrite Server SDK](/do {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/mailgun/+page.markdoc b/src/routes/docs/products/messaging/mailgun/+page.markdoc index 5a740a10c2..5cfaff118a 100644 --- a/src/routes/docs/products/messaging/mailgun/+page.markdoc +++ b/src/routes/docs/products/messaging/mailgun/+page.markdoc @@ -90,7 +90,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -299,7 +299,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/messages/+page.markdoc b/src/routes/docs/products/messaging/messages/+page.markdoc index e799a8acca..31c141fecb 100644 --- a/src/routes/docs/products/messaging/messages/+page.markdoc +++ b/src/routes/docs/products/messaging/messages/+page.markdoc @@ -226,11 +226,9 @@ Here are the different components that make up a message. {% /tabs %} # Sending a message {% #create-a-message %} -You can create a message with a Server SDK. - -You can send a push notification like this. +You can create a message with a Server SDK. You can send a push notification like this. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -575,7 +573,7 @@ Learn more about sending a push notification You can send an email like this. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -880,7 +878,7 @@ Learn more about sending an email You can send an SMS message like this. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/msg91/+page.markdoc b/src/routes/docs/products/messaging/msg91/+page.markdoc index 50fa13209f..c3a0d073d8 100644 --- a/src/routes/docs/products/messaging/msg91/+page.markdoc +++ b/src/routes/docs/products/messaging/msg91/+page.markdoc @@ -71,7 +71,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -347,7 +347,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/send-email-messages/+page.markdoc b/src/routes/docs/products/messaging/send-email-messages/+page.markdoc index c6cc8cfd7f..bdcf23edaa 100644 --- a/src/routes/docs/products/messaging/send-email-messages/+page.markdoc +++ b/src/routes/docs/products/messaging/send-email-messages/+page.markdoc @@ -46,7 +46,7 @@ During development, you can add targets to existing accounts by navigating to ** You can also implement forms in your app to collect contact information and add it as a target with the [createTarget](/docs/references/cloud/server-nodejs/users#createTarget) endpoint. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); const client = new sdk.Client() @@ -283,7 +283,7 @@ To create a topic in the Appwrite Console, navigate to **Messaging** > **Topics* You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/cloud/server-nodejs/messaging#createTopic). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -495,7 +495,7 @@ let topic = try await messaging.createTopic( You can send emails using a Server SDK. To send an email immediately, you can call the `createEmail` endpoint with `schedule` left empty. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -797,7 +797,7 @@ let message = try await messaging.createEmail( # Schedule emails {% #schedule-emails %} To send a scheduled email, you can call the `createEmail` endpoint with `status` set to `'scheduled'` and `schedule` as a ISO 8601 date time string for the scheduled time. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/send-push-notifications/+page.markdoc b/src/routes/docs/products/messaging/send-push-notifications/+page.markdoc index 14eba1055a..fd92de6b42 100644 --- a/src/routes/docs/products/messaging/send-push-notifications/+page.markdoc +++ b/src/routes/docs/products/messaging/send-push-notifications/+page.markdoc @@ -506,7 +506,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc b/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc index 5c3330bad0..6adfa84add 100644 --- a/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc +++ b/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc @@ -55,7 +55,7 @@ During development, you can add targets to existing accounts by navigating to ** You can also implement forms in your app to collect contact information and add it as a target with the [createSubscriber](/docs/references/cloud/server-nodejs/messaging#createSubscriber) endpoint. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); const client = new sdk.Client() @@ -293,7 +293,7 @@ To create a topic in the Appwrite Console, navigate to **Messaging** > **Topics* You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/cloud/server-nodejs/messaging#createTopic). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); const client = new sdk.Client() @@ -471,7 +471,7 @@ You can send SMS messages using a Server SDK. To send an SMS messages immediately, you can call the `createSMS` endpoint without passing either the `draft` or `scheduledAt` parameters. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -700,7 +700,7 @@ let message = try await messaging.createSMS( # Schedule SMS message {% #schedule-sms %} To send an scheduled SMS message, you can call the `createSMS` endpoint with `scheduledAt` as a ISO 8601 date time string for the scheduled time. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/sendgrid/+page.markdoc b/src/routes/docs/products/messaging/sendgrid/+page.markdoc index 1a2adbcb14..534ab250e6 100644 --- a/src/routes/docs/products/messaging/sendgrid/+page.markdoc +++ b/src/routes/docs/products/messaging/sendgrid/+page.markdoc @@ -86,7 +86,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -296,7 +296,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/smtp/+page.markdoc b/src/routes/docs/products/messaging/smtp/+page.markdoc index 1bea532789..68e9ca61b9 100644 --- a/src/routes/docs/products/messaging/smtp/+page.markdoc +++ b/src/routes/docs/products/messaging/smtp/+page.markdoc @@ -92,7 +92,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -301,7 +301,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/telesign/+page.markdoc b/src/routes/docs/products/messaging/telesign/+page.markdoc index 921912a1f4..e33cae1829 100644 --- a/src/routes/docs/products/messaging/telesign/+page.markdoc +++ b/src/routes/docs/products/messaging/telesign/+page.markdoc @@ -70,7 +70,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -345,7 +345,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/textmagic/+page.markdoc b/src/routes/docs/products/messaging/textmagic/+page.markdoc index 59539efe3d..b4bbf58e4e 100644 --- a/src/routes/docs/products/messaging/textmagic/+page.markdoc +++ b/src/routes/docs/products/messaging/textmagic/+page.markdoc @@ -70,7 +70,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -345,7 +345,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/topics/+page.markdoc b/src/routes/docs/products/messaging/topics/+page.markdoc index aed9290793..8ca4e2143a 100644 --- a/src/routes/docs/products/messaging/topics/+page.markdoc +++ b/src/routes/docs/products/messaging/topics/+page.markdoc @@ -49,7 +49,7 @@ Navigate to your Appwrite Console > **Messaging** > **Topics** > **Create topic* {% tabsitem #server-sdk title="Server SDK" %} {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -296,7 +296,7 @@ If you can't find the targets you'd like to add, see the [targets page](/docs/pr {% tabsitem #server-sdk title="Server SDK" %} {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); const client = new sdk.Client() diff --git a/src/routes/docs/products/messaging/twilio/+page.markdoc b/src/routes/docs/products/messaging/twilio/+page.markdoc index aa2705f73f..75151d6f75 100644 --- a/src/routes/docs/products/messaging/twilio/+page.markdoc +++ b/src/routes/docs/products/messaging/twilio/+page.markdoc @@ -72,7 +72,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -345,7 +345,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/messaging/vonage/+page.markdoc b/src/routes/docs/products/messaging/vonage/+page.markdoc index 5f1ee4449d..02527c11c0 100644 --- a/src/routes/docs/products/messaging/vonage/+page.markdoc +++ b/src/routes/docs/products/messaging/vonage/+page.markdoc @@ -72,7 +72,7 @@ Verify that you can receive the message in your inbox. If not, check for logs in {% tabsitem #server-sdk title="Server SDK" %} To send a message programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -347,7 +347,7 @@ In the settings, you can update a provider's configuration or delete the provide {% tabsitem #server-sdk title="Server SDK" %} To update or delete providers programmatically, use an [Appwrite Server SDK](/docs/sdks#server). {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/storage/buckets/+page.markdoc b/src/routes/docs/products/storage/buckets/+page.markdoc index 498c304279..60836757f0 100644 --- a/src/routes/docs/products/storage/buckets/+page.markdoc +++ b/src/routes/docs/products/storage/buckets/+page.markdoc @@ -27,7 +27,7 @@ You can also create collections programmatically using a [Server SDK](/docs/sdks {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK diff --git a/src/routes/docs/products/storage/images/+page.markdoc b/src/routes/docs/products/storage/images/+page.markdoc index 1cc509e997..0e35880e56 100644 --- a/src/routes/docs/products/storage/images/+page.markdoc +++ b/src/routes/docs/products/storage/images/+page.markdoc @@ -39,7 +39,7 @@ Below you can find all the different parameters offered by the preview endpoint # Examples {% #examples %} Here are some examples using [Client SDKs](/docs/sdks#client). {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -69,7 +69,7 @@ const result = storage.getFilePreview( console.log(result.href); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -118,7 +118,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -145,7 +145,7 @@ func main() async throws { print(String(describing: byteBuffer) } ``` -```kotlin +```client-android-java import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope diff --git a/src/routes/docs/products/storage/quick-start/+page.markdoc b/src/routes/docs/products/storage/quick-start/+page.markdoc index 4c94d2271e..f81577b26c 100644 --- a/src/routes/docs/products/storage/quick-start/+page.markdoc +++ b/src/routes/docs/products/storage/quick-start/+page.markdoc @@ -19,7 +19,7 @@ This allows anyone to create and read files in this bucket. To upload a file, add this to you web, Flutter, Apple, or Android app. {% multicode %} - ```js + ```client-web import { Client, Storage } from "appwrite"; const client = new Client() @@ -41,7 +41,7 @@ To upload a file, add this to you web, Flutter, Apple, or Android app. }); ``` - ```dart + ```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -58,27 +58,7 @@ To upload a file, add this to you web, Flutter, Apple, or Android app. ); } ``` - - ```kotlin - import io.appwrite.Client - import io.appwrite.services.Storage - - suspend fun main() { - val client = Client(applicationContext) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - - val storage = Storage(client) - - val file = storage.createFile( - bucketId = "[BUCKET_ID]", - fileId = ID.unique(), - file = File("./path-to-files/image.jpg"), - ) - } - ``` - - ```swift + ```client-apple import Appwrite func main() async throws { @@ -98,6 +78,24 @@ To upload a file, add this to you web, Flutter, Apple, or Android app. ) } ``` + ```client-android-kotlin + import io.appwrite.Client + import io.appwrite.services.Storage + + suspend fun main() { + val client = Client(applicationContext) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + + val storage = Storage(client) + + val file = storage.createFile( + bucketId = "[BUCKET_ID]", + fileId = ID.unique(), + file = File("./path-to-files/image.jpg"), + ) + } + ``` ```http POST /v1/storage/buckets/{bucketId}/files HTTP/1.1 @@ -129,7 +127,7 @@ To upload a file, add this to you web, Flutter, Apple, or Android app. To download a file, use the `getFileDownload` method. {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -145,7 +143,7 @@ const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); console.log(result); // Resource URL ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -183,7 +181,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -196,10 +194,10 @@ func main() async throws { fileId: "[FILE_ID]" ) - print(String(describing: byteBuffer) + print(String(describing: byteBuffer)) } ``` -```kotlin +```client-android-kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index e3a86847c4..39ebb29b74 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -55,7 +55,7 @@ You can also upload files programmatically using our SDKs: } ``` - ```kotlin + ```client-android-kotlin import io.appwrite.Client import io.appwrite.services.Storage @@ -74,7 +74,7 @@ You can also upload files programmatically using our SDKs: } ``` - ```swift + ```client-apple import Appwrite func main() async throws { @@ -277,7 +277,7 @@ The Appwrite .NET SDK expects an `InputFile` class for file inputs. To get a metadata about a.file, use the `getFile` method. {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -297,7 +297,7 @@ promise.then(function (response) { console.log(error); // Failure }); ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -335,7 +335,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -351,7 +351,7 @@ func main() async throws { print(String(describing: byteBuffer) } ``` -```kotlin +```client-android-kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope @@ -384,7 +384,7 @@ class MainActivity : AppCompatActivity() { To download a file, use the `getFileDownload` method. {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -400,7 +400,7 @@ const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); console.log(result); // Resource URL ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -438,7 +438,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -451,10 +451,10 @@ func main() async throws { fileId: "[FILE_ID]" ) - print(String(describing: byteBuffer) + print(String(describing: byteBuffer)) } ``` -```kotlin +```client-android-kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope @@ -487,7 +487,7 @@ class MainActivity : AppCompatActivity() { To get a file preview image , use the `getFilePreview` method. {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -503,7 +503,7 @@ const result = storage.getFilePreview('[BUCKET_ID]', '[FILE_ID]'); console.log(result); // Resource URL ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -541,7 +541,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -554,10 +554,10 @@ func main() async throws { fileId: "[FILE_ID]" ) - print(String(describing: byteBuffer) + print(String(describing: byteBuffer)) } ``` -```kotlin +```client-android-kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope @@ -591,7 +591,7 @@ class MainActivity : AppCompatActivity() { To view a file, use the `getFileView` method. {% multicode %} -```js +```client-web import { Client, Storage } from "appwrite"; const client = new Client(); @@ -607,7 +607,7 @@ const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]'); console.log(result); // Resource URL ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; void main() { // Init SDK @@ -645,7 +645,7 @@ FutureBuilder( }, ); ``` -```swift +```client-apple import Appwrite func main() async throws { @@ -658,10 +658,10 @@ func main() async throws { fileId: "[FILE_ID]" ) - print(String(describing: byteBuffer) + print(String(describing: byteBuffer)) } ``` -```kotlin +```client-android-kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import kotlinx.coroutines.GlobalScope diff --git a/src/routes/docs/quick-starts/angular/+page.markdoc b/src/routes/docs/quick-starts/angular/+page.markdoc index bef0d89ab2..285d4b0b30 100644 --- a/src/routes/docs/quick-starts/angular/+page.markdoc +++ b/src/routes/docs/quick-starts/angular/+page.markdoc @@ -68,7 +68,7 @@ Find your project's ID in the **Settings** page. {% /only_light %} Create a new file `src/lib/appwrite.ts` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account} from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/nextjs/+page.markdoc b/src/routes/docs/quick-starts/nextjs/+page.markdoc index 903810d14c..8667cdd1b5 100644 --- a/src/routes/docs/quick-starts/nextjs/+page.markdoc +++ b/src/routes/docs/quick-starts/nextjs/+page.markdoc @@ -58,7 +58,7 @@ Find your project's ID in the **Settings** page. Create a new file `app/appwrite.js` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account } from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/nuxt/+page.markdoc b/src/routes/docs/quick-starts/nuxt/+page.markdoc index 4c7ec2c91c..1d46bf3a64 100644 --- a/src/routes/docs/quick-starts/nuxt/+page.markdoc +++ b/src/routes/docs/quick-starts/nuxt/+page.markdoc @@ -61,7 +61,7 @@ Find your project's ID in the **Settings** page. Create a new file `utils/appwrite.js` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account} from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/react/+page.markdoc b/src/routes/docs/quick-starts/react/+page.markdoc index 20bcdbf8a4..51ece70dd0 100644 --- a/src/routes/docs/quick-starts/react/+page.markdoc +++ b/src/routes/docs/quick-starts/react/+page.markdoc @@ -58,7 +58,7 @@ Find your project's ID in the **Settings** page. {% /only_light %} Create a new file `src/lib/appwrite.js` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account} from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/refine/+page.markdoc b/src/routes/docs/quick-starts/refine/+page.markdoc index f53dfe7b19..36afd0e64b 100644 --- a/src/routes/docs/quick-starts/refine/+page.markdoc +++ b/src/routes/docs/quick-starts/refine/+page.markdoc @@ -84,7 +84,7 @@ export { account, appwriteClient, storage }; Replace the code in `src/App.tsx` with the following. -```js +```client-web import { Authenticated, Refine } from '@refinedev/core'; import { dataProvider, liveProvider } from '@refinedev/appwrite'; import { diff --git a/src/routes/docs/quick-starts/sveltekit/+page.markdoc b/src/routes/docs/quick-starts/sveltekit/+page.markdoc index 2746deed1c..319de0d782 100644 --- a/src/routes/docs/quick-starts/sveltekit/+page.markdoc +++ b/src/routes/docs/quick-starts/sveltekit/+page.markdoc @@ -57,7 +57,7 @@ Find your project's ID in the **Settings** page. {% /only_light %} Create a new file `src/lib/appwrite.js` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account } from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/vue/+page.markdoc b/src/routes/docs/quick-starts/vue/+page.markdoc index b49fa6c2f4..277985ba42 100644 --- a/src/routes/docs/quick-starts/vue/+page.markdoc +++ b/src/routes/docs/quick-starts/vue/+page.markdoc @@ -59,7 +59,7 @@ Find your project's ID in the **Settings** page. Create a new file `src/lib/appwrite.js` and add the following code to it, replace `` with your project ID. -```js +```client-web import { Client, Account} from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/quick-starts/web/+page.markdoc b/src/routes/docs/quick-starts/web/+page.markdoc index 25770963ee..0cbac41055 100644 --- a/src/routes/docs/quick-starts/web/+page.markdoc +++ b/src/routes/docs/quick-starts/web/+page.markdoc @@ -46,7 +46,7 @@ You can also add the Appwrite Web SDK using CDN with a script tag. ``` {% /section %} {% section #step-3 step=3 title="Import Appwrite" %} -```js +```client-web import { Client, Account } from 'appwrite'; export const client = new Client(); diff --git a/src/routes/docs/references/quick-start/+page.markdoc b/src/routes/docs/references/quick-start/+page.markdoc index 74beb676f3..0c56176c0c 100644 --- a/src/routes/docs/references/quick-start/+page.markdoc +++ b/src/routes/docs/references/quick-start/+page.markdoc @@ -90,7 +90,7 @@ and other metadata for Appwrite to properly parse your request. Client apps need to be configured with endpoint and project ID, so the Appwrite SDK knows which endpoint and project to connect to. {% multicode %} -```js +```client-web import { Client } from "appwrite"; const client = new Client(); @@ -100,7 +100,7 @@ client .setProject('') // Your project ID ; ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; Client client = Client(); @@ -110,20 +110,20 @@ client .setProject('') // Your project ID ; ``` -```kotlin -import io.appwrite.Client - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID -``` -```swift +```client-apple import Appwrite let client = Client() .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID ``` +```client-android-kotlin +import io.appwrite.Client + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID +``` {% /multicode %} {% /tabsitem %} @@ -132,7 +132,7 @@ Server apps need to be configured with endpoint, project ID, and an API key so the Appwrite SDK knows which endpoint and project to connect to, as well as have credentials to perform admin actions. {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Init SDK @@ -258,7 +258,7 @@ The API key should have the following scope in order to perform authentication: | Sessions | `sessions.write` | Allows API key to create, update, and delete sessions. | {% multicode %} -```js +```client-nodejs import { Client } from "node-appwrite"; // Using the server SDK const adminClient = new Client() @@ -289,7 +289,7 @@ It will be initialized with the session, usually stored within a cookie. You should create a new client for each request and **never** share the client between requests. {% multicode %} -```js +```server-nodejs const sessionClient = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID diff --git a/src/routes/docs/sdks/+page.markdoc b/src/routes/docs/sdks/+page.markdoc index 9a4dacf9ec..b1aca2b72a 100644 --- a/src/routes/docs/sdks/+page.markdoc +++ b/src/routes/docs/sdks/+page.markdoc @@ -146,7 +146,7 @@ Note that **ID.unique()** does not generate unique IDs locally, but asks the App {% tabs %} {% tabsitem #client title="Client SDKs" %} {% multicode %} -```js +```client-web import { Client, Account } from "appwrite"; // Generate a unique ID @@ -154,7 +154,7 @@ ID.unique() // Generate a custom ID ID.custom() ``` -```dart +```client-flutter import 'package:appwrite/appwrite.dart'; // Generate a unique ID @@ -162,7 +162,7 @@ ID.unique() // Generate a custom ID ID.custom() ``` -```swift +```client-apple import Appwrite // Generate a unique ID @@ -170,7 +170,7 @@ ID.unique() // Generate a custom ID ID.custom() ``` -```kotlin +```client-android-kotlin import io.appwrite.ID // Generate a unique ID @@ -183,7 +183,7 @@ ID.custom() {% tabsitem #server title="Server SDKs" %} {% multicode %} -```js +```server-nodejs const sdk = require('node-appwrite'); // Generate a unique ID diff --git a/src/routes/docs/tutorials/react/step-3/+page.markdoc b/src/routes/docs/tutorials/react/step-3/+page.markdoc index 5583586d25..a52ce90d16 100644 --- a/src/routes/docs/tutorials/react/step-3/+page.markdoc +++ b/src/routes/docs/tutorials/react/step-3/+page.markdoc @@ -44,7 +44,7 @@ Create a new file `src/lib/appwrite.js` to hold our Appwrite related code. Only one instance of the `Client()` class should be created per app. Add the following code to it, replacing `` with your project ID. -```js +```client-web import { Client, Databases, Account } from "appwrite"; const client = new Client(); diff --git a/src/routes/docs/tutorials/react/step-4/+page.markdoc b/src/routes/docs/tutorials/react/step-4/+page.markdoc index af576f745b..ce85a04810 100644 --- a/src/routes/docs/tutorials/react/step-4/+page.markdoc +++ b/src/routes/docs/tutorials/react/step-4/+page.markdoc @@ -12,7 +12,7 @@ We'll use context and a custom hook to manage our user's data. Create a new file `src/lib/context/user.jsx` and add the following code to it. -```js +```client-web import { ID } from "appwrite"; import { createContext, useContext, useEffect, useState } from "react"; import { account } from "../appwrite"; @@ -70,7 +70,7 @@ First, wrap the `main` element with the `UserProvider` component. Update `src/App.jsx` to the following code. -```js +```client-web import { Home } from "./pages/Home"; import { UserProvider } from "./lib/context/user"; @@ -93,7 +93,7 @@ Then, optionally render the `Login` component if the path is `/login`, otherwise Update `src/App.jsx` to the following code. -```js +```client-web import { Login } from "./pages/Login"; import { Home } from "./pages/Home"; import { UserProvider } from "./lib/context/user"; @@ -132,7 +132,7 @@ Finally, we are able to create the login page. Users will be able to login or re Create a new file `src/pages/Login.jsx` and add the following code to it. -```js +```client-web import { useState } from "react"; import { useUser } from "../lib/context/user"; diff --git a/src/routes/docs/tutorials/react/step-5/+page.markdoc b/src/routes/docs/tutorials/react/step-5/+page.markdoc index c834cef653..99fadc2d62 100644 --- a/src/routes/docs/tutorials/react/step-5/+page.markdoc +++ b/src/routes/docs/tutorials/react/step-5/+page.markdoc @@ -11,7 +11,7 @@ In our app we want to have a navigation bar that is always visible. We will add Update the App componenent in `src/App.jsx`: -```js +```client-web import { Login } from "./pages/Login"; import { Home } from "./pages/Home"; import { UserProvider, useUser } from "./lib/context/user"; diff --git a/src/routes/docs/tutorials/react/step-6/+page.markdoc b/src/routes/docs/tutorials/react/step-6/+page.markdoc index e90a9ed455..fa9ad5b9b6 100644 --- a/src/routes/docs/tutorials/react/step-6/+page.markdoc +++ b/src/routes/docs/tutorials/react/step-6/+page.markdoc @@ -26,7 +26,7 @@ Create a new collection with the following attributes: Now that you have a collection to hold ideas, we can read and write to it from our app. Like we did with the user data, we will create a React context to hold our ideas. Create a new file `src/lib/context/ideas.jsx` and add the following code to it. -```js +```client-web import { createContext, useContext, useEffect, useState } from "react"; import { databases } from "../appwrite"; import { ID, Query } from "appwrite"; diff --git a/src/routes/docs/tutorials/react/step-7/+page.markdoc b/src/routes/docs/tutorials/react/step-7/+page.markdoc index 4552972a62..5372e7f0ac 100644 --- a/src/routes/docs/tutorials/react/step-7/+page.markdoc +++ b/src/routes/docs/tutorials/react/step-7/+page.markdoc @@ -9,7 +9,7 @@ Using the `useIdeas` hook we can now display the ideas on the page. We will also Overwrite the contents of `src/pages/Home.jsx` with the following: -```js +```client-web import { useState } from "react"; import { useUser } from "../lib/context/user"; import { useIdeas } from "../lib/context/ideas"; diff --git a/src/routes/docs/tutorials/sveltekit/step-3/+page.markdoc b/src/routes/docs/tutorials/sveltekit/step-3/+page.markdoc index f0756a7ada..c684a9910c 100644 --- a/src/routes/docs/tutorials/sveltekit/step-3/+page.markdoc +++ b/src/routes/docs/tutorials/sveltekit/step-3/+page.markdoc @@ -43,7 +43,7 @@ Create a new file `src/lib/appwrite.js` to hold our Appwrite related code. Only one instance of the `Client()` class should be created per app. Add the following code to it, replacing `` with your project ID. -```js +```client-web import { Client, Databases, Account } from "appwrite"; const client = new Client(); diff --git a/src/routes/docs/tutorials/sveltekit/step-4/+page.markdoc b/src/routes/docs/tutorials/sveltekit/step-4/+page.markdoc index d7b9686e08..dee31f8f49 100644 --- a/src/routes/docs/tutorials/sveltekit/step-4/+page.markdoc +++ b/src/routes/docs/tutorials/sveltekit/step-4/+page.markdoc @@ -12,7 +12,7 @@ We'll use a store to keep track of our user's data. Create a new file `src/lib/user.js` and add the following code to it. -```js +```client-web import { writable } from 'svelte/store'; import { ID } from 'appwrite'; import { goto } from '$app/navigation'; diff --git a/src/routes/docs/tutorials/sveltekit/step-6/+page.markdoc b/src/routes/docs/tutorials/sveltekit/step-6/+page.markdoc index d13bbfb0ba..7e58202c55 100644 --- a/src/routes/docs/tutorials/sveltekit/step-6/+page.markdoc +++ b/src/routes/docs/tutorials/sveltekit/step-6/+page.markdoc @@ -33,7 +33,7 @@ Let's create some methods to manage ideas in our app. Create a new file `src/lib/ideas.js` and add the following code: -```js +```client-web import { ID, Query } from 'appwrite'; import { databases } from '$lib/appwrite'; diff --git a/src/routes/docs/tutorials/sveltekit/step-7/+page.markdoc b/src/routes/docs/tutorials/sveltekit/step-7/+page.markdoc index c9fd7a7a39..d350b1c8ea 100644 --- a/src/routes/docs/tutorials/sveltekit/step-7/+page.markdoc +++ b/src/routes/docs/tutorials/sveltekit/step-7/+page.markdoc @@ -11,7 +11,7 @@ First, let's create a load function for our ideas page. This will load the lates To do so, create a file called `src/routes/+page.js` with the following content: -```js +```client-web import { getIdeas } from '$lib/ideas'; export async function load() { diff --git a/src/routes/docs/tutorials/vue/step-3/+page.markdoc b/src/routes/docs/tutorials/vue/step-3/+page.markdoc index 66f4c2c3ca..80680b02e7 100644 --- a/src/routes/docs/tutorials/vue/step-3/+page.markdoc +++ b/src/routes/docs/tutorials/vue/step-3/+page.markdoc @@ -43,7 +43,7 @@ Create a new file `src/appwrite.js` to hold our Appwrite related code. Only one instance of the `Client()` class should be created per app. Add the following code to it, replacing `` with your project ID. -```js +```client-web import { Client, Databases, Account } from "appwrite"; const client = new Client(); diff --git a/src/routes/docs/tutorials/vue/step-4/+page.markdoc b/src/routes/docs/tutorials/vue/step-4/+page.markdoc index ea0941f10f..c402a9a6b4 100644 --- a/src/routes/docs/tutorials/vue/step-4/+page.markdoc +++ b/src/routes/docs/tutorials/vue/step-4/+page.markdoc @@ -12,7 +12,7 @@ We'll create a store to share the user's data between components. Create a new file `src/lib/stores/user.js` and add the following code to it. -```js +```client-web import { ID } from "appwrite"; import { account } from "../appwrite"; import { reactive } from "vue"; diff --git a/src/routes/docs/tutorials/vue/step-6/+page.markdoc b/src/routes/docs/tutorials/vue/step-6/+page.markdoc index a646b24068..5fb37ce9a5 100644 --- a/src/routes/docs/tutorials/vue/step-6/+page.markdoc +++ b/src/routes/docs/tutorials/vue/step-6/+page.markdoc @@ -26,7 +26,7 @@ Create a new collection with the following attributes: Now that you have a collection to hold ideas, we can read and write to it from our app. Like we did with the user data, we will create a store hold our ideas. Create a new file `src/lib/stores/ideas.js` and add the following code to it. -```js +```client-web import { ID, Query } from "appwrite"; import { databases } from "../appwrite"; import { reactive } from "vue"; From 205e53cdd4ff22db92e2ce062a9de9f21f75b563 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Tue, 2 Apr 2024 15:53:35 -0400 Subject: [PATCH 2/3] fix client-nodejs should be server-nodejs --- src/routes/docs/references/quick-start/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/references/quick-start/+page.markdoc b/src/routes/docs/references/quick-start/+page.markdoc index 0c56176c0c..0a04b76d2a 100644 --- a/src/routes/docs/references/quick-start/+page.markdoc +++ b/src/routes/docs/references/quick-start/+page.markdoc @@ -258,7 +258,7 @@ The API key should have the following scope in order to perform authentication: | Sessions | `sessions.write` | Allows API key to create, update, and delete sessions. | {% multicode %} -```client-nodejs +```server-nodejs import { Client } from "node-appwrite"; // Using the server SDK const adminClient = new Client() From f1b5856b829eebd76d3ab4508d9c377ea639e386 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Fri, 12 Apr 2024 16:32:24 -0400 Subject: [PATCH 3/3] Fix dead links --- .../products/auth/custom-token/+page.markdoc | 2 +- .../functions/execution/+page.markdoc | 503 ------------------ .../send-email-messages/+page.markdoc | 4 +- .../messaging/send-sms-messages/+page.markdoc | 4 +- .../[service]/descriptions/account.md | 2 +- 5 files changed, 6 insertions(+), 509 deletions(-) delete mode 100644 src/routes/docs/products/functions/execution/+page.markdoc diff --git a/src/routes/docs/products/auth/custom-token/+page.markdoc b/src/routes/docs/products/auth/custom-token/+page.markdoc index 7a0f1fdd5e..e5980e6464 100644 --- a/src/routes/docs/products/auth/custom-token/+page.markdoc +++ b/src/routes/docs/products/auth/custom-token/+page.markdoc @@ -161,7 +161,7 @@ If the client doesn't know the user's ID during authentication, we recommend to # Login {% #login %} -Once the client receives a token secret, we can use it to authenticate the user in the application. Use the [Client SDK's](/docs/sdks#client) [Create session endpoint](/docs/references/cloud/server-nodejs/account#createSession) to exchange the token secret for a valid session, which logs the user. +Once the client receives a token secret, we can use it to authenticate the user in the application. Use the [Client SDK's](/docs/sdks#client) [Create session endpoint](/docs/references/1.5.x/server-nodejs/account#createSession) to exchange the token secret for a valid session, which logs the user. {% multicode %} diff --git a/src/routes/docs/products/functions/execution/+page.markdoc b/src/routes/docs/products/functions/execution/+page.markdoc deleted file mode 100644 index 624e67b194..0000000000 --- a/src/routes/docs/products/functions/execution/+page.markdoc +++ /dev/null @@ -1,503 +0,0 @@ ---- -layout: article -title: Execution -description: Understand serverless function execution in Appwrite. Explore how triggers, events, and data flow enable dynamic execution of your code. -difficulty: beginner -readtime: 3 ---- - - -Appwrite Functions can be executed in several ways. -Executions can be invoked through the Appwrite SDK and visiting its REST endpoint. Functions can also be triggered by events and scheduled executions. -Here are all the different ways to consume your Appwrite Functions. - -# Domains {% #domains %} - -1. In the Appwrite Console's sidebar, click **Functions**. -1. Under the **Domains** tab, you'll find the generated domain from Appwrite and your custom domains. - -```bash -https://64d4d22db370ae41a32e.appwrite.global -``` - -[Learn about adding a custom domain](/docs/products/functions/deployment#domains). - -## REST API {% #rest %} - -When requests are made to this domain, whether through a browser or through an HTTP requests, -the request information like request URL, request headers, and request body will be passed to the function. -This unlocks ability for Appwrite Function to become a full-blown API server on its own. It also allows accepting incoming webhooks for handling online payments, hosting social platform bots, and much more. - -```bash -curl -X POST https://64d4d22db370ae41a32e.appwrite.global \ --H "X-Custom-Header: 123" \ --H "Content-Type: application/json" \ --d '{"data":"this is json data"}' -``` - -## SDK {% #sdk %} - -You can invoke your Appwrite Functions directly from the Appwrite SDKs. - -[Learn more about using the Appwrite SDKs](/docs/sdks) - -{% tabs %} -{% tabsitem #client title="Client SDKs" %} - -{% multicode %} -```client-web -import { Client, Functions } from 'appwrite'; - -const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject(''); - -const functions = new Functions(client) - -try { - const execution = await functions.createExecution( - '[FUNCTION_ID]', - JSON.stringify({ 'foo': 'bar' }), - false, - '/', - 'GET', - { 'X-Custom-Header': '123' } - ) - console.log(execution) -} catch (err) { - console.error(err.message) -} -``` - -```client-flutter -import 'package:appwrite/appwrite.dart'; -import 'dart:convert'; - -final client = Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject(''); - -final functions = Functions(client); - -try { - final execution = await functions.createExecution( - functionId: '[FUNCTION_ID]', - body: json.encode({ 'foo': 'bar' }), - async: false, - path: '/', - method: 'GET', - headers: { - 'X-Custom-Header': '123' - } - ); - print(execution.toMap()); -} catch (e) { - print(e.message); -} -``` - -```client-apple -import Appwrite -import Foundation - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - -let functions = Functions(client) - -do { - let execution = try await functions.createExecution( - functionId: "[FUNCTION_ID]", - data: JSONSerialization.jsonObject(with: ["foo": "bar"], options: [])!, - path: "/", - method: "GET", - headers: [ - "X-Custom-Header": "123" - ] - ) - print(execution.toMap()) -} catch { - print(error.localizedDescription) -} -``` - -```client-android-kotlin -import io.appwrite.Client; -import io.appwrite.services.Functions; -import com.google.gson.Gson; - -val client = Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject('') - -val functions = Functions(client) - -try { - val execution = functions.createExecution( - functionId = "[FUNCTION_ID]", - body = gson.toJson(mapOf("foo" to "bar")), - async = false, - path = "/", - method = "GET", - headers = mapOf( - "X-Custom-Header" to "123" - ) - ) - print(execution.toMap()) -} catch (AppwriteException e) { - e.printStackTrace() -} -``` -{% /multicode %} -{% /tabsitem %} - -{% tabsitem #server title="Server SDKs" %} -{% multicode %} -```server-nodejs -import { Client, Functions } from 'node-appwrite'; - -const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject('') - .setKey('[API_KEY]'); - -const functions = new Functions(client); - -try { - const execution = await functions.createExecution( - '[FUNCTION_ID]', - JSON.stringify({ 'foo': 'bar' }), - false, - '/', - 'GET', - { 'X-Custom-Header': '123' } - ) - console.log(execution) -} catch (error) { - console.error(error.message) -} -``` -```php -') - .setKey('[API_KEY]'); - -$functions = new Functions($client); - -try { - $execution = $functions->createExecution( - functionId: '[FUNCTION_ID]', - body: json_encode([ 'foo' => 'bar' ]), - async: false, - path: '/', - method: 'GET', - headers: [ - 'X-Custom-Header' => '123' - ] - ); - echo $execution; -} catch ($e) { - echo $e->getMessage(); -} -``` -```python -from appwrite.client import Client -from appwrite.services.functions import Functions - -import json - -client = Client() - -(client - .set_endpoint('https://cloud.appwrite.io/v1') - .set_project('') - .set_key('[API_KEY]') -) - -functions = Functions(client) - -try: - execution = functions.create_execution( - functionId="[FUNCTION_ID]", - data=json.dumps({'foo': 'bar'}), - path='/', - method='GET', - headers=[ - 'X-Custom-Header': '123' - ] - ) - print(execution) -except Exception as e: - print(e.message) -``` -```ruby -require 'Appwrite' -require 'json' - -include Appwrite - -client = Client.new - .set_endpoint('https://cloud.appwrite.io/v1') - .set_project('') - .set_key('[API_KEY]') - -functions = Functions.new(client) - -begin - execution = functions.create_execution( - function_id: '[FUNCTION_ID]', - body: JSON.generate({ 'foo': 'bar'}), - async: false, - path: '/', - method: 'GET', - headers: { - 'X-Custom-Header': '123' - }) - puts execution -rescue => e - puts e.message -end -``` -```deno -import { Client, Functions } from "https://deno.land/x/appwrite/mod.ts"; - -const client = new Client() - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject('') - .setKey('[API_KEY]'); - -const functions = new Functions(client); - -try { - const execution = await functions.createExecution( - '[FUNCTION_ID]', - JSON.stringify({ 'foo': 'bar' }), - false, - '/', - 'GET', - { 'X-Custom-Header': '123' } - ) - console.log(execution) -} catch (error) { - console.error(error.message) -} -``` -```dart -import 'package:dart_appwrite/dart_appwrite.dart'; -import 'dart:convert'; - -final client = Client(); - .setEndpoint('https://cloud.appwrite.io/v1') - .setProject('') - .setKey('[API_KEY]'); - -final functions = Functions(client); - -try { - final execution = await functions.createExecution( - functionId: '[FUNCTION_ID]', - body: json.encode({ - 'foo': 'bar' - }), - async: false, - path: '/', - method: 'GET', - headers: { - 'X-Custom-Header': '123' - } - ); -} catch (e) { - print(e.message); -} -``` - -```swift -import Appwrite -import Foundation - -let client = Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - .setKey("[API_KEY]") - -let functions = Functions(client) - -do { - let execution = try await functions.createExecution( - functionId: "[FUNCTION_ID]", - body: JSONSerialization.jsonObject(with: ["foo": "bar"], options: [])!), - async: false, - path: "/", - method: "GET", - headers: [ - "X-Custom-Header": "123" - ] - ) - print(execution) -catch { - print(error.localizedDescription) -} -``` - -```csharp -using Appwrite; -using Appwrite.Services; -using Appwrite.Models; -using System.Text.Json; - -var client = new Client() - .SetEndPoint("https://cloud.appwrite.io/v1") - .SetProject("") - .SetKey("[API_KEY]"); - -var functions = new Functions(client); - -try -{ - var execution = await functions.CreateExecution( - functionId: "[FUNCTION_ID]", - body: JsonSerializer.Serialize(new Dictionary { - { "foo", "bar" } - }), - async: false, - path: "/", - method: "GET", - headers: new Dictionary { - { "X-Custom-Header", "123" } - }); - - Debug.Write(execution) -} -catch (Exception e) -{ - Debug.Write(e); -} -``` - -```kotlin -import io.appwrite.Client -import io.appwrite.services.Functions -import com.google.gson.Gson - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - .setKey("[API_KEY]") - -val functions = Functions(client) - -try { - val execution = functions.createExecution( - functionId = "[FUNCTION_ID]", - body = gson.toJson(mapOf( - "foo" to "bar" - )), - path = "/", - method = "GET", - headers = mapOf( - "X-Custom-Header" to "123" - ) - ) - print(execution) -} catch (e: Exception) { - e.printStackTrace() -} -``` -```java -import io.appwrite.Client; -import io.appwrite.services.Functions; -import java.util.HashMap; -import com.google.gson.Gson; - -Client client = new Client() - .setEndpoint("https://cloud.appwrite.io/v1") - .setProject("") - .setKey("[API_KEY]"); - -Functions functions = new Functions(client); - -functions.createExecution( - "[FUNCTION_ID]", - gson.toJson(new HashMap() {{ - put("foo", "bar"); - }}), - false, - "/", - "GET", - new HashMap() {{ - put("X-Custom-Header", "123"); - }}, - new CoroutineCallback<>((execution, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - System.out.println(result); - }), -); -``` -{% /multicode %} -{% /tabsitem %} -{% /tabs %} - -## Console {% #console %} -Another easy way to test a function is directly in the Appwrite Console. -You test a function by hitting the **Execute now** button, which will display with modal below. - -You'll be able to mock executions by configuring the path, method, headers, and body. - -{% only_dark %} -![Create project screen](/images/docs/functions/execution/dark/execute-function.png) -{% /only_dark %} -{% only_light %} -![Create project screen](/images/docs/functions/execution/execute-function.png) -{% /only_light %} - - -## Events {% #events %} - -Changes in Appwrite emit events. You can configure Functions to be executed in response to these events. - -1. In Appwrite Console, navigate to **Functions**. -2. Click to open a function you wish to configure. -3. Under the **Settings** tab, navigate to **Events**. -4. Add one or multiple events as triggers for the function. -5. Be careful to avoid selecting events that can be caused by the function itself. This can cause the function to trigger its own execution, resulting in infinite recursions. - -## Schedule {% #schedule %} - -Appwrite supports scheduled function executions. You can schedule executions using [cron expressions](https://en.wikipedia.org/wiki/Cron) in the settings of your function. Cron supports recurring executions as frequently as **every minute**. - -Here are some cron expressions for common intervals: - -| Cron Expression | Schedule | -| ---------------- | --------------------- | -| `*/15 * * * *` | Every 15 minutes | -| `0 * * * *` | Every Hour | -| `0 0 * * *` | Every day at 00:00 | -| `0 0 * * 1` | Every Monday at 00:00 | - - -## Permissions {% #permission %} - - -Appwrite Functions can be executed using Client or Server SDKs. Client SDKs must be authenticated with an account that has been granted execution [permissions](/docs/advanced/platform/permissions) on the function's settings page. Server SDKs require an API key with the correct scopes. - -If your function has a generated or custom domain, executions are not authenticated. Anyone visiting the configured domains will be considered a guest, so make sure to give `Any` execute permission in order for domain executions to work. If you need to enforce permissions for functions with a domain, use authentication methods like JWT. - - -## Logs and results {% #logs %} - -You can view the logs of your function executions in the Appwrite Console. Navigate to **Functions** and click on a function to view its executions. - -For security reasons, Appwrite does not store the response of function executions. If you need to debug, we recommend logging the response in your function code. diff --git a/src/routes/docs/products/messaging/send-email-messages/+page.markdoc b/src/routes/docs/products/messaging/send-email-messages/+page.markdoc index 90500767d5..0a0e9ec3b1 100644 --- a/src/routes/docs/products/messaging/send-email-messages/+page.markdoc +++ b/src/routes/docs/products/messaging/send-email-messages/+page.markdoc @@ -44,7 +44,7 @@ During development, you can add targets to existing accounts by navigating to ** ![Add a target](/images/docs/messaging/targets/add-targets.png) {% /only_light %} -You can also implement forms in your app to collect contact information and add it as a target with the [createTarget](/docs/references/cloud/server-nodejs/users#createTarget) endpoint. +You can also implement forms in your app to collect contact information and add it as a target with the [createTarget](/docs/references/1.5.x/server-nodejs/users#createTarget) endpoint. {% multicode %} ```server-nodejs const sdk = require('node-appwrite'); @@ -281,7 +281,7 @@ To create a topic in the Appwrite Console, navigate to **Messaging** > **Topics* ![Add a target](/images/docs/messaging/topics/create-topics.png) {% /only_light %} -You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/cloud/server-nodejs/messaging#createTopic). +You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/1.5.x/server-nodejs/messaging#createTopic). {% multicode %} ```server-nodejs const sdk = require('node-appwrite'); diff --git a/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc b/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc index 6adfa84add..85bd408d8b 100644 --- a/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc +++ b/src/routes/docs/products/messaging/send-sms-messages/+page.markdoc @@ -52,7 +52,7 @@ During development, you can add targets to existing accounts by navigating to ** ![Add a target](/images/docs/messaging/targets/add-targets.png) {% /only_light %} -You can also implement forms in your app to collect contact information and add it as a target with the [createSubscriber](/docs/references/cloud/server-nodejs/messaging#createSubscriber) endpoint. +You can also implement forms in your app to collect contact information and add it as a target with the [createSubscriber](/docs/references/1.5.x/server-nodejs/messaging#createSubscriber) endpoint. {% multicode %} ```server-nodejs @@ -291,7 +291,7 @@ To create a topic in the Appwrite Console, navigate to **Messaging** > **Topics* ![Add a target](/images/docs/messaging/topics/create-topics.png) {% /only_light %} -You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/cloud/server-nodejs/messaging#createTopic). +You can also create topics programmatically using an [Appwrite Server SDK](/docs/references/1.5.x/server-nodejs/messaging#createTopic). {% multicode %} ```server-nodejs const sdk = require('node-appwrite'); diff --git a/src/routes/docs/references/[version]/[platform]/[service]/descriptions/account.md b/src/routes/docs/references/[version]/[platform]/[service]/descriptions/account.md index 0482cf9f66..96270162a1 100644 --- a/src/routes/docs/references/[version]/[platform]/[service]/descriptions/account.md +++ b/src/routes/docs/references/[version]/[platform]/[service]/descriptions/account.md @@ -1,5 +1,5 @@ The Account service allows you to authenticate and manage a user account. You can use the account service to update user information, retrieve the user sessions across different devices, and fetch the user security logs with his or her recent activity. -Register new user accounts with the [Create Account](/docs/references/cloud/client-web/account#create), [Create Magic URL session](/docs/references/cloud/client-web/account#createMagicURLToken), or [Create Phone session](/docs/references/cloud/client-web/account#createPhoneToken) endpoint. You can authenticate the user account by using multiple sign-in methods available. Once the user is authenticated, a new session object will be created to allow the user to access his or her private data and settings. +Register new user accounts with the [Create Account](/docs/references/cloud/client-web/account#create), [Create Magic URL session](/docs/references/1.5.x/client-web/account#createMagicURLToken), or [Create Phone session](/docs/references/1.5.x/client-web/account#createPhoneToken) endpoint. You can authenticate the user account by using multiple sign-in methods available. Once the user is authenticated, a new session object will be created to allow the user to access his or her private data and settings. This service also exposes an endpoint to save and read the [user preferences](/docs/references/cloud/client-web/account#updatePrefs) as a key-value object. This feature is handy if you want to allow extra customization in your app. Common usage for this feature may include saving the user's preferred locale, timezone, or custom app theme.