Code Monkey home page Code Monkey logo

sdk-for-web's Introduction

Appwrite Web SDK

License Version Build Status Twitter Account Discord

This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check previous releases.

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Web SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs

Appwrite

Installation

NPM

To install via NPM:

npm install appwrite --save

If you're using a bundler (like Rollup or webpack), you can import the Appwrite module when you need it:

import { Client, Account } from "appwrite";

CDN

To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services:

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

Getting Started

Add your Web Platform

For you to init your SDK and interact with Appwrite services you need to add a web platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before and click the 'Add Platform' button.

From the options, choose to add a Web platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.

Init your SDK

Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.

// Init your Web SDK
const client = new Client();

client
    .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
    .setProject('455x34dfkj') // Your project ID
;

Make Your First Request

Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

const account = new Account(client);

// Register User
account.create(ID.unique(), "[email protected]", "password", "Walter O'Brien")
    .then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Full Example

// Init your Web SDK
const client = new Client();

client
    .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
    .setProject('455x34dfkj')
;

const account = new Account(client);

// Register User
account.create(ID.unique(), "[email protected]", "password", "Walter O'Brien")
    .then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });

Learn more

You can use the following resources to learn more and get help

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

sdk-for-web's People

Contributors

abnegate avatar christyjacob4 avatar eldadfux avatar lohanidamodar avatar loks0n avatar meldiron avatar obnoxious-coder avatar stnguyen90 avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-for-web's Issues

๐Ÿ› Bug Report: React Native File Upload

๐Ÿ‘Ÿ Reproduction steps

Im trying to upload files from react native expo

steps to reproduce

yarn create expo-app demo
cd demo
yarn add appwrite

here is my App.js

import { StatusBar } from "expo-status-bar";
import { Button, StyleSheet, Text, View } from "react-native";

import { Client, Account, Storage } from "appwrite";
const client = new Client();
client
.setEndpoint("https://demo.com/v1") // We set the endpoint, change this if your using another endpoint URL.
.setProject("62aa497432281eaabc7a"); // Your project ID

const account = new Account(client);
const storage = new Storage(client);

export default function App() {
const login = () => {
  const promise = account.createEmailSession("[email protected]", "demodemo");

  promise.then(
    function (response) {
      console.log(response); // Success
    },
    function (error) {
      console.log(error); // Failure
    }
  );
};
const upload = () => {
  const file = new File(["HELOOOO"], "filenamenew.txt", {
    type: "text/plain",
  });
  const promise2 = storage.createFile("userImages", "unique()", file);

  promise2.then(
    function (response) {
      console.log(response); // Success
    },
    function (error) {
      console.log(error); // Failure
    }
  );
};
return (
<View style={styles.container}>
    <Button onPress={login} title="login" />
    <Button onPress={upload} title="upload data" />
  </View>

);
}

const styles = StyleSheet.create({
container: {
  flex: 1,
  backgroundColor: "#fff",
  alignItems: "center",
  justifyContent: "center",
},
});

๐Ÿ‘ Expected behavior

It should upload a file named filenamenew.txt to the specified bucket. The same works properly on react native web. but its not working in with android and ios

๐Ÿ‘Ž Actual Behavior

Network request failed
at node_modules@babel\runtime\helpers\construct.js:19:9 in _construct
at node_modules@babel\runtime\helpers\wrapNativeSuper.js:26:22 in Wrapper
at http://192.168.0.108:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:120669:293 in _createSuperInternal
at node_modules\appwrite\dist\cjs\sdk.js:72:8 in AppwriteException#constructor
at node_modules\appwrite\dist\cjs\sdk.js:391:22 in __awaiter$argument_3
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch
at node_modules@babel\runtime\helpers\regeneratorRuntime.js:66:31 in
at node_modules\appwrite\dist\cjs\sdk.js:25:46 in rejected
at node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:248:12 in _allocateCallback$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:112:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:162:14 in _callReactNativeMicrotasksPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:413:41 in callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:391:6 in __callReactNativeMicrotasks
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:133:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:368:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:132:4 in flushedQueue

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Realtime doesn't work on React Native

๐Ÿ‘Ÿ Reproduction steps

  1. create a react native expo app
  2. init the appwrite
  3. check the console log

๐Ÿ‘ Expected behavior

As react native does not have window.localstorage, implementing the same with
AsyncStorage from '@react-native-async-storage/async-storage'; would be more sense.

i was checking the docs of supabase. This is how they did it

import AsyncStorage from '@react-native-async-storage/async-storage';
import { createClient } from '@supabase/supabase-js'

const supabaseUrl = YOUR_REACT_NATIVE_SUPABASE_URL
const supabaseAnonKey = YOUR_REACT_NATIVE_SUPABASE_ANON_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  localStorage: AsyncStorage as any,
  autoRefreshToken: true,
  persistSession: true,
  detectSessionInUrl: false,
});

implementing something like this would be helpful

๐Ÿ‘Ž Actual Behavior

Screenshot 2022-07-08 at 5 25 10 AM

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Realtime ws unsubscribe does not work as expected

๐Ÿ‘Ÿ Reproduction steps

unsubscribe does not work as expected for the following code block

  startListener() {
    if (!this.listenerFn) {
      this.listenerFn = this.notification.connect();
    }
  }

  unsubscribeListener() {
    // Stop listening to notifications
    if (this.listenerFn) {
      this.listenerFn();
      console.log('Notification Service stopped');
    }

doc ref:

import { Client } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

const unsubscribe = client.subscribe('files', response => {
    // Callback will be executed on changes for all files.
    console.log(response);
});

// Closes the subscription.
unsubscribe();

demo video:

๐Ÿ‘ Expected behavior

it should close the websocket totally. i can see the network tab of inspector

๐Ÿ‘Ž Actual Behavior

when i call unsubscribe, it doesnt trigger to and after logout it continues to listen.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

appwrite version 1.4.13
sdk for web "appwrite": "^13.0.0",

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: registration using websdk fails with API fetch loading failed

๐Ÿ‘Ÿ Reproduction steps

Using Web SDK

Interacting with self hosted appwrite endpoint hosted on a subdomain endpoint.

The SDK fails at times mysteriously , at times it works

can you please let me know if I am missing anything.

appwrite error Screenshot 2023-01-31 090248

๐Ÿ‘ Expected behavior

fetch should be successful

๐Ÿ‘Ž Actual Behavior

api fetch is failing for login/Register

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

html page on Live server, acessed via chrome browser

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report:

๐Ÿ‘Ÿ Reproduction steps

Create a basic svelte app and create a client pointing at the local version of appwrite.
Create a project and add the web platform with the hostname as localhost. (NOTE: This happens when the hostname is a wildcard *)

<script lang="ts">
  import { Client, Account, ID } from 'appwrite';
  import { onMount } from 'svelte';
  const client = new Client().setEndpoint('http://localhost/v1').setProject('<project id>')
  const account = new Account(client);
  onMount(async () => {
    const user = await account.get();
    console.log(user);
  })
</script>

<div>App</div>

๐Ÿ‘ Expected behavior

The account.get() call should return the currently logged in user if any.

๐Ÿ‘Ž Actual Behavior

The request fails with a CORS error related to the x-sdk-language header.
image

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Not able to detect Appwrite Web SDK Types

๐Ÿ‘Ÿ Reproduction steps

Step 1: Initialize a Vite Project

yarn create vite my-vue-app --template vanilla-ts

Root Cause
Because "moduleResolution" is set to "bundler" in my tsconfig.json

Step 2: Install appwrite

yarn add appwrite

Step 3: Import App

import {Client} from "appwrite"

๐Ÿ‘ Expected behavior

It should not throw an error!

๐Ÿ‘Ž Actual Behavior

It throws an error

 Could not find a declaration file for module 'appwrite'. 'c:/Users/ASUS/OneDrive/Desktop/my-vue-app/node_modules/appwrite/dist/esm/sdk.js' implicitly has an 'any' type.
  There are types at 'c:/Users/ASUS/OneDrive/Desktop/my-vue-app/node_modules/appwrite/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'appwrite' library may need to update its package.json or typings.

image

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

Nope!

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Document autocompletion for Databases.createDocument broken

๐Ÿ‘Ÿ Reproduction steps

When using an IDE/editor supporting autocompletion with the Typescript Language Server, such as VS Code.

Calling Databases.createDocument with a type parameter:

interface ProjectModel extends Models.Document {
  name: string;
  whatever: number;
}

/* ... */

const project = await databases.createDocument<ProjectModel>(
  databaseId,
  collectionId,
  ID.unique(),
  {
    name: "my project",
  },
});

๐Ÿ‘ Expected behavior

I should see the properties I defined in the ProjectModel interface when VS Code autocompletes the code inside the curly brackets.

๐Ÿ‘Ž Actual Behavior

VS Code shows identifiers from the function scope, but not the properties defined in the ProjectModel interface:

SCR-20230929-q7u

Possible solution

I think this is caused by the data argument of Databases.createDocument having the type Omit<Document, keyof Models.Document>.

Since Models.Document contains a string index signature, the value of keyof Models.Document is probably string | number. That would remove all properties from the Document type parameter, basically turning it into an empty object type ({}).

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

Appwrite Cloud

Appwrite web SDK version:

13.0.0

VS Code version information:

Version: 1.82.2 (Universal)
Commit: abd2f3db4bdb28f9e95536dfa84d8479f1eb312d
Date: 2023-09-14T05:59:47.790Z (2 wks ago)
Electron: 25.8.1
ElectronBuildId: 23779380
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 22.5.0

MacOS version:

13.4.1 (22F82)

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Expo React Native realtime URLSearchParams.set is not implemented

๐Ÿ‘Ÿ Reproduction steps

I'm trying to subscribe to a document on the Expo client.

// expo project
import { Client } from 'appwrite';
const client = new Client().setProject(PROJECT_ID).setEndpoint(ENDPOINT_HERE);

useEffect(
    function subscribeToLikeAndCommentCount() {
      const unsubscribe = client.subscribe(
        `databases.DATABASE_ID_HERE.collections.COLLECTION_ID_HERE.documents.${videoId}`,
        (payload) => {
          console.log('payload', payload);
        }
      );
      return () => unsubscribe();
    },
    [videoId]
  );

I'm trying to install polyfill manually but got another issue with localstorage that doesn't exist on React Native.
facebook/react-native#23922 (comment)
Simulator Screen Shot - iPhone 14 Pro - 2022-12-31 at 17 47 04
Simulator Screen Shot - iPhone 14 Pro - 2022-12-31 at 17 42 51
Screenshot 2022-12-31 at 17 47 23

๐Ÿ‘ Expected behavior

should print the console logs for the payload

๐Ÿ‘Ž Actual Behavior

Error: URLSearchParams.set is not implemented

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

System:
    OS: macOS 13.1
    CPU: (8) x64 Apple M1
    Memory: 37.08 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.7.0/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
    Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/tuannguyen/.rvm/gems/ruby-2.7.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 29, 31, 32, 33
      Build Tools: 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
      System Images: android-32 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.5 => 0.70.5 
    expo: 47.0.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: List Teams in Account.get()

๐Ÿ”– Feature description

I don't find a way to get the list of teams that the user belongs to, unless using Users.

I need to manage the logged user authorizations in my app, so I think it would be very useful if we can find out which Teams the user is a member of in the Account Object returned by Account.get().

๐ŸŽค Pitch

It will be very easy to manage authorizations in the application.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Replace cross-fetch with fetch

๐Ÿ”– Feature description

Replace the cross-fetch library with the native browser fetch Implementation

๐ŸŽค Pitch

I want to call a cloud Function using the SDK in a chrome extension service worker. However chrome extension service workers do not support XHR Requests, only the native fetch API

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: setting header "X-Fallback-Cookies" gets overwritten on request

๐Ÿ‘Ÿ Reproduction steps

Setting header "X-Fallback-Cookies" without "cookieFallback" inside localStorage always sets the header to blank string.

  1. Signin user inside +page.server.js form action and set returned cookies on the response object with "httpsOnly" flag set to false
export const actions = {
	login: async ({ request, cookies }) => {
		const data = Object.fromEntries(await request.formData());
		try {
			const response = await fetch(`${AppwriteEndpoint}/account/sessions/email`, {
				method: 'POST',
				headers: {
					'x-appwrite-project': AppwriteProject,
					'Content-Type': 'application/json'
				},
				body: JSON.stringify({
					email: data.email
					password: data.password
				})
			});
			const json = await response.json();
			const cookiesArray = splitCookiesString(response.headers.get('set-cookie'));
			const cookiesParsed = cookiesArray.map((cookie) => parseString(cookie));
			for (const cookie of cookiesParsed) {
				cookies.set(cookie.name, cookie.value, {
					domain: cookie.domain,
					secure: cookie.secure,
					sameSite: cookie.sameSite,
					path: '/',
					maxAge: cookie.maxAge,
					httpOnly: false,
					expires: cookie.expires
				});
			}
			
		} catch (e) {
			console.log(e);
		}
	}
};
  1. Load value from the previously set cookie inside +page.svelte file and add header.
const cookiesArray = splitCookiesString(document.cookie, ';');
		const cookiesParsed = cookiesArray.map((cookie) => parseString(cookie));

		cookiesParsed.map((cookie) => {
			if (cookie.name === 'a_session_' + AppwriteProject) {
				AppwriteService.setSession(cookie.value);
			}
		});

Appwrite.setSession function:

setSession: (hash) => {
		const authCookies = {};
		authCookies['a_session_' + AppwriteProject] = hash;
		client.headers['X-Fallback-Cookies'] = JSON.stringify(authCookies);
	}

๐Ÿ‘ Expected behavior

The header "X-Fallback-Cookies" gets set to the loaded value and a client side request will be send with the header present.

๐Ÿ‘Ž Actual Behavior

Since the localstorage is empty the provided value gets overridden with an empty string and the request will fail with a 401 error.

i believe the bug happens inside client.ts on line 373-375:

if (typeof window !== 'undefined' && window.localStorage) {
            headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? '';
        }

there is no check if "X-Fallback-Cookies" is present at the time of the request so the value will always be overwritten if window and window.localStorage return true.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

Sveltekit 1.22.3
Appwrite 1.3.7
Appwrite Client: 11.0.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: List collections

๐Ÿ”– Feature description

I would be nice if the list collections method is implemented in the web-sdk as well.
Currently only the node server SDK includes the listCollections method.

Is there any restriction on why this can't we used on the web-sdk?

๐ŸŽค Pitch

To be more flexible it would be nice to also have some methods from the node-sdk available in the web-sdk. I could then remove the node-js middleware.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Realtime/Websocket stuck with previous user after new user has logined

๐Ÿ‘Ÿ Reproduction steps

Config/Setup:

  • I am using Appwrite v:0.13.4.304, WebSDK 7.0.0, and node-appwrite 5.0.0
  • Database collection is setup as Document Level permission
  • Documents read permission are assigned appropriately like so, e.g. user:UserID
  • There is a collection with only couple of documents with read access for User A, but NOT User B

To reproduce:

  1. Login as User A , e.g. sdk.account.createSession(User A email, User A password)

  2. At a React page, using WebSDK to subscribe to a channel like so

  useEffect(() => {
    const unsubscribe = sdk.subscribe(`collections.COLLECTION_ID.documents`,
      res => {
        console.log('realtime response', res)
      }
    )

    return () => {
      unsubscribe()
    }
  }, [])
  1. Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed

  2. User A logout, unsubscribe() is fired, and then User A is logout like so sdk.account.deleteSession('current') / sdk.account.deleteSession(session_id)

  3. At the same browser tab, User B login, e.g. sdk.account.createSession(User B email, User B password), and visit the same page, so step 2 above is executed as well
    NOTE: Don't refresh browser page, if you have refreshed browser page you can't reproduce the issue

  4. Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed, which is not expected behaviour as only User A has read permission, not User B

๐Ÿ‘ Expected behavior

I should not receive any channel/subscription callback when I login as User B

๐Ÿ‘Ž Actual Behavior

I receive channel/subscription callback when I login as User B, but User B doesn't have any read permission on the subscribed data collection (Where the callback response data is for User A)

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

  • Frontend using React 17.x, and WebSDK 7.0.0
  • Backend using Node 14.x and Appwrite Node client 5.0.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: React Native Realtime

๐Ÿ‘Ÿ Reproduction steps

When i Subscribe to any events on react native expo. every 30sec to 1min I get "Realtime got disconnected. Reconnect will be attempted in 1 seconds., undefined" error.

Steps to reproduce

  1. just create a react native expo app
  2. subscribe to any collection and check the console logs

๐Ÿ‘ Expected behavior

connection should be stable

๐Ÿ‘Ž Actual Behavior

Screenshot 2022-07-08 at 5 17 45 AM

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: getFileView() missing project

๐Ÿ‘Ÿ Reproduction steps

  • try to pull a FileView with the SDK
  • print the path to it in the console

๐Ÿ‘ Expected behavior

path should end with ?project={projectID}

๐Ÿ‘Ž Actual Behavior

It end just with ?view, making it impossible for appwrite to know which project the file is pulled from

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

Runs on Ubuntu latest, using Cloudflare as my DNS manager and it is proxied via cloudflare. Turning it off has no effect whatsoever.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Cannot find module 'appwrite' or its corresponding type declarations.ts(2307) in Angular project

๐Ÿ‘Ÿ Reproduction steps

I have an Angular project version 14.2.0. Installing the new version 10.0.0 gives the following error:
Cannot find module 'appwrite' or its corresponding type declarations.ts(2307)
Worked with previous 9.0.2 version.
Looked in node_modules/appwrite folder, and types folder is missing. It was present i previous version.

๐Ÿ‘ Expected behavior

Types should be present and no error in code.

๐Ÿ‘Ž Actual Behavior

Module import error.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: cloud.appwrite.io/v1/account/sessions/current 400 (Bad Request)

๐Ÿ‘Ÿ Reproduction steps

Issue await account.updateSession('current') which sends a request to https://cloud.appwrite.io/v1/account/sessions/current and results in AppwriteException: invalid_request: Missing required parameter: refresh_token

๐Ÿ‘ Expected behavior

The docs suggest using the string current to refresh the current session, however that appears to be an invalid request: https://appwrite.io/docs/references/cloud/client-web/account

๐Ÿ‘Ž Actual Behavior

400 response from the endpoint

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

This is after authenticating with oAuth (Google) - I can issue account.getSession('current') and it returns fine. This is being issued from the browser, not Node.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Option to disable Cookies

๐Ÿ”– Feature description

You should add an option to disable cookies and use local storage instead.

// Init your Web SDK
const client = new Client();

client
    .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint
    .setProject('455x34dfkj') // Your project ID
    .useCookies(false)
;

๐ŸŽค Pitch

By providing an option to disable cookies and use local storage instead can help developers comply with EU data protection laws (GDPR), respect user privacy preferences, enhance privacy control, improve performance, and ensure cross-domain compatibility. By considering these factors, the SDK can offer a more versatile and privacy-conscious solution for web application development.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Node dependencies prevent SSR (like Remix) on Cloudflare Pages

๐Ÿ‘Ÿ Reproduction steps

Using https://github.com/Meldiron/appwrite-ssr-remix from @Meldiron, replace @remix-run/node with @remix-run/cloudflare.

The workaround (for Node) is to use installGlobals as seen in https://github.com/Meldiron/appwrite-ssr-remix/blob/main/server.ts, however this is not available for Cloudflare as Workers use the V8 runtime.

๐Ÿ‘ Expected behavior

The client should not use isomorphic libraries, and instead determine which libraries to use based on the platform. <-- guessing here

๐Ÿ‘Ž Actual Behavior

Using import { Client } from 'appwrite' in a server file will cause Uncaught ReferenceError: window is not defined due to the use of node_modules/isomorphic-form-data/lib/browser.js which does not work on edge (Workers). Pages is built on Workers, so it prevents deployment.

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: CommonJS or AMD dependencies can cause optimization bailouts

๐Ÿ‘Ÿ Reproduction steps

Add the Appwrite web SDK to an angular project.
Run the build command to compile.

npx nx run oncampus-cms:build --parallel

Should also occur when execute it with
ng serve

๐Ÿ‘ Expected behavior

No warnings regarding "CommonJS or AMD dependencies can cause optimization bailouts" should appear while compiling the project

๐Ÿ‘Ž Actual Behavior

Receiving two warnings with dependencies that are not optimized:

Warning: /Users/marcelpochert/Programming/Work/on-campus/node_modules/appwrite/dist/esm/sdk.js depends on 'cross-fetch'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/marcelpochert/Programming/Work/on-campus/node_modules/appwrite/dist/esm/sdk.js depends on 'isomorphic-form-data'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

Using version "appwrite": "^9.0.1"
Angular Version 14.2.0

Withing an nx mono repo

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: File Upload not working

๐Ÿ‘Ÿ Reproduction steps

When I want to create a file using createFile I get the error:

AppwriteException: Network request failed at Appwrite._callee56$ (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:261917:25) at tryCatch (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:28085:19) at Generator.invoke [as _invoke] (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:28255:24) at Generator.throw (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:28127:23) at rejected (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:258615:34) at tryCallOne (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:32938:14) at http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:33039:17 at http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:33479:21 at _callTimer (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:33367:9) at _callImmediatesPass (http://192.168.178.53:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&strict=false&minify=false:33406:7)

I debugged the request at the server and I get the POST request:

"POST /v1/storage/buckets/default/files/ HTTP/2.0" 400 1527 "-" "okhttp/3.14.9"

But when I do it with the appwrite web console I get:

"POST /v1/storage/buckets/default/files HTTP/2.0" 201 216 "https://appwrite.oberhauser.dev/console/storage/bucket?id=default&project=619d57cbe54c9" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0"

So it looks like projectID and bucketID is missing.

And indeed, if I add the two params to this line https://github.com/appwrite/sdk-for-web/blob/6bedd589a9be12407d7756dd3231b4459a7f8631/src/sdk.ts#L2935

payload['id'] = bucketId;
payload['project'] = this.config.project;

and also add the query params to POST requests: https://github.com/appwrite/sdk-for-web/blob/6bedd589a9be12407d7756dd3231b4459a7f8631/src/sdk.ts#L1098

then the request is accepted, but returns an empty error message.

Appwrite version is 0.13.3, couldn't select it from this template.

๐Ÿ‘ Expected behavior

It should be able to upload the file, so it should lead to this request + body:

"POST /v1/storage/buckets/default/files HTTP/2.0" 201 216 "https://appwrite.oberhauser.dev/console/storage/bucket?id=default&project=619d57cbe54c9" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0"

๐Ÿ‘Ž Actual Behavior

It leads to this request:

"POST /v1/storage/buckets/default/files/ HTTP/2.0" 400 1527 "-" "okhttp/3.14.9"

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

Using this in a react-native app and accessing an appwrite server on a Raspberry PI 4, running Ubuntu Server 21.10

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

React Native / Expo support

๐Ÿ”– Feature description

Hello!
Can this sdk be used with React Native? I was thinking that things like authentication with oauth providers would not work.
Thanks!

๐ŸŽค Pitch

Perhaps some alternative methods could be implemented for executions in these environments.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Unable to get browser avatar

Hey,

I'm want to get some browser images for a profile overview. I noticed that the sdk does fetch the image with the incorrect content type (it uses "application/json" instead of "image/png").

Additionally the doc says that sdk.avatars.getBrowser(...) returns the image url, which is not correct. It returns the image content.
Personaly I think it might be better to return the url, but thats just me :)

๐Ÿš€ Feature: globalThis

๐Ÿ”– Feature description

in the javscript client SDK, make it more compatible in a wider amount of uh, environments, or something, by using the globalThis context instead of window and this

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis

๐ŸŽค Pitch

God uh like, i dont, ugh, like, it will work better ???

Like im making a browser game and want to use appwrite and i want performance and responsiveness so like I run it in a web worker so it's not blocking but that locks me out of the DOM and i lose window access and like, all your uh, bindings? variables? i dont know the word, are written in the window context instead of using the much more compatible globalThis property that probs wouldn't break anything in ur code and broaden ocmpatibility to like allow it to also run on nodejs and deno maybe ?? and like that'S a good thing I think ? because it would be a pain in the ass to change the minified file every time myself when there'S an update when you could just, do it yourself and make your thingy thing better for everyone at the same time

dab, vineboom !!!

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Upload Progress not being reported

๐Ÿ‘Ÿ Reproduction steps

    try {
      const upload = await storage.createFile('uploads', ID.unique(), file, [Permission.read(Role.any())], (uploadProgress) => {
        console.log('Progress', uploadProgress)
      });

      console.log("Upload completed", upload);
    } catch (error) {
      console.error("Error while uploading file: ", error);
    }
  };

๐Ÿ‘ Expected behavior

The console.log in the callback should be updated, so I can report the upload progress to the user.

๐Ÿ‘Ž Actual Behavior

Sadly, the callback isn't emitting any events. The file gets uploaded correctly.

๐ŸŽฒ Appwrite version

Cloud Beta

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: We should remove top level `types` field in `package.json`.

๐Ÿ‘Ÿ Reproduction steps

  1. Initialize a TypeScript project with moduleResolution: "bundler" in your tsconfig.
  2. Install appwrite web sdk.
  3. Try to import it you will see that for the sdk, types will be undefined.

This is due to the fact that for TypeScript to work with packages that have exports field when using the new moduleResolution: node16/nodenext/bundler settings. When those are not used then TypeScript just ignores package.json#exports - but when you make it aware of exports by using those options then it requires the types to be included in exports and not as the top-level key of package.json.

You can also visit this tool to check that the types for this sdk are definitely wrong: https://arethetypeswrong.github.io/.

๐Ÿ‘ Expected behavior

Types should be well defined.

๐Ÿ‘Ž Actual Behavior

Types aren't well defined with moduleResolution: "bundler" option on in your tsconfig.json.

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Some TypeScript Definitions incorrectly have have parameters that are non-optional when they should be optional

For example, The storage.listFiles() function should have all optional parameters, while instead all of them are non-optional.

The code for this particular issue is here:
https://github.com/appwrite/sdk-for-js/blob/3f71ea130d6c91ea484f9de821a9ec74345d4160/types/index.d.ts#L582

This should be replaced with

listFiles(search?: string, limit?: number, offset?: number, orderType?: string): Promise<object>;

Which will make all the parameters optional, allowing the function to be used just to list all the files.

Over the coming days, I'll take a look at index.d.ts more closely and try to find a couple more instances of this occurring.

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

๐Ÿ› Bug Report: Origin localhost not allowed when fetching file

๐Ÿ‘Ÿ Reproduction steps

Running a local instance of appwrite, use Safari as a browser and fetching data from a link returned by getFileView

const url = storage.getFileView(BUCKET_ID, fileId);
axios
  .get(url.href)
  .then((response) => console.log(response))
  .catch((error) => console.log(error));

๐Ÿ‘ Expected behavior

Returns the data from the file.

๐Ÿ‘Ž Actual Behavior

[Error] XMLHttpRequest cannot load http://localhost/v1/storage/buckets/62e3ed0fc097798c4bfe/files/62e3ed7e4eafee1a50d1/view?project=625ec35b68a2dcb2d0fd due to access control checks.
[Error] Failed to load resource: Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. Status code: 200 (view, line 0)

๐ŸŽฒ Appwrite version

Version 0.9.x

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: storage.createFile() looses mimeType and stops at 0 bytes when uploading

๐Ÿ‘Ÿ Reproduction steps

When using sdk-for-web for react-native createFile looses the mimetype and stops at 0 bytes when uploading a file

const blob = new Blob(['Hello World'], {
type: 'plain/text',
} as BlobOptions);
//@ts-ignore
const file = new File([blob], fileName, {type: blob.type});
const response = await storage.createFile(BUCKET_ID, ID.unique(), file);

Bildschirmfoto 2023-07-03 um 23 23 00

The same behaviour is when i upload an image from rn-image-picker.

๐Ÿ‘ Expected behavior

it should upload a file and keeping the mimetype.

๐Ÿ‘Ž Actual Behavior

it stops at 0 bytes and looses the mimeType.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

Appwrite Client Version: 11.0.0
Appwrite Server: 1.3.7
React-Native Version: 0.71.11

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Add JSDocstrings (I Closed It)

๐Ÿ”– Feature description

Please add JSDocstring to all appwrite's classes/functions. such as the Client, Database, Accounts, etc classes and their methods. I can provide all of them if you need.

๐ŸŽค Pitch

They can be very useful for people who use IDEs for coding, as IDEs can fetch the Docstrings and tell the user about the methods/functions instead of the user opening up documentation in the browser.
I need this very much

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Syntax highlighting missing from example docs

I noticed that the example docs are Markdown files, but the contents are not inside code blocks. As a result the code is missing syntax highlighting, and indentation is broken.

How it looks currently:

let sdk = new Appwrite();
sdk .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ;
// Go to OAuth provider login page sdk.account.createOAuth2Session('amazon');

With code block:

let sdk = new Appwrite();

sdk
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

// Go to OAuth provider login page
sdk.account.createOAuth2Session('amazon');

๐Ÿ› Bug Report: Database listDocuments method return old/cached data

๐Ÿ‘Ÿ Reproduction steps

Create a document within a collection using 'createDocument' and update using 'updateDocument'. Now fetch the document list using listDocuments returns old data. The same happens even after the entire collection has been deleted, the method returns the data that does not exist. Tried on the incognito tab, and on the first query, it returned the correct data, further updates to the document resulted in the same behavior.

๐Ÿ‘ Expected behavior

Should return up-to-date data from database

๐Ÿ‘Ž Actual Behavior

Returns old or deleted documents

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

appwrite-web-sdk v13.0.0
appwrite server v1.4.4 self-hosted on digitalocean
Frontend React v18.2.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Enhancement: Custom type for OAuth2Provider instead of string

๐Ÿ”– Feature description

image
Custom type for OAuth2Provider instead of string like the one used here in appwrite-react
https://github.com/sanny-io/react-appwrite/blob/main/src/account/types.ts

export type OAuth2Provider =
  | 'amazon'
  | 'apple'
  | 'auth0'
  | 'authentik'
  | 'autodesk'
  | 'bitbucket'
  | 'bitly'
  | 'box'
  | 'dailymotion'
  | 'discord'
  | 'disqus'
  | 'dropbox'
  | 'etsy'
  | 'facebook'
  | 'github'
  | 'gitlab'
  | 'google'
  | 'linkedin'
  | 'microsoft'
  | 'notion'
  | 'okta'
  | 'paypal'
  | 'paypalSandbox'
  | 'podio'
  | 'salesforce'
  | 'slack'
  | 'spotify'
  | 'stripe'
  | 'tradeshift'
  | 'tradeshiftBox'
  | 'twitch'
  | 'wordpress'
  | 'yahoo'
  | 'yammer'
  | 'yandex'
  | 'zoom'

๐ŸŽค Pitch

It can provide better developer experience.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Websocket Connect and Disconnect Events

๐Ÿ”– Feature description

Have the Client.Realtime emit events when the websocket connects and disconnects

๐ŸŽค Pitch

Currently there is no way to detect this.
If the websocket disconnects and you are relying on the realtime connection to track data between the client and the database, you will miss CRUD events, and your client data may not reflect the database data.
With events indicating WSS connect and disconnect, this would allow feedback to the user that it is no longer realtime, and to do a full data refetch/refresh when the websocket connects.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: JSDocstrings for functions not appearing in VSCode Intellisense thingy when using Web SDK

๐Ÿ‘Ÿ Reproduction steps

  1. Open HTML file.
  2. Add Web SDK CDN.
  3. Initialize Appwrite Client using:
const client = new Appwrite.Client()
  1. Set Projects, Endpoint:
client.setProject("myProject");
client.setEndpoint("https://cloud.appwrite.io/v1")
  1. Hover over client.setProject("myProject"); or client.setEndpoint("https://cloud.appwrite.io/v1") and see no JSDocstring.

๐Ÿ‘ Expected behavior

When I hover over the client.setProject("myProject"); or client.setEndpoint("https://cloud.appwrite.io/v1") part, it should show the JSDoc using this Docstring provided in your source code:

/**
     * Set Endpoint
     *
     * Your project endpoint
     *
     * @param {string} endpoint
     *
     * @returns {this}
*/

or

/**
     * Set Project
     *
     * Your project ID
     *
     * @param value string
     *
     * @return {this}
*/

๐Ÿ‘Ž Actual Behavior

They actually don't. I am not sure if this is a problem by the IDE or not.

๐ŸŽฒ Appwrite version

Version 0.10.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

Vercel for hosting. VSCode 1.70.3 as IDE, Windows 7 for OS, HP Probook 4520s for Machine

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Realtime channel still receiving data after user session is deleted/logout

๐Ÿ‘Ÿ Reproduction steps

Config/Setup:

  • I am using Appwrite v:0.13.4.304, WebSDK 7.0.0, and node-appwrite 5.0.0
  • Database collection is setup as Document Level permission
  • Documents read permission are assigned appropriately like so, e.g. user:UserID
  • There is a collection with only couple of documents with read access for User A, but NOT User B

To reproduce:

  1. Login as User A , e.g. sdk.account.createSession(User A email, User A password)

  2. At a React page, using WebSDK to subscribe to a channel like so

  useEffect(() => {
    const unsubscribe = sdk.subscribe(`collections.COLLECTION_ID.documents`,
      res => {
        console.log('realtime response', res)
      }
    )

    return () => {
      unsubscribe()
    }
  }, [])
  1. Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed

  2. User A logout, unsubscribe() is fired, and then User A is logout like so sdk.account.deleteSession('current') / sdk.account.deleteSession(session_id)
    NOTE: Don't refresh browser page or close the browser tab, if you have refreshed browser page or close the browser tab you can't reproduce the issue

  3. Update any of the documents on the said collection from Appwrite Console, at the same browser tab where sdk.account.deleteSession is executed and I can noticed data is still being received As seen in image below where data still coming into Websocket , but channel/subscription callback is NOT executed

image

๐Ÿ‘ Expected behavior

As described in reproduction steps above, I am expecting Websocket stop receiving data after session is removed after sdk.account.deleteSession('current') / sdk.account.deleteSession(session_id)

๐Ÿ‘Ž Actual Behavior

After sdk.account.deleteSession('current') / sdk.account.deleteSession(session_id), Websocket still receiving data

image

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

  • Frontend using React 17.x, and WebSDK 7.0.0
  • Backend using Node 14.x and Appwrite Node client 5.0.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ“š Documentation: missing setSelfSigned on js client

๐Ÿ’ญ Description

Thanks for Taking your time.

Im currently struggling to get the Appwrite web SDK to connect to my locally hosted Appwirte instance.

I spun up AppWrite inside Docker, and setup a new project "testing". When i try to sign in a user via the SKD, i get "404 | ERR_CERT_AUTHORITY_INVALID"
When i try to set "setSelfSigned()" on the client i get the error "client.setEndpoint(...).setProject(...).setSelfSigned is not a function".

Here is my AppwriteService.js file:

import { Account, Avatars, Client, Teams, Storage, Databases, Functions } from 'appwrite';
  
  export const AppwriteEndpoint = "https://localhost/v1";
  export const AppwriteProject = "testing";
  
  const client = new Client().setEndpoint(AppwriteEndpoint).setProject(AppwriteProject).setSelfSigned();
  const account = new Account(client);
  const avatars = new Avatars(client);
  const teams = new Teams(client);
  const storage = new Storage(client);
  const databases = new Databases(client);
  const functions = new Functions(client);
  
  export const AppwriteService = {
	  signOut: async () => {
		  await account.deleteSession('current');
	  },
	  signIn: async (email, password) => {
		  await account.createEmailSession(email, password);
	  },
	  setSession: (hash) => {
		  const authCookies = {};
		  authCookies['a_session_' + AppwriteProject] = hash;
		  client.headers['X-Fallback-Cookies'] = JSON.stringify(authCookies);
	  }
  };

I cant find any documentation on how to get this working. With the node-appwrite package it works like expected, but in the web SDK i cant get it working.

Im using SvelteKit 1.21.0
AppWrite Web SDK version 11.0.0

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ› Bug Report: Appwrite Rest endpoint expects 'passwordAgain' param when calling account.updateRecovery

๐Ÿ‘Ÿ Reproduction steps

Install appwrite web sdk, configure w/ v1 endpoint (https://cloud.appwrite.io/v1), and attempt to call account.updateRecovery. The method accepts 3 args (userId, secret, and password), but the endpoint is expecting a separate "passwordAgain" param.
Also, docs still show that the method accepts a 4th "paswordAgain" arg, but in v14.0.0 of sdk it does not support that argument.

๐Ÿ‘ Expected behavior

I'm able to use the updateRecovery method to confirm password reset by passing 3 arguments - userId, secret, and password.

๐Ÿ‘Ž Actual Behavior

I get an error saying that "passwordAgain" param is required, but updateRecovery method does not support it.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

Local environment, node 20.5.1, appwrite 14.0.0 configured with v1 endpoint

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿ“š Documentation: links looks wrong at the bottom of Readme file

๐Ÿ’ญ Description

The Getting Started link at the bottom of the readme file (below the Learn More section) looks wrong. If you click on it, you will be navigated to getting started with flutter docs. even in the last link, flutter have been mentioned in it. "Appwrite Flutter Playground".

also, the "Code of Conduct" link is broken too. I didn't see such a file nor in this repo or appwrite itself.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

remove all dep

sdk-for-web/package.json

Lines 34 to 37 in 7b37a2b

"dependencies": {
"cross-fetch": "3.1.5",
"isomorphic-form-data": "2.0.0"
},

formdata + fetch is built-in to all evergreen env. (NodeJS v18+)
if it isn't just let the developer who depend on this package bring them in themself if they need to.

Add Support for Queries with Large Numbers (BigInt/BigNumber)

In my database, I am using large integers (e.g. 76561198060487740) for storing userIDs that I receive from an external API, which is larger than the MAX_SAFE_INT for the javascript number primitive.
Unfortunately, queries using .listDocuments only allow the primitive type number. I have workarounded this for now by storing a copy of the ID as a string, but it would be much better to be able to query this by integer value.

I just started using Javascript a few days ago so maybe there is an alternative here that I am not aware of, suggestions would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.